Multi-line graph 3 with v7: Legend
This multi-line graph shows monthly stock price changes for Microsoft, Amazon, and IBM from 2000 to 2010, with a categorical legend labeling each company’s colored line. Using d3.v7, the code parses dates with `d3.timeParse`, groups the CSV data by symbol via `d3.group`, and applies a `d3.scaleOrdinal` color scheme. Each path is drawn with `d3.line` and `d3.scaleTime` and `d3.scaleLinear` axes, while legend text is positioned evenly along the bottom using computed spacing.
AI-generated descriptionThis 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 third 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 addition of a legend to the graph.
The graph should be taken in context with the text of the book which can be downloaded for free from Leanpub.