score:1

Accepted answer

basic on your yaxis.max settings we can check which points with stacktotal higher than setting are visible and what categories they have assigned.

let ar = []
chart.series.foreach(s => {
    s.points.foreach(p => {
    if (p.stacktotal > chart.yaxis[0].datamax * 0.3){
        ar.push(p.category)
    }
  })
})

when we have an array of visible categories as a next step we need to get the unique values from it.

let xaxiscat = [... new set(ar)];

as a final step, we can set the new xaxis.max as a length of this array and categories to this array.

demo: https://jsfiddle.net/blacklabel/y92usjvf/

this is a solution without changing the data for your particular case.

score:0

make your xaxis.categories dynamic and dependent on your data collection's length

pseudo:

  1. get maximum length of columns in every row of your data.
  2. set that length to your xaxis.categories so that it'll only match the data you provided.

Related Query

More Query from same tag