Multi-line graph 4 with v6: Toggle
A multi-line graph displays monthly stock prices for Microsoft, Amazon, and IBM. D3.js v6 is used to parse CSV data, scale the time and price domains, and render the SVG lines with distinct colors. Clicking a legend label toggles the corresponding line’s opacity via a transition, hiding or showing that company’s data. The example uses `d3.csv`, `d3.timeParse`, `d3.line`, and `d3.scaleOrdinal`.
AI-generated descriptionThis is used as an example in the book D3 Tips and Tricks v6. The stock data was sourced from Mike Bostock's small multiples example.
It is the fourth graph in a series that is building a multi-line graph that incorperates an automatically developed legend and a system that can toggle the lines off and on as desired.
This version is demonstrating the ability to toggle the lines off and on by clicking on the appropriate legend text.
The graph should be taken in context with the text of the book which can be downloaded for free from Leanpub.