Show/Hide Elements
Learn how to toggle the visibility of elements by clicking on your graph.
We'll cover the following...
Show/Hide an element by clicking on another element
This is a trick that I found I wanted to implement in order to present a graph with a range of lines and then provide the reader with the facility to click on the associated legend to toggle the visibility of the lines off and on as required.
The example we’ll follow is our friend from earlier; a slightly modified example of the graph with two lines.
In this example, we will be able to click on either of the two titles at the bottom of the graph (“Blue Line” or “Red Line”) and have it toggle the respective line and y-axis. ...