pyrochlore / obsidian-tracker

A plugin tracks occurrences and numbers in your notes
MIT License
1.31k stars 229 forks source link

Use threshold for streaks #77

Open ramon86 opened 2 years ago

ramon86 commented 2 years ago

I would love to be able to determine streaks based on a threshold parameter. For example, I have a habit I track with a numeric value and I'd like to display the streak length etc. for cases where the number is at least some specific threshold value, similar to the existing threshold value for the calendar view.

pyrochlore commented 2 years ago

Hi, @ramon86,

A bullet chart might fit your requirement, showing the numbers (streak) and a mark (threshold) at the same time.

If not, could you describe what kind of graph you want to show your data?

ramon86 commented 2 years ago

Aaah, I see that I forgot to mention this was about summaries hehe, my bad :)

This is specifically for the maxStreak function for summaries (and the related ones for start and end date). I see that it currently counts it by checking for non-null values:

dataPoint.value !== null

Could the functions/expressions maybe get an (optional) parameter, where the check is extended to verify that dataPoint.value is at least the provided threshold parameter?

pyrochlore commented 2 years ago

The best way to make this happen would be a new Expression function. For example, a function call removeValueLowerThan. Then pass the result to maxStreak. Any suggestion about this?

ramon86 commented 2 years ago

Aah yes, that would work perfectly for my use case! Makes sense to me to make a separate expression function for it to make it useable in a broader context.

pyrochlore commented 2 years ago

Will do.

niamurrell commented 1 year ago

Seconding this and chiming in with another use case 😊

For a habit I track with tags, it sometimes has a value of 0 (as in, I didn't do it that day). If there was a threshold, I could exclude these values from the streaks.

As far as I can tell I can't remove the tag entirely, because then it won't reflect 0 on the corresponding line graph—the current options are either blank (i.e. not a continuous line) or use fillGap, which also doesn't reflect the accurate count of zero.

Thanks!