javascript - D3je: how to select all data points with specific value of particular data field -


i have d3js heatmap graph made using code , reacting on click event:

  var heatmap = svg.selectall(".hour")     .data(availplain)     // abriged...      .on("click", function (d, i) {         // toggle special class clicked item         d3.select(this).classed("selectedclass",             d3.select(this).classed("selectedclass") ? false : true);         var isshown=d3.select(this).classed("selectedclass");                   }); 

the looks of parameter d passed in on-click handler such:

 {"g":"16","station":"91","rid":"360"}  

which element of availplain array or objects used make graph. want iterate on d3 elements have same "g" value , toggle class them well. quite sure follow-up of select/selectall shall used difficult comprehend actual code using documentaion (https://github.com/mbostock/d3/wiki/selections). so, how "classed" items have data condition "data.g==something"?

fugured out:

.on("click", function (d, i) {         heatmap.filter(function(dta){return (dta.g==d.g);})         .classed("selectedclass",              d3.select(this).classed("selectedclass") ? false : true);      }); 

note "this" in .classed , and in event handler function mean different objects.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -