简体   繁体   English

使用d3js从两个csv文件导入数据

[英]Importing data from two csv files using d3js

consider this fiddle link FIDDLE . 考虑这个小提琴链接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]. 在此示例中,我想使用一个csv文件在第33- [data.csv]行和第158- [data1.csv]行加载数据。 I want to use two separate csv files. 我想使用两个单独的csv文件。 I tried using a csv file for data at line no.33 with this code 我尝试使用此代码在第33行使用csv文件作为数据

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

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

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. 我能够得到输出,但图表彼此之间相距较远,并出现以下错误:异常值NaN解析cy属性。 How to load the two datasets in an efficient way using two separate csv files ? 如何使用两个单独的csv文件高效地加载两个数据集?

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.) 希望这是这个不断发展的项目中的最后一个笨拙的人:)(这里的很多csv工作都是由伟大的Lars指导的……像往常一样,对他很敬重。)

Updated plunker with data on top chart coming from datam.csv. 更新了带有来自datam.csv顶部图表的数据的插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM