简体   繁体   中英

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.

You can access drilldown at runtime using chart.options.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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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