score:5

Accepted answer

you're asking to select based on the value of the style attribute. the fill property is nested within the style attribute; it is not a direct attribute of the dom node. so you won't be able to select it using an attribute selector (ie the method @larskotthoff linked to).

you can switch to setting the fill using the svg fill attributes, .attr('fill', ...) instead of using style('fill'), which will allow you to later select it using an attribute selector.

that aside, selecting via the fill attribute doesn't seem too elegant. if your design evolves and you start using a different fill color, you'll have to change the attribute selector as well. assigning it a class and selecting based on the class is more appropriate.

perhaps the best is to select based on data. eg:

g.selectall('circle')
  .filter(function(d) { return d.artistid == 1; })
  .style('fill', function(d, i) {
    // here you can affect just the red circles (bc their artistid is 1)
  })

Related Query

More Query from same tag