I am facing an issue while trying to populate my highchart with data using a fetch function. The data is not being displayed or set in the chart element.
Below is the fetch function I am using:
fetch("data.csv")
.then(response => response.text())
.then((response) => {
//console.log("d"+response)
function csvToArray(str, delimiter = ",") {
let array = str.split("\n").map(function (line) {
return line.split(delimiter);
});
return array;
}
let array = csvToArray(response);
array.splice(0, 1);
array.splice((array.length-1),1)
let string =JSON.stringify(array);
let stringnew = string.replaceAll("\"","");
//console.log(csvToArray(response));
//console.log(csvToArray(response)[0]);
console.log(stringnew);
chart.series[0].setData(stringnew);
})
.catch(err => console.log(err))
Additionally, here is the content of my data.csv file:
time,data
1672683118394,12.00
1672683159084,10.00
1672683199305,9.00
Although I can see the correct output in the console:
[[1672683118394,12.00],[1672683159084,10.00],[1672683199305,9.00]]
It seems to follow the Highcharts documentation as far as I can tell. However, the data is still not loading on the chart. Any assistance would be greatly appreciated :)