All examples By author By category About

d3noob

Show / hide elements on mouse click with d3.js

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.