heatmap-calendar-obsidian icon indicating copy to clipboard operation
heatmap-calendar-obsidian copied to clipboard

How to show just a specific month?

Open adshz opened this issue 1 year ago • 3 comments

Hi there,

I was thinking about if there was a way to just show a specific month rather than a whole year, regarding the use case of tracking habits monthly.

My attempt was below


dv.span("**👟 Gym ** First Phase")

const calendarData = {
 year: 2023,   
    month: 8,
    colors: {
        white: ["#ba3030", "#c72c2c", "#ce2525", "#d62121", "#df1b1b"],
    },
    entries: []
}

for(let page of dv.pages('"--Daily Briefing--"').where(p=>p.gym)){
	 
    calendarData.entries.push({
        date: page.file.name,
        intensity: 4,
        content: "👟"
    })   
}

//console.log(calendarData)
	
renderHeatmapCalendar(this.container, calendarData)

I added a key month with the value 8 or August but I knew it didn't work after reviewing the code in main.ts ; If I wanted to develop this feature, what's the best way to do that? can you guide me a bit so I can learn and develop the specific feature for this plug in?

Best, David

adshz avatar Aug 29 '23 09:08 adshz

Maybe you've found out by yourself, but you could simply change the filter so that the heatmap is based on pages where gym is present and the month is August.

Since you're using page.file.name as the date, I'm assuming that your filenames are dates, which means every page object will have the day field available (see the docs). That field is a Luxon DateTime object.

Change where(p=>p.gym) into where(p=>p.gym && p.file.day.month == 8) and you should get what you want.

tatablack avatar Sep 16 '23 11:09 tatablack

@tatablack that is still going to render the entire year

SunnyAureliusRichard avatar Dec 23 '23 20:12 SunnyAureliusRichard

Closing as duplicate of https://github.com/Richardsl/heatmap-calendar-obsidian/issues/7

SunnyAureliusRichard avatar Dec 23 '23 20:12 SunnyAureliusRichard