nabeeln786
Posts: 3
Joined: Tue May 04, 2021 2:48 am

[Question] Hide unwanted indexes from Y-Axis from a stacked bar chart

Expected behavior:
I have data set with building names on Y-axis and decimal values on the x-axis. I want to show users a stacked bar chart with one or more buildings. Each building has multiple decimal values associated with them. For example, if a user selects one building then the Y-axis should contain only one building name and the x-axis should have all values.

Actual behavior:
Y-axis has unknown-unwanted indexes.

Live demo with steps to reproduce:
https://jsfiddle.net/nabeelnazir796/4w8j3675/

Screenshot
![JSFiddle-Code-Playground](https://user-images.githubusercontent.c ... 29e436.png)
pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: [Question] Hide unwanted indexes from Y-Axis from a stacked bar chart

Hi! Welcome to the official highcharts forum and Thanks for contacting us with your question!
What I see in the demo, that you shared is the normal bar chart. The stacking isn't working correctly, because you created the series with type 'bar', and specified the plotOptions for 'column', so it doesn't kick in. You can either change the 'column' to 'bar' or 'series'.

https://jsfiddle.net/BlackLabel/okyq57rm/


Moving on to the next topic, you created the categories array in the configuration of the xAxis, but the categories are just replacements for respective index labels. Because you specified only 3 categories and length of your data array is bigger then 3 (it is 6 for every series) the first 3 labels are categories from the given array and every next point has a correct index as a label.

Could you specify more thoroughly, what you are expecting to achieve?
Kind regards,
Paweł Lysy
Highcharts Developer
nabeeln786
Posts: 3
Joined: Tue May 04, 2021 2:48 am

Re: [Question] Hide unwanted indexes from Y-Axis from a stacked bar chart

Thank you for getting back on this.
My requirement is: I have building names on the y-axis and numbers on the x-axis. Each building name has multiple numbers associated with it. The problem is if there is only one building on the y-axis and there are multiple numbers on the x-axis then I want only one building name on the y-axis. I don't want to show indexes on the y-axis in a stacked bar chart. Please suggest a way forward for this as the requirement is to use a stacked bar chart only. Please let me know if I can add more details to this. I know I am missing something here in the configurations of the chart but not sure how can I achieve my end goal.

There is a new fiddle link that will explain my issue in a detail:
https://jsfiddle.net/nabeelnazir796/7potdhLz/1/

Screenshot:
Stacked-bar-JSFiddle-Code-Playground.png
Stacked-bar-JSFiddle-Code-Playground.png (30.74 KiB) Viewed 580 times
pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: [Question] Hide unwanted indexes from Y-Axis from a stacked bar chart

Hi again! You can create the formatter function for the labels, and check if the value that you want to display is a string or a number. Here is the example: https://jsfiddle.net/BlackLabel/9opar2h3/a

let me know, if that works for you! Kind regards,
Kind regards,
Paweł Lysy
Highcharts Developer

Return to “Highcharts Usage”