chrismi
Posts: 2
Joined: Mon Jan 24, 2022 9:15 pm

Negative Numbers in Red for y-axis of Line Plot

Hello,
Do you know if there is a (simple) way to have the negative numbers of the y-axis in red?

I did some research but I have only found options to either have the background of the entire negative part of the chart in red or to have a red line vertically covering the negative part of the y-axis. I saw some cases combining a recursive function in the formatter to change the values but I didn't manage to include any color formatting for negative numbers.

I saw the options to have the line plot of another color for negative numbers but I am not interested in this. My line will only cover negative numbers therefore it would help. I just want to highlight that they are negative numbers.

I am a bit out of clues!

Thanks!
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Negative Numbers in Red for y-axis of Line Plot

Hi chrismi,

Welcome to our forum and thanks for contacting us with your question!

You're right, to have something like that you can use formatter callback.
Demo:https://jsfiddle.net/BlackLabel/t2naxjhL/
API reference: https://api.highcharts.com/highcharts/y ... .formatter

Let me know if that was what you were looking for!
Regards!
Mateusz Bernacik
Highcharts Developer
chrismi
Posts: 2
Joined: Mon Jan 24, 2022 9:15 pm

Re: Negative Numbers in Red for y-axis of Line Plot

This is exactly what I was trying to do. I will try to apply it to my specific case.

Thank you very much!
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Negative Numbers in Red for y-axis of Line Plot

You're welcome! In case of any further questions, feel free to contact us again.
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”