Hi All,
I have generated a script, but it is not creating the individual series by using column 3 of my csvURL.
My script is:
Highcharts.stockChart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Stock Chart with CSV Data Source'
},
xAxis: {
type: 'datetime'
},
series: [],
data: {
csvURL: 'https://mydata.csv',
parseCSV: function (data) {
var lines = data.split('\n'),
series = [],
dateTimeFormat = /(\d{13})/;;
// Iterate over the lines of the CSV data
for (var i = 0; i < lines.length; i++) {
var line = lines.split(','),
dateTime = parseInt(line[0]),
value = parseFloat(line[1]),
seriesName = line[2],
marker = line[3];
// Find or create the series based on the seriesName
var series = seriesData.find(function (s) {
return s.name === seriesName;
});
if (!series) {
series = {
name: seriesName,
data: [],
marker: {
enabled: marker === 'true'
}
};
seriesData.push(series);
}
// Add the point to the series
series.data.push([dateTime, value]);
}
// Set the parsed series data to the chart
this.update({
series: seriesData
});
}
}
});
my data format is :
1487716365000,26,Oranges,main
1487716365000,27,Apples,main
1487716365000,29,Bananas,main
1487716365000,26,Oranges,secondary
1487716365000,27,Apples,secondary
1487716365000,29,Bananas,secondary
column 1 is the date time, coulumn 2 is the value, column3 is the series, coulmn 4 would apply a marker based on this variable
currently the script above is generating only one series with all the data
This should generate 3 series Oranges, Apples, Bananas