mardi 5 juillet 2016

Highcharts - using addSeriesAsDrilldown dynamically not working


the following code is not working, what am I doing wrong? Loading the json_data into "options.drilldown" works but using addSeriesAsDrilldown does not work. Any help is appreciated. function getData(name) { var result = null; var scriptUrl = "data.php?name=" + name; $.ajax({ url: scriptUrl, type: 'get', dataType: 'json', async: false, success: function(data) { result = data.drilldown; } }); return result; } var options = { chart: { renderTo: 'high', type: 'column', events: { drilldown: function (e) { if (!e.seriesOptions) { data = getData(e.point.name); var chart = this; chart.addSeriesAsDrilldown(e.point, data); console.log(data); } } } }, plotOptions: { series: { borderWidth: 0, dataLabels: { enabled: true } } }, legend: { enabled: true }, xAxis: { categories: [] }, series: [{}], drilldown: {} }; $.getJSON('data.php', function(data) { options.series = data.series; //options.drilldown = data.drilldown; console.log(data.drilldown); var chart = new Highcharts.Chart(options); }); Below is the used data, which comes from data.php: { "series": [ { "id": "toplevel", "name": "Tage", "data": [ { "name": "2016-06-08", "y": 9, "drilldown": "2016-06-08", "title": "2016-06-08" } ] } ], "drilldown": { "series": [ { "id": "2016-06-08", "name": "Tarife", "data": [ { "name": "test (obscured)", "y": 4, "title": "test (obscured)" }, { "name": "test (obscured)", "y": 5, "title": "test (obscured)" } ] } ] } }

Aucun commentaire:

Enregistrer un commentaire