Highcharts drilldown column to pie, axis label issue - Stack Overflow

I am using Highcharts drilldown feature and change visualization type in each level of drilldown.I hav

I am using Highcharts drilldown feature and change visualization type in each level of drilldown. I have an issue when I drillup from pie chart to columns type, the xAxis labels disapear (replaced by number values).

You can see an example in the following jsfiddle : /

When you click on "Safari" then drillup to "Browser", the xAxis values are correct but when you click on "Chrome" and drillup to "Browser", the xAxis values are replaced by numbers.

I tried to use the

chart:{ 
 event:{
  drillup: function(e) {
   var chart = this;
   chart.axes[0].update({type: "category"});
  }
 }
}

but it seems the "names" values are not correctly set in the xAxis.

Is there a way to fix that please ? Thanks

I am using Highcharts drilldown feature and change visualization type in each level of drilldown. I have an issue when I drillup from pie chart to columns type, the xAxis labels disapear (replaced by number values).

You can see an example in the following jsfiddle : https://jsfiddle/vegaelce/21ogcap9/

When you click on "Safari" then drillup to "Browser", the xAxis values are correct but when you click on "Chrome" and drillup to "Browser", the xAxis values are replaced by numbers.

I tried to use the

chart:{ 
 event:{
  drillup: function(e) {
   var chart = this;
   chart.axes[0].update({type: "category"});
  }
 }
}

but it seems the "names" values are not correctly set in the xAxis.

Is there a way to fix that please ? Thanks

Share Improve this question asked Nov 18, 2024 at 10:29 vegaelcevegaelce 1458 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Inside of the drillup event, you can update the x-axis type to category and set correct categories by extracting names from the data points.

 events: {
    drillup: function(e) {
        const categories = e.seriesOptions.data.map(data => data.name);
        
        e.target.xAxis[0].update({
            type: 'category',
            categories
        });
    }
}

Demo: https://jsfiddle/BlackLabel/vufgc0x2/

You can also set the categories array explicitly on the x-axis, so that it will work correctly on the drillup regardless of the displayed chart type.

xAxis: {
  type: "category",
  categories: ['Chrome', 'Safari', 'Other']
}

Demo: https://jsfiddle/BlackLabel/mdw7tpxb/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745626098a4636814.html

相关推荐

  • Highcharts drilldown column to pie, axis label issue - Stack Overflow

    I am using Highcharts drilldown feature and change visualization type in each level of drilldown.I hav

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信