Reputation: 690
I need a help about highchart
i want to set series drilldown data from array
this is the code if using manual
series: [{
name: 'Things',
colorByPoint: true,
data: [{
name: 'Animals',
y: 5,
drilldown: 'animals'
}, {
name: 'Fruits',
y: 2,
drilldown: 'fruits'
}, {
name: 'Cars',
y: 4
drilldown: 'cars'
}]
}],
but i want to set the data for this series from array
this is my array:
var name = new Array('Animals', 'Fruits', 'Cars');
var y = new Array(5, 2, 4);
var drill = new Array('animals', 'fruits', 'cars');
this is the series using variable that set from array
series: [{
name: 'Things',
colorByPoint: true,
data: data_drilldown //data_drilldown is a variable set from array
}],
i have try many way to set value insert data_drilldown
but have failed
can someone help me? how to set the value insert data_drilldown
from array name, y, and drill
with looping (for or any) so the output is same as manual one
thank you very much
Upvotes: 0
Views: 273
Reputation: 45079
Simple use for
, that way:
var data_drilldown = [];
for(var i = 0; i < name.length; i++) {
data_drilldown.push({
name: name[i],
y: y[i],
drilldown: drill[i];
});
}
Note: all arrays need to be the same length.
Upvotes: 1