Richardsl / heatmap-calendar-obsidian

An Obsidian plugin for displaying data in a calendar similar to the github activity calendar
Apache License 2.0
614 stars 102 forks source link

Daily Note Checkboxes #111

Open marcellonovak opened 6 months ago

marcellonovak commented 6 months ago

I'm having an issue with the plugin - I want to track how multiple things add up as a heatmap, I've attached an image below.

I want to make it so that the more things I check off in a day, the darker the cell gets - showing how well I'm doing, but it's tricky to get the heatmap to "scrape" the completed boxes, am I doing something wrong here?

I dont want these inline fields either that was just something chatgpt suggested.

Here's the code:

## Loop:
- Sleep schedule:
    - Woke up:
    - Went to bed:
- Hygiene:
    - Face cleaned: 
        -  [ ] Morning [hygiene:: 1]
        -  [ ] Night [hygiene:: 1]
        - [ ] Teeth brushed [hygiene:: 1]
    - Showered: 
        - [ ] Morning [hygiene:: 1]
       - [ ] Night [hygiene:: 1]
- Health:
    - [ ] Protein Shake [health:: 1]
    - [ ] Vitamins [health:: 1]

And here's what the bot suggested for heatmapping:

// Heatmap for Skincare
dv.span("**Skincare Tracker**");
let skincareCalendarData = {
    year: new Date().getFullYear(), // Dynamically set to the current year
    colors: {
        green: ["#c6e48b", "#7bc96f", "#49af5d", "#2e8840", "#196127"]
    },
    entries: []
};

for (let page of dv.pages('"Daily Notes"').where(p => p.file.tasks)) {
    let skincare = 0;

    // Query completed tasks with metadata for skincare
    let tasks = page.file.tasks.where(t => t.completed && t.skincare);

    for (let task of tasks) {
        skincare += task.skincare || 0;
    }

    if (skincare > 0) {
        skincareCalendarData.entries.push({
            date: page.file.name,
            intensity: skincare,
            content: "🧴",
            color: "green"
        });
    }
}

renderHeatmapCalendar(this.container, skincareCalendarData);
// Heatmap for Nutrition
dv.span("**Nutrition Tracker**");
let nutritionCalendarData = {
    year: new Date().getFullYear(), // Dynamically set to the current year
    colors: {
        blue: ["#8cb9ff", "#69a3ff", "#428bff", "#1872ff", "#0058e2"]
    },
    entries: []
};

for (let page of dv.pages('"Daily Notes"').where(p => p.file.tasks)) {
    let nutrition = 0;

    // Query completed tasks with metadata for nutrition
    let tasks = page.file.tasks.where(t => t.completed && t.nutrition);

    for (let task of tasks) {
        nutrition += task.nutrition || 0;
    }

    if (nutrition > 0) {
        nutritionCalendarData.entries.push({
            date: page.file.name,
            intensity: nutrition,
            content: "🍎",
            color: "blue"
        });
    }
}

renderHeatmapCalendar(this.container, nutritionCalendarData);

Any suggestions are helpful, thank you! image