Increase the capability of the Sparkline #6395
hiromon0125
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Considering how small Sparkline is and not very meaningful in terms of holding information, this may not be very significant to many devs, but I was trying to use Sparkline to visually display workloads based on percentage value where there is an absolute range of values where the data range is static from 0 to 100.
However with the way that Sparkline is currently implemented, the range is dynamically determined based on the data list where the minimum and maximum bucket value is being used to display the range of values. Which only work for my case if there is always a bucket with the absolute minimum and maximum value in the data list, so I wanted to add a slight extension to the Sparkline component where I can set data range argument of two float tuple.
The reason I wanted this feature is that my data does not vary greatly to really make it meaningful to visualize using Sparkline because it will just flat line for majority of the time which is not very useful.
Solution
The logic for determining the minimum and maximum value can be found in
renderable/sparkline.pyline 92.I wanted to change this logic to contain the following:
where the get_range method is the following:
This retains the original behavior, if the range is None or not passed in, and allow me to statically set a range during initialization.
I can make a PR for this change if this is something I can add to the package and update the documentation around the Sparkline component.
Beta Was this translation helpful? Give feedback.
All reactions