I need to create multiple series for a highcharts based on a array variable. IF the array has 5 elements then create 5 series, if the array has 4 elements then create 4 series and so on. How do i do this? I'm using JQuery to create the charts and using Ajax, i send and recieve JSON data from my Java class.
Only what you need is use loop which push element of array to series object.
var array = [10,20,30,40,50]
var series = [],
len = array.length,
i = 0;
for(i;i<len;i++){
series.push({
name: 'serie'+i,
data:[array[i]]
});
}
Example: http://jsfiddle.net/Dxr6d/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With