用两个变量过滤D3中的.csv

时间:2017-07-11 09:47:26

标签: javascript d3.js

我有一个形状如下的CSV。我想过滤CSV中的数据,以便我只获取一个国家和特定帮助组的头发颜色和值。

Help,Hair Colour,Europe,Africa,North America
1Male,Brown Hair,1,13,14
1Male,Blonde Hair,3,20,24
1Male,Ginger Hair,50,30,30
1Male,Grey Hair,70,40,40
1Male,Black Hair,100,100,100
1Female,Brown Hair,66,22,14
1Female,Blonde Hair,70,45,23
1Female,Ginger Hair,80,46,25
1Female,Grey Hair,90,70,30
1Female,Black Hair,100,100,100

例如,我想要定义我在北美只想要1Female:

Hair Colour,North America
Brown Hair,14
Blonde Hair,23
Ginger Hair,25
Grey Hair,30
Black Hair,100

然后我想将这些头发颜色存储为自己的变量,因为我将从1-100生成一个随机数,并根据该值是否大于或等于随机数来指定头发颜色

我一直在阅读带有D3的.csv并知道有一个过滤器选项,但我不知道如何过滤两个变量。

0 个答案:

没有答案