使用d3js从两个csv文件导入数据 [英] Importing data from two csv files using d3js

查看:191
本文介绍了使用d3js从两个csv文件导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑使用此小提示链接 FIDDLE 。在这个例子中,我想使用一个csv文件在第33- [data.csv]行和第158行 - [data1.csv]行的数据加载数据。我想使用两个单独的csv文件。我尝试使用csv文件在第33行使用此代码

consider this fiddle link FIDDLE. In this example I would like to use a csv file to load data at line no.33-[data.csv] and data at line no.158-[data1.csv]. I want to use two separate csv files. I tried using a csv file for data at line no.33 with this code

 d3.csv("data.csv", function(csvData) {

csvData.forEach(function (d,i) {
    data[i] = {
      first: +d.first, 
      second: +d.second
    } 
});
console.log(data);

我能够得到一个输出,但是图表已经移动到彼此远离有以下错误:意外值NaN解析cy属性。如何加载两个数据集有效的方式使用两个单独的csv文件?

I was able to get an output but the charts had moved far away from each other with the following errors : Unexpected value NaN parsing cy attribute. How to load the two datasets in an efficient way using two separate csv files ?

推荐答案

这是希望最终的 plunker 在这个不断增长的项目:)(很多csv工作在这里已经指导了伟大的Lars ...像往常一样,许多的赞美他。)

Here is hopefully the final plunker in this ever-growing project :) (A lot of the csv work here has been guided by the great Lars...as usual, many kudos to him.)

更新plunker 的数据顶部图来自datam.csv。

Updated plunker with data on top chart coming from datam.csv.

这篇关于使用d3js从两个csv文件导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆