Is it possible to load csv data to nvd3 library?

前端 未结 3 417
野趣味
野趣味 2021-01-14 08:38

I\'m new on nvd3 after testing the D3js the last week. I\'d like to load data from .csv file with nvd3, that I did on D3 but I\'m not able to do it with nvd

3条回答
  •  长情又很酷
    2021-01-14 09:01

    Finally I got the error on my code. The examples from NVD3.js load the v2 file from D3.js. When we use the 2.x versions from D3 we've to load external data with the next code:

    d3.csv("weather.csv", function(data) {
        data.forEach(function(d) {
            d.date = parseDate(d.Hour);
            d.T = +d.T;
        })
    });
    

    After v3 update, this thing changed and appears the error argument, and insinde the .csv function we can control the error case.

    d3.csv("weather.csv", function(error, data) {
        data.forEach(function(d) {
            d.date = parseDate(d.Hour);
            d.T = +d.T;
        });
    });
    

    Here you can see this changes explained by Mike Bostock, the creator of D3.js

提交回复
热议问题