block by d3noob 5d621a60e2d1d02086bf

Show / hide elements on mouse click with d3.js

Full Screen

This is a relativly straight forward graph with two lines. Each line and it’s corresponding Y axis can be toggled on and off by clicking on the text labels at the bottom of the graph.

This example is based on the explanation given by ‘mdml’ in response to a Stack Overflow question on showing and hiding links and nodes.

It is used as an example of showing and hiding an element in d3.js using a separate element and described in the book D3 Tips and Tricks which can be downloaded for free from Leanpub.

index.html