Rickycadet
Posts: 8
Joined: Thu Feb 10, 2022 4:16 pm

Hiding Series using Y-axis Click event

Hi,
I am finding it difficult to hide the respective series using the respective Y-axis. My plan is to bring the functionality of legends over to Y-axis and disable legends so that the chart could take over the entire screen. I have multiple series with their respective Y-axis. Tried using events under Y-axis but didn't work.
After trying a few times, I found AfterSetExtremes() working on chart initialization. I used a function inside AfterSetExtremes( )[( Each Y-axis has its own id which on click, gives me the ID which is used to hide its respective series using the chart Instance)]
Highcharts.JPG
Highcharts.JPG (42.55 KiB) Viewed 153 times

The above function worked on whichever series was plotted during chart Initialization, I was able to get Y-axis ID and hide the respective series. (I looped through the chart instance, found the series with the Y-axis ID, and used the series. hide()/series.show())

But the above-only function worked on chart initialization only and not when new series is added dynamically, even though I am calling the above function whenever new series is added to the chart(onclick mentioned in the above function was not getting triggered). Updating the color of any series also somehow reset the respective series properties which I had changed manually using the above function.

Below I am attaching a project similar to mine.

https://jsfiddle.net/4rykzxeb/29/

Basically want to bring the x-axis click event functionality over to Y-axis.

if it helps, I am using Angular 11 and highcharts 10.3.2

Any Help is appreciated! Thank you!
User avatar
dawid.d
Posts: 837
Joined: Thu Oct 06, 2022 11:31 am

Re: Hiding Series using Y-axis Click event

Hi,

Did you mean something like in the demo below?

Demo: https://jsfiddle.net/BlackLabel/onashexu/

As a small tip, you can set the cursor in the axis title with title.style.cursor.
See: https://api.highcharts.com/highcharts/yAxis.title.style

Let me know if that was what you were looking for!
Kind regards
Dawid Draguła
Highcharts Developer

Return to “Highcharts Usage”