javascript - Using on click & selectAll to remove existing data -
i have set of randomly plotted diamonds, squares & circles on canvas. have 1 of each lined in straight line created go variable. wish use onclick function upon variable filter or make shapes disappear depending on parameter give it. e.g. squares show squares on canvas etc.
so far have started basic example:
.on("click", function(d){ if (d.shape == 'square') { return alert('success') ;} })
i moved onto this:
.on("click", function(d){ if (d.shape =='circle') { return d3.selectall(".node").filter(function(d) {return d.country === 'usa'} ) } ;})
when have applied that, doesnt result errors or actions. i'm pretty sure i'm going in right direction, getting there
thanks, in advance!
you doing nothing selection. if need hide add .style("display", "none")
.on("click", function(d){ if (d.shape =='circle') { d3.selectall(".node") .filter(function(d) {return d.country === 'usa'} ) .style("display", "none"); } })
Comments
Post a Comment