-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom legend for Heatmap chart. #53
Conversation
Screenshots! |
Passing random data from 0 to 100 inclusive.
If the legend is not passed, default (green) colors are used and starting values calculated with following function (not changed):
with the same distribution (different random data) it calculates like [0, 25, 50, 75, 100]
Hope this is useful. |
@IDDT Thanks for contributing :) Custom legend colors are great. However, having to provide manual start values for each defeats the purpose of the heatmap, as data passed is dynamic, and the breakpoints are calculated via We recommend keeping the legend colors an array, instead of an object. Any distribution fix needs to be done in |
@pratu16x7 , |
"There are different scenarios where the scale doesn't have to be calculated linearly." Example use case? Nevertheless, in that case, the only thing known about the scale before getting data would be the scale mappings, not the actual values. So it would make sense to pass the mappings (perhaps as percentages of the min-max (range)), rather than values :) |
For example using logistic function to put more highlight on minimal changes while keeping drastic changes less prominent. Another use case would be centering around 0 or around some business target, where values might be generally negative (or positive) for almost all of the scale. One more case I have in mind is visualizing body vitals, where normal and critical values are predetermined. Let me know what you think. |
2c9063b
to
1efedb3
Compare
Added a few commits, be sure to check out the docs demonstrating your idea :) Let's keep the distribution mapping as a level 2 feature (maybe a new GitHub issue? ;) ). We'll focus on covering the standard uses first. |
Explanation About What Code Achieves:
Allows to pass an optional parameter "legend" to Heatmap chart with own starting values and colors.
Remove logic to use 2nd color if the value is bigger than the starting number for the 1st color.
Therefore, use "legend" parameter in docs example as it supposed to highlight 1st commit, even though the distribution calculates starting number as 1.25 (which does not highlight 1st commit).
Screenshots/GIFs:
Example in docs.
Steps To Test:
Pass your own legend.
Look at the example in the docs with and without passing "legend" parameter.
TODOs:
None