Multi-line graph 1 with v4: Lines
This example shows a multi-line graph comparing the monthly stock prices of Microsoft, Amazon, and IBM from 2000 to 2010. It uses D3 v4 with SVG rendering, parsing dates with `d3.timeParse` and nesting the CSV data by symbol via `d3.nest` to draw a separate line for each company. The lines are styled with a steel blue stroke, and both axes are generated using `d3.axisBottom` and `d3.axisLeft`. The data originates from a CSV file, and the code demonstrates grouping data to create multiple line series.
AI-generated descriptionThis is a derivative of the simple d3.js graph in v4 used as an example in the book D3 Tips and Tricks v4. 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.nest 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.