Focusing in this question: php-json-highcharts-load-database-result
The answer was to do the follow each
:
$.getJSON('ajax/calc.ajax.php', function(data) {
var series = { // <-------------------- create just one series object
type: 'pie',
data: [] //data array for new series
};
$.each(data, function(key, value) {
series.data.push([key, value[0]]);
});
options.series.push(series); // <-------- pushing series object
var chart = new Highcharts.Chart(options);
});
This works using pie charts, and if I change to another type (line
for example), the same $.each
will do the work except showing more then one series. I've already tryied putting the series inside the each, but without success.
How can I make this work? In the highchart docs, if the series came with name
, the name will appear as series. like this:
{
type: 'bar',
name: 'Apple' // showing only once
data: []
};