最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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/

发布评论

评论列表(0)

  1. 暂无评论