Richardsl / heatmap-calendar-obsidian

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

Recursive search? #11

Closed ebdavison closed 2 years ago

ebdavison commented 2 years ago

I have been using the heatmap calendar for a while and have been quite happy with it. However, I recently reorganized all of my daily notes into a YYYY/MM/Day Planner-YYYYMMDD folder structure and now all of the heatmaps I had been using are empty.

I tried to change it to a tag in the meta YAML such that the meta is something like:

---
tags:
  - dayplaner
---

as well as adding a #dayplanner tag into the body of the notes but neither of those produce a graph either.

How can I tell the heatmap generator to search all subfolders as well for data?

Code I am using:

dv.span("Course Attendance")

const calendarData = {
    year: 2022, // optional, defaults to current year
    colors: {   // optional, defaults to green
        blue:        ["#8cb9ff","#69a3ff","#428bff","#1872ff","#0058e2"], // this first entry is considered default
        green:       ["#c6e48b","#7bc96f","#49af5d","#2e8840","#196127"],
        red:         ["#ff9e82","#ff7b55","#ff4d1a","#e73400","#bd2a00"],
        orange:      ["#ffa244","#fd7f00","#dd6f00","#bf6000","#9b4e00"],
        pink:        ["#ff96cb","#ff70b8","#ff3a9d","#ee0077","#c30062"],
        orangeToRed: ["#ffdf04","#ffbe04","#ff9a03","#ff6d02","#ff2c01"]
    },
    entries: []
}

//for (let page of dv.pages('"Day Planners"').where(p=>p.course).sort(p=>p.file.name)) {
for (let page of dv.pages("#dayplanner").where(p=>p.course).sort(p=>p.file.name)) {
    calendarData.entries.push({
        date: page.file.day,
        intensity: 1
    })
}

renderHeatmapCalendar(this.container, calendarData)
Richardsl commented 2 years ago

This sounds like a dataview issue, not a heatmap calendar issue. I personally have my daily notes in a subfolder, so it should work fine.

You can check if your "for" loop is returning any data with a console.log() or like this:

for (let page of dv.pages('"Day Planners"').where(p=>p.course).sort(p=>p.file.name)) {
    dv.span(page.file.day + " - ")
}
ebdavison commented 2 years ago

Thank you. Correct on the issue being dataview but it also appeared to be some sort of cache issue. A full restart of Obsidian fixed the issue and your example code displays the proper pages.