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

The plugin should give priority to manually-set scale when mapping intensity #61

Closed THeK3nger closed 1 year ago

THeK3nger commented 1 year ago

So, I struggled for an hour to understand why this plugin failed to map my "mindfulness:: 10" entries with the correct shade of color. Then I discovered that it happened that, by coincidence, I meditated 10 minutes for the first 3 days of the year. In this case, the plugin check minimumIntensity === maximumIntensity (the actual minimum and maximum values of my entries), and because they are the same, it completely ignores my scale (that goes from 1 to 60) and try to set the intensity index 10 (that doesn't exist).

I find this behavior confusing, especially at the beginning of the year (when there are just a couple of entries and, therefore, it is very likely that minimumIntensity === maximumIntensity by accident).

A better behavior should be to always map the intensity between intensityScaleStart and intensityScaleEnd if the user set those values. If not, they will fall back to minimumIntensity === maximumIntensity and, therefore, the old behavior is preserved. So I think we can have our cake and eat it.

This PR address this.