Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter by attribute with D3

Tags:

d3.js

I couldn't find an answer to a (hopefully) very easy question. I use filtering like in this chord diagram example http://bl.ocks.org/mbostock/4062006:

.filter(function(d) { return d.source.index != i && d.target.index != i; })

What I need now is to filter only those connections with, let's say, an orange fill. Is there something like

.filter(style('fill') == 'orange')

that works? Any advice highly appreciated.

like image 878
Steevie Avatar asked Jul 24 '14 16:07

Steevie


1 Answers

To search everything with fill = orange, you can do:

svg.selectAll('path[style = "fill: orange;"]')

If you want to limit the search to a particular element type, for example "rect", you can do:

svg.selectAll('rect[style = "fill: orange;"]')
like image 130
Selman Tunc Yilmaz Avatar answered Oct 24 '22 22:10

Selman Tunc Yilmaz