下拉列表的类别未更新

问题描述 投票:2回答:1

我正在尝试使用堆积的条形图来进行向下钻取。问题是,当我单击图表时,它会显示钻取明细,但显示的是我要分配的更多类别。因此,您能帮我解决问题吗?

我的代码在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'
            });
         } 
      }
highcharts
1个回答
0
投票

您需要更新max属性:

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

实时演示: https://jsfiddle.net/BlackLabel/zkquLt0y/

API参考: https://api.highcharts.com/highcharts/xAxis.max

© www.soinside.com 2019 - 2024. All rights reserved.