billboard.js icon indicating copy to clipboard operation
billboard.js copied to clipboard

Gauge: enforce min/max values

Open adschm opened this issue 3 years ago • 1 comments

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 avatar Jun 04 '21 09:06 adschm

@adschm, thanks for the suggestion! I'll be considering on future release.

netil avatar Jun 10 '21 01:06 netil

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

m-gallesio avatar Nov 02 '22 14:11 m-gallesio

Thanks for implementing the feature.

Just tested with the nightly build (on "multi" mode): Everything seems to work as expected/desired.

adschmu avatar Jan 26 '24 10:01 adschmu