Accepted answer

This is just a guess, because I didn't verify it:

Your type function does not return anything. According to the d3 CSV description, the second method of d3.csv() is called the "accessor"-method:

An optional accessor function may be specified, which is then passed to d3.csv.parse

The documentation of csv.parse() says this:

An optional accessor function may be specified as the second argument. This function is invoked for each row in the CSV file, being passed the current row and index as two arguments. The return value of the function replaces the element in the returned array of rows; if the function returns null, the row is stripped from the returned array of rows

So I suppose that because of nothing is returned by type, the element is removed from the list and this is why you have 0 results. If you would return d; it could work.

Again, it's just a guess by looking at the documentation, maybe I'm totally wrong. If this didn't help, I'm sorry.


I am working with D3js version v4. The way of using data parsed by d3.csv looks like

d3.csv("/path/data/mydata.csv", function(data) {
   console.log(data[0]); // print out the first row of the data


I believe this is based off of a tutorial by Curran Kelleher? I was also having trouble with this exercise since there have been a few updates to d3 since he made the tutorial. I got stuck on the last bit of code:

d3.csv("iris.csv", type, render);

in d3 version 5, that will not work. They are now doing


More information can be found at

Related Query

More Query from same tag