Skip to main content
100%

Multi-line graph 1 with v7: Lines

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

This multi-line graph displays monthly stock prices for Microsoft, Amazon, and IBM from 2000 to 2010, with each company represented by a separate line. The visualization uses D3 v7’s `d3.group` function to nest data by symbol, then draws each line using the `d3.line` path generator. Data is loaded from a CSV file via `d3.csv`, with dates parsed using `d3.timeParse` and scales set with `d3.scaleTime` and `d3.scaleLinear`. Axes are rendered as SVG elements using `d3.axisBottom` and `d3.axisLeft`.

AI-generated description

This is 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 first 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 use of the d3.group function to group the data to allow the different lines to be drawn.

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