Skip to main content
100%

Multi-line graph 4: Toggle

✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Jul 5, 2014

This multi-line chart displays monthly stock prices for Microsoft, Amazon, and IBM from 2000 to 2010, sourced from a CSV file. The graph automatically generates a color-coded legend, and clicking a legend label toggles the corresponding line’s opacity via a smooth CSS transition. Built with the D3.js library, it uses `d3.time.scale` for the time axis, `d3.svg.line` for plotting, and `d3.nest()` to group data by company symbol, with linear scaling for the price axis.

AI-generated description

This is a derivative of the simple d3.js graph used as an example in the book D3 Tips and Tricks. 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.

mit Licensed

Similar vizzes