Question

First of all: I'm new to d3.js!

I have a map and some points displayed on it. Now I want to add buttons to show/hide the points. What I have until now:

function checkAll(){
    d3.selectAll("g").attr("visibility", "visible");
}
function uncheckAll(){
    d3.selectAll("g").attr("visibility", "hidden");
}

This works so far but hides/shows the whole map.

I have a function "drawpoints()" that draws the points on the map. How can I change my code that it only shows/hides the points and not the whole map?

Était-ce utile?

La solution

You would need to select only the elements that you want to hide. If, for example, they are identified by a class, you would do the following:

d3.selectAll(".classOfCircles").attr("visibility", "hidden");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top