Importing data from multiple csv files in D3

后端 未结 4 553
旧时难觅i
旧时难觅i 2020-11-28 11:11

I am brand new to D3 and just started working on an a project. My question is this. I want to import data from 2 csv files in D3 to use them for graph comparisons. The probl

4条回答
  •  星月不相逢
    2020-11-28 11:42

    In d3 version 5, you can use Promise.all to load multiple csv files. Example:

    Promise.all([
        d3.csv("file1.csv"),
        d3.csv("file2.csv"),
    ]).then(function(files) {
        // files[0] will contain file1.csv
        // files[1] will contain file2.csv
    }).catch(function(err) {
        // handle error here
    })
    

    More info about loading csv in d3 v5

    More info about Promise.all()

提交回复
热议问题