Karthik VU
Karthik VU

Reputation: 561

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.

Upvotes: 5

Views: 4319

Answers (1)

Igor Popov
Igor Popov

Reputation: 2144

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];

Upvotes: 12

Related Questions