Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3 change attribute of all elements

I want to change the color of all my svg elements with class "tmp-click" to yellow

var yellow = d3.select('svg')
               .selectAll('.tmp-click')
               .attr("fill","yellow);

When executing the code only one of the elements is changed, what did I miss?

like image 923
Anh Tuan Nguyen Avatar asked Sep 14 '25 05:09

Anh Tuan Nguyen


1 Answers

Do it this way

var yellow = d3.selectAll('.tmp-click')
               .style("fill","yellow");
like image 94
Cyril Cherian Avatar answered Sep 16 '25 18:09

Cyril Cherian