billboard.js
billboard.js copied to clipboard
Gauge: enforce min/max values
If I set min/max on gauge ("multi" mode*), and data goes beyond the min/max values set before, the scale is updated accordingly.
I'm looking for a way that min/max are fixed and the scale is not adjusted, so empty arc is shown for "value < min" and full arc is shown for "value > max", but if the value comes back into the earlier min-to-max range, the position would be the same as before.
While I can obviously fake this behavior for the arc by having "max([minbound min([datavalue maxbound]))" as data point, this workaround would also affect the data label, which should display the "correct" value even when without the arc range.
I suspect this could be implement relatively easy by adding a bool "fixedbounds" parameter to the gauge options dict, which would then internally switch between the current mechanism (false) and a mechanism that does some min/max enforcement for the plotted data value similar to my workaround above (true).
*
using multi here since this is broken for "single" mode (#2123), but this would obviously be helpful for both modes.
@adschm, thanks for the suggestion! I'll be considering on future release.
We have ran into this issue today.
It seems the min
value is respected but the max
value is not.
This seems to be the "offending" code: https://github.com/naver/billboard.js/blob/aad3dcc6d3c367c0ea5f7ba7e189ce9568d785cb/src/ChartInternal/shape/gauge.ts#L45
Thanks for implementing the feature.
Just tested with the nightly build (on "multi" mode): Everything seems to work as expected/desired.