我们如何使用d3js从.csv文件中选择特定的行

时间:2016-05-15 17:01:30

标签: d3.js nvd3.js

输入文件

perf_month,Jan-15,Feb-15,Mar-15,Apr-15,May-15,Jun-15,Jul-15,Aug-15,Sep-15,Oct-15,Nov-15,Dec-15,Jan-16,Feb-16,Mar-16
open_acc,5843,7126,7682,5517,6965,7519,2579,2572,8108,356,8950,718,1214,6523,8068<br>
exter_sales,6345,3933,9529,1457,7920,8608,3910,971,6070,5859,7899,5342,3466,2005,4357<br>
payment,1179,8452,8040,2082,8351,1494,1877,2772,5985,477,7153,1857,1572,5698,1436<br>

输出表单

{{1}}

之后我想使用d3js从这些行创建表

1 个答案:

答案 0 :(得分:-1)

要使用数据,只需使用d3.csv

例如:

d3.csv("csvPath.csv",function(data){
//use the data variable above as you csv for example

data.forEach(function(d){
console.log(d)// this will log each line of data, so the first one would be
//d.perf_month = "open_acc" and so on
})

})

至于使用它来填充表格,有很多例子: