Heatmap Plugin Problems: Parsing tags outside of frontmatter

What I’m trying to do

I have pages with different tags (e.g. #tag1, #tag2, #tag3).
I want to use the Heatmap Plugin to show these pages and assign them different colors (e.g. Red rectangles on the Heatmap Calendar for pages with #tag1, Blue rectangles for tag 2, and so on.)

Things I have tried

Adapting the author’s sample code below:

//
// Using multiple colors for different variations of entry
//

dv.span("**👫 Social tracker 🧑‍🤝‍🧑**")

const calendarData = {
    colors: {
        blue: ["#8cb9ff","#69a3ff","#428bff","#1872ff","#0058e2"],
        pink: ["#ff96cb","#ff70b8","#ff3a9d","#ee0077","#c30062"],
    },
    entries: []
}

for(let page of dv.pages('"daily notes"').where(p=>p.social)){
    let color = ""
    if(page.social.greg.initiative == "incoming"){color="pink"}
    
    calendarData.entries.push({
        date: page.file.name,
        intensity: page.social.greg.time,
        color: color,
        content: await dv.span(`[](${page.file.name})`), //for hover preview
    })
       
}

renderHeatmapCalendar(this.container, calendarData)

Into:

dv.span("Tags1-3")

const calendarData = {
    colors: {
        red: ["#ff0000'],
        blue: ["#8cb9ff"],
        pink: ["#ff96cb"],
    },
    entries: []
}

for(let page of dv.pages(#tag1 or #tag2 or #tag3)){
    let color = ""
    if(page.file.etags == "#tag1"){color="red"}
    if(page.file.etags == "#tag2"){color="blue"}
    if(page.file.etags == "#tag3"){color="pink}
    
    calendarData.entries.push({
        date: page.file.name,
        color: color,
        content: await dv.span(`[](${page.file.name})`), //for hover preview
    })
       
}

renderHeatmapCalendar(this.container, calendarData)

Results of adapted code: Heatmap shows all pages with tags 1 to 3, but it colors all these pages as the first color. It does not seem to actually be pulling the tags for matching, or it does not seem to be matching the tags correctly.

I have also tried page.file.tags (same wrongly-colored result), and file.tags (error).

If anyone knows how to fix the code, that would be greatly appreciated.

I hope bumping is allowed

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.