kirthxxx
Posts: 3
Joined: Tue Jan 12, 2016 11:58 am

xAxis labels always be visible even if there is no data

I need xAxis labels should be visible always even if there is no data. I am passing xAxis categories dynamically. Categories will be like 12/21, 12/22, 12/23, 12/24, 12/25, 12/26, 12/27, 12/28, 12/29, 12/30, 12/31, 1/1, 1/2, 1/3 etc., date and month. I have some set of checkboxes. If I uncheck the checkbox I will hide the series related to that checkbox. If I am hiding last series the xAxis labels also hiding. I need xAxis to be visible even I uncheck all the checkboxes. If I hide all the series, then graph should be like Graph have no plots but xaxis and yaxis should be visible. Kindly provide me the steps to solve this.
Izothep
Posts: 1246
Joined: Wed Oct 07, 2015 11:50 am

Re: xAxis labels always be visible even if there is no data

The standard behaviour of Highcharts is that your axes are updated each time you are hiding or showing series.
You can change standard behaviour by using plotOptions.series.events.legendItemClick parameter:
http://api.highcharts.com/highcharts#pl ... dItemClick

You can hide or show series using this.group.hide() or this.group.show().
This example will just hide or show your series, without any calculations and for fixed width.

example:
http://jsfiddle.net/7r34djec/1/


You can also simply use chart.ignoreHiddenSeries:
http://api.highcharts.com/highcharts#ch ... ddenSeries

example:
http://jsfiddle.net/7r34djec/2/
Grzegorz Blachliński
Highcharts Developer
kirthxxx
Posts: 3
Joined: Tue Jan 12, 2016 11:58 am

Re: xAxis labels always be visible even if there is no data

Thank you so much.
ignoreHiddenSeries: false works great.
enwayshih
Posts: 7
Joined: Tue Jun 29, 2021 8:24 pm

Re: xAxis labels always be visible even if there is no data

Hi,
If I want to keep xAxis Labels, but Stack the columns, how sholud I do?
Thanks...
http://jsfiddle.net/60thfmyc/
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: xAxis labels always be visible even if there is no data

Hello enwayshih!

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

You can just set tickInterval property to one to make sure that all axis labels are displayed.

API references:
https://api.highcharts.com/highcharts/x ... ckInterval

Demo:
http://jsfiddle.net/BlackLabel/zyq467L8/

Best regards!
Dominik Chudy
Highcharts Developer
pradeepkumarreddy
Posts: 16
Joined: Mon Jun 20, 2022 1:58 pm

Re: xAxis labels always be visible even if there is no data

http://jsfiddle.net/jlbriggs/QBvLS/2/
I have set tickInterval and ignoreHiddenSeries, but still it is not working. Category without any values is not being displayed.
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: xAxis labels always be visible even if there is no data

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

You can show empty categories on the chart by setting a xAxis.max property to a value equal to the length of the category array - 1.

Demo: http://jsfiddle.net/BlackLabel/gmLtu4d3/

Let me know if you have any further questions.
Regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Usage”