简体   繁体   English

Highcharts:如何将动态数据设置为向下钻取饼图?

[英]Highcharts: How do I set dynamic data to the drilldown pie chart?

I am able to set data to the main pie chart using 我可以使用将数据设置为主饼图

var data = [1,2,3,4,5]; //value of data will be returned through an AJAX call
chart1.series[0].setData(data);

Similarly, how do I set the drilldown data dynamically? 同样,如何动态设置向下钻取数据?

I tried with 我试过了

chart1.drilldown[0].data = '[1,2,3]';

but it did not work. 但它不起作用。

I am using RESTful services to expose data. 我正在使用RESTful服务来公开数据。

You can access drilldown at runtime using chart.options.drilldown 您可以使用chart.options.drilldown在运行时访问drilldown

var newDrillDowns = {
                id: 'my drilldowns',
                data: [
                    ['Cat1', 4],
                    ['Cat2', 2],
                    ['Cat3', 1]
                ]};

chart.options.drilldown.series[0] = newDrillDowns;

In the same way you can replace drilldowns completely 以同样的方式,您可以完全替换钻取

chart.options.drilldown.series = [newDrillDowns];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM