2

I'm currently following the tutorial in Scott Murray's D3 book. His code for my specific problem is here: https://github.com/scotthmurray/d3-book/blob/master/chapter_07/09_time_scale.html

I copied his code into my index.html directly (for trouble shooting purposes) but it doesn't appear to be loading in my csv data correctly when I open my local host browser.

I'm trying to read in my "time_scale_data.csv" file which looks like below:

enter image description here

Below is I believe the relevant part of my D3 code but please see my link above for full code: enter image description here

When I check my browser / console ... it looks like only the last row of data in my CSV file was loaded in instead of the whole dataset

enter image description here

According to the book, this is what the data should look like after I add dataset to the console: enter image description here

PineNuts0
  • 4,740
  • 21
  • 67
  • 112
  • Here is your CSV file converted to JSON: https://api.jsonbin.io/b/61cc9e42ea3bf5682139ba17 – Michael Rovinsky Dec 29 '21 at 17:44
  • are you saying try loading again using the json file? – PineNuts0 Dec 29 '21 at 18:07
  • Yes try load as JSON, it should work – Michael Rovinsky Dec 29 '21 at 18:08
  • I'm getting undefined when I print the dataset in the console :( ... I think it has to do with my rowConverter function -- probably not suited for JSON file – PineNuts0 Dec 29 '21 at 18:18
  • 2
    The code from the book was written for D3 **v4** and is not compatible with any version >=v5. You are probably using a version higher than v4 where the third argument to `d3.csv()` is now interpreted as the row conversion function. You might want to have a closer look at the API [docs](https://github.com/d3/d3-fetch#dsv) for more information. The following question may also be helpful: [*"How to load data from a CSV file in D3 v5"*](/q/49599691). – altocumulus Dec 29 '21 at 21:03

0 Answers0