I am building a simple feedback system for a study. I have just started to learn JS and D3.js, but decided to build some very simple plot in D3.js. However, I get the following error message and I don't understand how I can fix it?
(index):36 Uncaught (in promise) TypeError: data.forEach is not a function
What I want to do with this script is to take a single line in a .csv and put the number on the screen. This my code
const inter = setInterval(function() {
updateData();
}, 5000);
// ** PLOG
function updateData() {
// Get the data again
d3.csv("lagplot.csv", function(error, data) {
data.forEach(function(d) {
d.finish = +d.FINISH;
d.bib = +d.BIB;
});
// PLOT TEXT
d3.select("text")
.data(data)
.enter()
.append("text")
.attr("fill", "teal")
.text(function(d) { return d.finish; })
});
}
And this how the csv file looks
Unnamed: 0 RANK STA RUN BIB NAME INTER 1 INTER 1.1 INTER 1.2 INTER 2 INTER 2.1 INTER 2.2 FINISH FINISH.1 FINISH.2 COURSE
33 33 34 9 4 2 OFTEBRO Einar 4.85 3.72 33 10.145.29 +8.10+4.38 3232.0 14.053 +11.28+3.18 32.0 LØYPE 3
errorparameter contain anything? Becausedataseems to either benullor something other than an array.