Alan Dunning
Alan Dunning

Reputation: 1351

Remove circle and path on click d3

I am trying to remove a path and it the circles that are placed on it when a text label is clicked.

The line is removed on click but I am having trouble removing the circles too.

The d3 code to remove the path is as follows.

.on("click", function () {
            // Determine if current line is visible 
            var active = d.active ? false : true;
            var newOpacity = active ? 0 : 1; 
            // Hide or show the elements based on the ID
            d3.select("#line" + d.key.replace(/\s+/g, ''))
                .transition().duration(500) 
                .style("opacity", newOpacity); 
            // Update whether or not the elements are active
            d.active = active;
        })  

Please see the Plunker link for a better example for the whole code.

Plunker link

Upvotes: 0

Views: 674

Answers (1)

Kiba
Kiba

Reputation: 10827

Is this what you are looking for, Made some changes and here is where the circles disappear Thanks d3.selectAll(".dot"+d.key.replace(/\s+/,"")).transition().duration(500).style("opacity", newOpacity);

Added Plunker Here plunker

Upvotes: 1

Related Questions