67cherries
67cherries

Reputation: 6951

D3 chart example "TypeError: data is undefined"

I am working with the D3 chart example here: http://bl.ocks.org/mbostock/3883245. Everything is working as planned, but I am getting TypeError: data is undefined on the second line of the following code:

d3.tsv(tsvDataURL, function(error, data) {
               data.forEach(function(d) {
                            d.time = parseDate(d.time);
                            d["temperature [C]"] = +d.["temperature [C]"];
                            });

The question here deals with an almost identical issue as this one, but it did not seem to solve the problem for me. I know that tsvDataURL is correct, and I can open up the tsv from my browser. How can I fix this error?

Upvotes: 1

Views: 1810

Answers (1)

Mads Skjern
Mads Skjern

Reputation: 5890

I had the same problem. I had copy pasted both the code and the data to my laptop. But when copy pasting the data file, you don't get a proper .tsv file, since the website is rendered with spaces instead of tabs.

Instead download the tsv file from: http://bl.ocks.org/mbostock/raw/3883245/data.tsv.

Upvotes: 1

Related Questions