Note that there are some explanatory texts on larger screens.

plurals
  1. POd3 map with checkbox filtering
    primarykey
    data
    text
    <p>I have a made a d3 symbolic map and would like the user to be able to filter points by an attribute called 'type'. There are three types: a, b, c, each of which has an associated html checkbox, that when checked should display points of type a, and when un-checked should remove those points. I was wondering what the best way to pass the check/uncheck event into d3? I am thinking if there was a way to pass the checked types into a select.filter(), that would be the best way to go. Here is the code:</p> <p>HTML</p> <pre><code>&lt;div class="filter_options"&gt; &lt;input class="filter_button" id="a_button" type="checkbox"&gt;a&lt;/input&gt;&lt;br&gt; &lt;input class="filter_button" id="b_button" type="checkbox"&gt;b&lt;/input&gt;&lt;br&gt; &lt;input class="filter_button" id="c_button" type="checkbox"&gt;c&lt;/input&gt;&lt;br&gt; &lt;/div&gt; </code></pre> <p>js</p> <pre><code>queue() .defer(d3.json, "basemap.json") .defer(d3.json, "points.json") .await(ready); function ready(error, base, points) { var button = svg.append("path") .attr("class", "polys") .datum(topojson.object(us, base.objects.polys)) .attr("d", path); svg.selectAll(".symbol") .data(points.features) .enter().append("path") .filter(function(d) { return d.properties.type != null ? this : null; }) .attr("class", "symbol") .attr("d", path.pointRadius(function(d) { return radius(d.properties.frequency * 50000); })) .style("fill", function(d) { return color(d.properties.type); });; </code></pre> <p>Currently, the filter is set to catch all points:</p> <pre><code>.filter(function(d) { return d.properties.type != null ? this : null; }) </code></pre> <p>I would like the user to be able to change this.</p> <p>Cheers</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.
 

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