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

Custom formatting of values

Open mohammadnouritani opened this issue 4 years ago • 12 comments

can we change the needle SVG is it possible to do that

also can we custom the label of the numbers

can we show the numbers with the custom label for segments

mohammadnouritani avatar Apr 07 '21 22:04 mohammadnouritani

can we change the needle SVG is it possible to do that

This is not possible right now.

also can we custom the label of the numbers

This should be possible with valueFormat prop.

can we show the numbers with the custom label for segments

Please share a screenshot or more info on this since I could not understand what you mean by this

palerdot avatar Apr 08 '21 02:04 palerdot

image

I want to change the 1400 and the 1700 to say " min 1400" , "max 1700"

in this image I am using the custom segments labels image

you can see that the numbers are gone

can I show both the number and the segment labels

mohammadnouritani avatar Apr 08 '21 04:04 mohammadnouritani

can I show both the number and the segment labels

No. It is not possible right now.

PRs are welcome

palerdot avatar Apr 09 '21 02:04 palerdot

I think this could be achieved by passing a formatValue function prop (which is not available now) which allows the user to customise how the values are formatted ... something like

<ReactSpeedometer 
   formatValue={value => {
      if (value === "1400") { return "min $1400" }
   }}
/>

In any case, right now this feature is not available. I will see if this can be achieved in future releases.

palerdot avatar Apr 09 '21 02:04 palerdot

@mohammadnouritani I'm reopening this issue so that issue can be worked on in future. Thank you for raising this issue.

palerdot avatar Apr 09 '21 02:04 palerdot

I think this could be achieved by passing a formatValue function prop (which is not available now) which allows the user to customise how the values are formatted ... something like

<ReactSpeedometer 
   formatValue={value => {
      if (value === "1400") { return "min $1400" }
   }}
/>

In any case, right now this feature is not available. I will see if this can be achieved in future releases.

This will change the value in the label bellow I want to change the numbers with value formate array for each segment divider

mohammadnouritani avatar Apr 09 '21 06:04 mohammadnouritani

This will change the value in the label bellow I want to change the numbers with value formate array for each segment divider

can you elaborate more with an example?

palerdot avatar Apr 09 '21 14:04 palerdot

I want to show % with vale. How can I do with gradient color.

nilesh1762 avatar Sep 16 '21 05:09 nilesh1762

I want to show % with vale. How can I do with gradient color.

can you elaborate more with an example?

palerdot avatar Sep 17 '21 03:09 palerdot

I want to show % with vale. How can I do with gradient color.

can you elaborate more with an example? Gauge_with_trend

I mean I want to show value which is connect with spedometer graph with % sign. I have attach snap.You will see every value there is % sign is attached.But I have to do this with css gradient.

nilesh1762 avatar Sep 17 '21 06:09 nilesh1762

I want to show % with vale. How can I do with gradient color.

can you elaborate more with an example? Gauge_with_trend

I mean I want to show value which is connect with spedometer graph with % sign. I have attach snap.You will see every value there is % sign is attached.But I have to do this with css gradient.

I have make same as given snap with gradient effect,

nilesh1762 avatar Sep 17 '21 06:09 nilesh1762

You can use customSegmentLabels for having more control over colors and display text - https://palerdot.in/react-d3-speedometer/?path=/story/reactspeedometer--custom-segment-labels. In this case, you have to calculate the values for display so that you can use appropriate formatting.

Example sandbox - https://codesandbox.io/s/condescending-lewin-v2vty?file=/src/App.js

palerdot avatar Sep 18 '21 04:09 palerdot

@palerdot How can I add the Target needle which is shown in the below snapshot? Do we have any prop? Could you please help I am new to React? image

muhammadnaved avatar Feb 03 '23 19:02 muhammadnaved

Custom formatting of values is now available valueFormatter prop - https://github.com/palerdot/react-d3-speedometer/issues/152

Closing this issue.

palerdot avatar Feb 05 '23 03:02 palerdot

@mohammadnouritani This option/prop is not available and also not planned.

For future updates use this issue - https://github.com/palerdot/react-d3-speedometer/issues/163

@palerdot How can I add the Target needle which is shown in the below snapshot? Do we have any prop? Could you please help I am new to React? image

palerdot avatar Feb 05 '23 03:02 palerdot