d3.js - D3. Histogram Layout. How do I recalculate the histogram on the fly? -


i have histogram created datasource.

this.histogramdatasource = d3.layout.histogram()     .value (function(d) { return d.score; })     .bins(binthresholds) (self.datasource); 

that render thusly

histogramrects = histogramgroup.selectall('.svg_container rect')     .data(histogram.histogramdatasource)     .enter().append("rect")     .attr({         x:      function(d) { return histogram.x(d);       },         width:  function(d) { return histogram.width(d);   },         y:      function(d) { return histogram.y(d);       },         height: function(d) { return histogram.height(d);  }     })     .attr("fill",  function(d) { return scarpa.connectivityscorehistogram.fillcolor(); }); 

based on user input want filter input datasource, recalculate histogram , re-render. thought this:

this.histogramdatasource(filtered_data_source); 

but generates errors. have missed here?

i think need keep reference original histogram builder:

this.histogramlayout = d3.layout.histogram()     .value (function(d) { return d.score; })     .bins(binthresholds);  this.histogramdatasource = this.histogramlayout(self.datasource); 

then

this.histogramdatasource = this.histogramlayout(filtered_data_source); 

however, keep in mind recalculating entire histogram scratch might bit slow larger data sets. if want interactive filtering might want @ crossfilter.


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -