Hi All,
I am getting a Uncaught TypeError: Cannot read properties of undefined (reading 'time') in my script
I have put a few console.logs in my script so I can see the data is being picked up and converted.
I also have a jquery reference in my header.
My csv data format is:
1686189540000,26.223,Cu,Tiger
1686189540000,27.029,Fe,Tiger
1686189540000,29.733,S,Tiger
1686149788000,26.359,Cu,Tiger
1686149788000,26.969,Fe,Tiger
1686149788000,29.851,S,Tiger
My script is:
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Spline Chart with CSV Data'
},
xAxis: {
type: 'datetime', catagories: true, ordinal: false,
minTickInterval: 100000, labels: { align: 'center'},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'Value'
}
},
series: []
});
// Get the CSV data from the URL
$.get('mydatasource.csv', function(data) {
// Split the CSV rows
var rows = data.split('\n');
// Iterate through the rows and parse the data
for (var i = 1; i < rows.length; i++) {
var columns = rows.split(',');
var timestamp = parseFloat(columns[0]);
console.log(timestamp);
var date = new Date(timestamp);
console.log(date);
var newdate = date.toISOString();
console.log(newdate);
var value = parseFloat(columns[1]);
var category = columns[2];
// Find or create the series based on the category
var series = Highcharts.chart('container').series.find(s => s.name === category);
if (!series) {
series = Highcharts.chart('container').addSeries({
name: category,
data: []
});
}
// Add the data point to the series
series.addPoint({
x: newdate,
y: value
})
}
});
any suggestions
Regards
Csommer