Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Histogram Bins with html range slider
    primarykey
    data
    text
    <p>I'm trying to modify the bins of an histogram layout through an html slider, with no success.<br> The code I tried running for the slider is:</p> <pre><code>&lt;div id = "range"&gt; &lt;input type="range" min="1" max="50" step="1" value="25"&gt; &lt;/div&gt; </code></pre> <p>Then I set the <code>bins</code> of the histogram to <code>var bin</code>.<br> The js code to update the bins with the value of the range slider:</p> <pre><code>d3.select("#range") .select("input") .on("change", function () { this.value == bin; //The two histogram variables, line and path generators histogSans = d3 .layout.histogram() .bins(bin) .value(function (d) { return d.Peso; }) (FontSans); histogSerif = d3 .layout.histogram() .bins(bin) .value(function (d) { return d.Peso; }) (FontSans); line = d3.svg.line() .x(function (d) { return x(d.x); }) .y(function (d) { return y(d.y); }); SansPath = svg .transition() .duration(1500) .attr("d", line(histogSans)); }); </code></pre> <p>where <code>histogSans</code> &amp; <code>histogSerif</code> are the generators of the histogram values, <code>line</code> is the line generator and <code>SansPath</code> &amp; <code>SerifPath</code> are the path generators that follow the histogram values.</p> <p><br><br> <strong>EDIT:</strong> thanks to cuckovic I am now able to get the right value out of the slider, with <code>bin = this.value;</code>, but the console log of the histogram now returns a wrong array, containing just an array of all the values in the dataset, so the values are not plotted correctly! anyone knows why this happens? Full code here: <a href="http://dl.dropboxusercontent.com/u/37967455/confronto_pesi.html" rel="nofollow">http://dl.dropboxusercontent.com/u/37967455/confronto_pesi.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload