CSommer
Posts: 56
Joined: Mon Jun 27, 2016 12:27 am

Uncaught Type error on Time

Thu Sep 14, 2023 7:15 am

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

jakub.j
Posts: 857
Joined: Tue Jan 24, 2023 11:14 am

Re: Uncaught Type error on Time

Fri Sep 15, 2023 1:06 pm

We appreciate you reaching out to us!

When providing a different data source, this error is not there. Could you reproduce it in this demo in a way that you get this error?

Demo: https://jsfiddle.net/BlackLabel/mzpk8e5j/

Best regards
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Usage”