scotthmurray / d3-book

Code examples for “Interactive Data Visualization for the Web”
http://d3book.com
Other
2.4k stars 1.79k forks source link

Chapter 5 HANDLING DATA-LOADING ERRORS #46

Open zlw8844 opened 3 years ago

zlw8844 commented 3 years ago

Regarding global variable dataset, I found I had to define var dataset = [], and use dataset.push(data). If I did the same as the book, the dataset can only have the last element in the imported csv file.

scotthmurray commented 3 years ago

@zlw8844 Thanks! Which specific example are you referring to? It would be helpful to have the filename (like chapter_01/00_example.html) as well as the book page number that refers to it.

zlw8844 commented 3 years ago

@zlw8844 Thanks! Which specific example are you referring to? It would be helpful to have the filename (like chapter_01/00_example.html) as well as the book page number that refers to it.

I am reading the online version, and there is no page number. It is in chapter 5, section 'HANDLING DATA-LOADING ERRORS'. A snapshot of the code is as follows. I need to use an array for dataset, and push new data into it in order to save all input data into dataset. I guess it was caused by the version of D3 used? image

scotthmurray commented 3 years ago

Thanks. Where are you finding the online version? Please share a URL.

I suspect you may be referencing an older version of the text.

zlw8844 commented 3 years ago

I read the 2nd edition through O'reilly. The link is as follows: https://learning.oreilly.com/library/view/interactive-data-visualization/9781491921296/ Regards, Lingwei "Eric" Zhan

On Thu, Sep 3, 2020 at 4:22 PM Scott Murray notifications@github.com wrote:

Thanks. Where are you finding the online version? Please share a URL.

I suspect you may be referencing an older version of the text.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scotthmurray/d3-book/issues/46#issuecomment-686735053, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEW5R6VKBSIQD3RU24JNVT3SD73KDANCNFSM4QSAWF7A .

scotthmurray commented 3 years ago

Ah thanks.

Yes, that was my silly example. You don't have to push data into the array the way I did, but you do have to use an array.

Which version of D3 are you using with the example code? (The examples are only guaranteed with work with D3 v4.5.0, as included in this repo. If you are using v5.0 or newer, then yes, the way the CSV method works has changed, so that probably is breaking here.)

CWMo commented 2 years ago

I look forward to seeing the updates on your new book.