stargazer5
Posts: 4
Joined: Tue Nov 05, 2024 8:01 am

Update Vertical Category Axis as Visibility of Multiple Series changes

Hi,

I have a complex gantt chart with multiple points within each series, and multiple series overlaid on the same row with the y parameter.

The Yaxis is categorical with a grid table attached. Only a single series is shown by default, and the others are hidden on chart load, and selectable through the legend.

Is it possible to show only the y axis categories associated with the initially shown series, and dynamically updating as series are added/removed from the visible list?

For instance, I would like to hide category 1 when Series 1 is deselected in the legend in the fiddle here: https://jsfiddle.net/awm5y6zx/1/, show all categories when Series 1 and 2 are selected, and hide category 1 again when Series 1 is selected.

Note 1: I would move to treegrid with uniqueNames = true, but would like both series on the same "row" and am impacted by this bug: viewtopic.php?f=19&t=47851 (see https://jsfiddle.net/awm5y6zx/2/ for an example of treegrid)

Thanks in advance for your input.
andrzej.b
Site Moderator
Posts: 317
Joined: Mon Jul 15, 2024 12:34 pm

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi @stargazer5,

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

There is no API option to get the functionality you want in a straightforward way, but we can work out the helper function combined with proper chart options setup. I've prepared for you a demo, where initially yAxis categories are empty and are added only for visible series by a combination of the settings and helper function: https://jsfiddle.net/BlackLabel/s4qb3waz/

Let me know if that is what you were looking for!

Kind regards,
Andrzej
Highcharts Developer
stargazer5
Posts: 4
Joined: Tue Nov 05, 2024 8:01 am

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi @ andrzej.b,

Thanks for your reply! I think I get what you are doing, BUT
JSFiddle returns "Script error." on your code and the graph is shown with no Y-axis at all; Could you fix it?
andrzej.b
Site Moderator
Posts: 317
Joined: Mon Jul 15, 2024 12:34 pm

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi, You are right, here is the fixed version: https://jsfiddle.net/BlackLabel/wzdv6jrn/

Best,
Andrzej
Highcharts Developer
stargazer5
Posts: 4
Joined: Tue Nov 05, 2024 8:01 am

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi @andrzej.b,

Thanks again for your fixed fiddle.
I was hoping for a couple of clarifications:
1) I notice with the category label blank (through the helper function) the axis grid line still shows, just with a blank category label. Is there no way to hide it?

2) could you help explain why hiding Series1 makes Category 3 disappear, but hiding Series 2 doesn't do the same for Category 1 in my original fiddle? (Maybe there's some sorting magic I could use on my side?)
andrzej.b
Site Moderator
Posts: 317
Joined: Mon Jul 15, 2024 12:34 pm

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi,

Ad 1) For clarity, do you mean the whole row or just the label cell should disappear?

Ad 2) This is related to presetting categories and rendering logic; if there is no data for display at the end, the category can be hidden, even the whole row, but if data is conditionally hidden in the beginning, the place should stay there for better display experience.

Kind regards,
Andrzej
Highcharts Developer
stargazer5
Posts: 4
Joined: Tue Nov 05, 2024 8:01 am

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi,

RE: 1) I had meant the entire row should disappear, apologies for the lack of clarity earlier.

Appreciate your inputs so far.
andrzej.b
Site Moderator
Posts: 317
Joined: Mon Jul 15, 2024 12:34 pm

Re: Update Vertical Category Axis as Visibility of Multiple Series changes

Hi,

With the category axis, such an effect is currently not available. If you think such a feature would be useful for more users, you can request it here: https://github.com/highcharts/highchart ... new/choose You can expect possible updates or workarounds there. However, if you need a customized solution for yourself without waiting for us to resolve the request, please contact us directly.

Please let me know if I can be of any further assistance.

Kind regards,
Andrzej
Highcharts Developer

Return to “Highcharts Gantt”