Skip to main content
100%

Multi-line graph 4 with v7: Toggle

✓ Published0🌍 Public
Dd3noob
Last edited Jun 19, 2021
Created on Jun 19, 2021

This interactive multi-line chart displays monthly stock prices for three companies (MSFT, AMZN, IBM) from January 2000 to March 2010. Users can click legend labels to toggle individual lines on and off, with a smooth opacity transition revealing or hiding each series. The visualization uses d3.csv to load data, d3.group to organize by symbol, d3.scaleOrdinal with d3.schemeCategory10 for colors, d3.line for paths, and d3.axisBottom/axisLeft for axes. Clicking triggers d3.select and transition().duration(100) to animate opacity changes.

AI-generated description

This is used as an example in the book D3 Tips and Tricks v7. 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