可以使用d3.js过滤数据,只显示数据中的特定项目吗?
例如,如果我有如下数据集:
timestamp,location,price,FirstName,LastName
1/6/2014 7:28,Brew've Been Served,11.34,Edvard,Vann
1/6/2014 7:34,Hallowed Grounds,52.22,Hideki,Cocinaro
1/6/2014 7:35,Brew've Been Served,8.33,Stenig,Fusil
1/6/2014 7:36,Hallowed Grounds,16.72,Birgitta,Frente
1/6/2014 7:37,Brew've Been Served,4.24,Sven,Flecha
1/6/2014 7:38,Brew've Been Served,4.17,Cornelia,Lais
1/6/2014 7:42,Coffee Cameleon,28.73,Linnea,Bergen
1/6/2014 7:43,Brew've Been Served,9.6,Mat,Bramar
1/6/2014 7:43,Brew've Been Served,16.9,Brand,Tempestad
1/6/2014 7:47,Hallowed Grounds,16.53,Emile,Arpa
1/6/2014 7:48,Hallowed Grounds,10.66,Kare,Orilla
1/6/2014 7:49,Coffee Cameleon,8.39,Bertrand,Ovan
1/6/2014 7:52,Brew've Been Served,32.83,Hennie,Osvaldo
1/6/2014 7:54,Hallowed Grounds,16.88,Nils,Calixto
1/6/2014 7:54,Coffee Cameleon,11.86,Adra,Nubarron
1/6/2014 7:54,Hallowed Grounds,32.93,Rachel,Pantanal
1/6/2014 7:55,Hallowed Grounds,8.05,Lucas,Alcazar
1/6/2014 7:55,Brew've Been Served,3.67,Varja,Lagos
1/6/2014 7:59,Brew've Been Served,8.88,Inga,Ferro
1/6/2014 8:00,Brew've Been Served,4.27,Ruscella,Mies Haber
1/6/2014 8:00,Hallowed Grounds,9.69,Anda,Ribera
1/6/2014 8:01,Hallowed Grounds,10.07,Lidelse,Dedos
1/6/2014 8:06,Brew've Been Served,18.24,Loreto,Bodrogi
1/6/2014 8:06,Brew've Been Served,15.58,Minke,Mies
1/6/2014 8:07,Brew've Been Served,5.66,Felix,Resumir
1/6/2014 8:14,Coffee Cameleon,3.2,Carla,Forluniau
1/6/2014 8:16,Brew've Been Served,14.97,Kanon,Herrero
我可以绘制一个Scatter图表来仅渲染FirstName' Edward'?
的圆圈我知道如何为数据创建散点图,但不知道如何过滤它或是否可以完成?
答案 0 :(得分:2)
只需将.filter(function(d){return d.name.substring(0,6) === 'Edward'})
添加到数据阵列