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

Number data cant use fractions #9

Closed mmfs37 closed 2 years ago

mmfs37 commented 2 years ago

sorry if I am a bit obsessed with this plugin, I got a new "issue" Having a heatmap for every habit on the daily page is too much. I just want one that shows how many I did that day. Because I will add in the future more habits or take some away a literal score like 5 for 5 habits done and then 8 for 8 habits done would be unfair. Because if I would stop to track 5 habits because I dont want to use them I cant achieve anymore as many points as I did earlier. So the intensity would be unfair. The easiest solution is using fractions. So if I track 12 habits and completed 10 I would just type habits::10/12 and if I would add habits, I would type habits::11/13 Fractions could show it like percents but better and simpler Using fractions as numerical value doesn't work yet. I can ofc calculate them to numerical so 10/12 = 83.333% but always converting that will be pain. Is there any way to implement that or is this limited because of using the dataview?

Richardsl commented 2 years ago

i think its a limitation in dataview mainly. You could possibly separate them into two values like below:

daily note:

habitsCompleted: 8
habitsTotal: 12
---

overview note:

dv.span("**Habits**") 

const calendarData = { 
    entries: [] // populated in the DataviewJS loop below
}

for(let page of dv.pages('"Journal/Daily Notes"').where(p=>p.habitsCompleted || p.habitsTotal).sort(p=>p.file.name)){ 

    let intensity = 0
    if(page.habitsTotal == page.habitsCompleted){
        intensity = 100
    }else{
        intensity = (1/(page.habitsTotal-page.habitsCompleted))*100
    }  
    calendarData.entries.push({
        date: page.file.name, 
        intensity: intensity
    }) 

}

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

oh that is smart. Thank you a lot 👍