AMAT Developer
AMAT Developer

Reputation: 23

Category is not updating for drildown bar chart

I am trying to implement Drill-down with stacked bar chart. Issue is when I click on chart it shows drill down detail but it shows more category then I am assigning. So, could you please help me to fix the issue?

My code is available in JSFIDDLE

function setChart(name, categories, data, color, level, type) {
         alert("Chart should have categories :-" + categories.length)
         chart.xAxis[0].setCategories(categories);
         //chart.xAxis[0].categories = categories;
         var dataLen = data.length;

         for (var i = 0; i < chart.series.length; i++) {
            chart.series[0].remove();
         }

         for (var i = 0; i < dataLen; i++) {
            chart.addSeries({
               type: type,
               name: name,
               data: data[i],
               level: level,
               color: color || 'white'
            });
         } 
      }

Upvotes: 2

Views: 21

Answers (1)

ppotaczek
ppotaczek

Reputation: 39069

You need to update max property:

chart.xAxis[0].update({
    categories: categories,
    max: categories.length - 1
}, false);

Live demo: https://jsfiddle.net/BlackLabel/zkquLt0y/

API Reference: https://api.highcharts.com/highcharts/xAxis.max

Upvotes: 1

Related Questions