lalana
Posts: 3
Joined: Wed Jan 26, 2022 12:02 pm

How to add two labels in Y axis

Wed Jan 26, 2022 12:09 pm

Any idea about adding two labels into y axis of line chart as show in the image,
Eg: - (above 0 'profit' and below 0 'Loss')
https://ibb.co/p4Brh6y
Image

mateusz.b
Posts: 1906
Joined: Tue Jul 13, 2021 11:34 am

Re: How to add two labels in Y axis

Wed Jan 26, 2022 12:24 pm

Hi lalana,

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

You should use yAxis.labels.formatter.
Demo: https://jsfiddle.net/BlackLabel/2tjc8wzh/

Let me know if that was what you were looking for!
Regards!
Mateusz Bernacik
Highcharts Developer

lalana
Posts: 3
Joined: Wed Jan 26, 2022 12:02 pm

Re: How to add two labels in Y axis

Thu Jan 27, 2022 2:51 am

Thanks this works!! . I was wondering if it was able to format the title instead of Label.

mateusz.b
Posts: 1906
Joined: Tue Jul 13, 2021 11:34 am

Re: How to add two labels in Y axis

Thu Jan 27, 2022 10:04 am

It would be quite hard to do something like that with title. Of course you can change title content with title.text property, but positioning and keeping it responsive could be challenging. Label formatter is much better choice. Alternatively, you could use SVGRenderer tool , which allows you to draw shapes and text on your chart, to draw those labels.

Regards!
Mateusz Bernacik
Highcharts Developer

lalana
Posts: 3
Joined: Wed Jan 26, 2022 12:02 pm

Re: How to add two labels in Y axis

Thu Jan 27, 2022 4:33 pm

Thanks for the update Mateusz

mateusz.b
Posts: 1906
Joined: Tue Jul 13, 2021 11:34 am

Re: How to add two labels in Y axis

Thu Jan 27, 2022 5:28 pm

You're welcome! In case of any further questions feel free to contact me anytime!

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”