martyna.kiljan
Posts: 38
Joined: Tue Dec 14, 2021 9:57 pm

how to make a negative value on donut charts? and change the color?

Hi, I have a few charts-donuts on the site. Some of them have negative values.
I normally have 4 colors: light blue, darker blue, navy blue and green. But when the last value is negative, the color should be orange. I do not know how to do i. It so that the automatic color changes when the value is negative (also legends)


this is my code, but unfortunately the chart is not shown but maybe someone can tell me without it?
https://jsfiddle.net/kmartynak/5fret3g2/1/

to the legend, I have a loop in sass. That's why I automatically add four colors, but not when the value is negative ...

Thank you very much.
Attachments
Bildschirmfoto 2022-01-08 um 12.52.42.png
Bildschirmfoto 2022-01-08 um 12.52.42.png (15.63 KiB) Viewed 195 times
Bildschirmfoto 2022-01-08 um 12.54.31.png
Bildschirmfoto 2022-01-08 um 12.54.31.png (14.42 KiB) Viewed 195 times
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: how to make a negative value on donut charts? and change the color?

Hi martyna.kiljan,

Thanks for contacting us with your question.

Pie series doesn't draw slices for negative values. However, you can add a custom negative property to the point which would determine if the value should be treated as negative, and then based on it you can format the label and change point's color.
Demo: https://jsfiddle.net/BlackLabel/60aw4hxn/
API reference: https://api.highcharts.com/class-refere ... int#update,
https://api.highcharts.com/highcharts/s ... .formatter

Let me know if you have any further questions!
Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”