react-d3-speedometer icon indicating copy to clipboard operation
react-d3-speedometer copied to clipboard

Possible to make needle stop at max value?

Open raukaute opened this issue 1 year ago • 3 comments

Hey,

I was wondering if it's possible to to prevent the needle going beyond the max-value?

Cheers!

raukaute avatar Jul 06 '23 11:07 raukaute

I don't understand. Please post a screenshot of what you are referring to.

palerdot avatar Jul 07 '23 03:07 palerdot

Sorry for the confusion. What is the maxValue used for, if the needle will never actually stop, i.e. is prevented from going beyond that value? I hope I could make my point a bit clearer. 🙈

image

raukaute avatar Jul 07 '23 08:07 raukaute

Ok. I think you should validate your value and check if it is within your range, since you are controlling the value and maxValue.

For some use cases, current behaviour may be relevant, like animating a value going out of range slightly (for eg: a speedometer showing revving of engine, which crosses the threshold). I think in general, you should control the value being animated and not just directly inject the value directly to the speedometer. For eg: passing a string as a value, will show NaN and animate to the middle. The library leaves these scenarios for the consumers to handle. I hope it makes sense.

palerdot avatar Jul 07 '23 09:07 palerdot