I want to load x csv files and render the data to a line chart. Loading 1 csv file and create a line chart works already fine.
My csv file:
Date,PV,Energy
1355100420,0.000,0.851
1355100480,0.000,0.841
1355100540,0.000,1.000
1355100600,0.000,0.984
1355100660,0.000,1.006
1355100720,0.000,2.769
1355100780,0.000,2.791
My problems: the number of csv files is various and the correct order is important, because the x axis is my time axis and I have the dates/times in the 1st column of my csv.
Read a single csv:
$.get(csv_file, function(data) {
var series = [];
// Split lines
var lines = data.toString().split('\n');
// For each line, split the record into seperate attributes
$.each(lines, function(lineNo, line) {
var items = line.split(',');
// first line contains the series names
if (lineNo === 0) {
for (var i = 1; i < items.length; i++) {
series.push({
name : items[i],
data : [],
dataGrouping : {
enabled : false
}
});
}
} else {
for (var i = 1; i < items.length; i++) {
// get the serie
var serie = series[i - 1];
serie.data.push([parseFloat(items[0] * 1000), parseFloat(items[i])]);
}
}
});
chart = new Highcharts.StockChart({
chart : {
renderTo : container_id,
type : 'line',
reflow : true,
},
xAxis : {
type : 'datetime'
},
series : series
});
});
But how can I read multiple csv files in the correct order?
Thanks a lot!