Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daily Note Checkboxes #111

Open
marcellonovak opened this issue Feb 13, 2024 · 0 comments
Open

Daily Note Checkboxes #111

marcellonovak opened this issue Feb 13, 2024 · 0 comments

Comments

@marcellonovak
Copy link

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

@randomuserjusttoask
Copy link

Hi!

I'm tracking my sports activities in a similar way. I think you also need tasks plugin to be installed for this to work.
As you can see below I get different number of points for different kind of activities:
Run gives 5 points, #stretch gives 1 and #excercise gives 2.
Here are my daily note template and heat calendar code:

### [[Exercises/Run|Run]]
[distance:: ]
[duration:: ]
[avgbpm:: ]
[maxbpm:: ]
[level:: ]
[sequence:: ]
### [[Stretching]]
* [ ] Stretch Quad #stretch 
* [ ] Stretch Harmstring #stretch 
* [ ] Stretch Groin #stretch 
* [ ] Stretch Gluteus #stretch 
* [ ] Stretch Shoulder #stretch 
* [ ] Stretch Overhead #stretch 
* [ ] Stretch Head #stretch 
### [[Bodyweight excercise]]
- [ ] Hyperextension #excercise 
- [ ] Squads #excercise 
- [ ] Pull-ups #excercise 
- [ ] Single leg squats #excercise 
- [ ] Press #excercise 
dv.span("**Calendar**") /* optional ⏹️💤⚡⚠🧩↑↓⏳📔💾📁📝🔄📝🔀⌨️🕸️📅🔍✨ */
const calendarData = {
    showCurrentDayBorder: true, // (optional) defaults to true
    defaultEntryIntensity: 4,   // (optional) defaults to 4
    intensityScaleStart: 0,    // (optional) defaults to lowest value passed to entries.intensity
    intensityScaleEnd: 25 ,     // (optional) defaults to highest value passed to entries.intensity
    entries: [],                // (required) populated in the DataviewJS loop below
}

const journalPath = '"Journal"';
var journals = dv.pages(journalPath)

for (let page of dv.pages('"Journal"')) {
	i = 0
	if (page.distance) {
		i = i + 5
		}
	i = i + page.file['tasks'].filter(t => t.tags == '#stretch').where(t => t.completed).length + page.file['tasks'].filter(t => t.tags == '#excercise').where(t => t.completed).length*2
//	dv.span("<br>"+ page.file.name + i) // uncomment for troubleshooting
    calendarData.entries.push({
        date: page.file.name,     // (required) Format YYYY-MM-DD
        intensity: i // (required) the data you want to track, will map color intensities automatically
    })
}

renderHeatmapCalendar(this.container, calendarData)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants