Multi-line graph 2 with v5: Colours
This example displays monthly stock prices for Microsoft, Amazon, and IBM as a multi-line graph, with each line assigned a distinct color from the d3.schemeCategory10 scale. The code uses d3.csv to load the data, d3.nest to group entries by symbol, and d3.line with d3.scaleTime and d3.scaleLinear to render the paths. The SVG canvas is built with D3 v5, and axes are added via d3.axisBottom and d3.axisLeft. It is the second in a series demonstrating multi-line graph techniques.
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 v5. The stock data was sourced from Mike Bostock's small multiples example.
It is the second 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 application of unique colours to the graph lines.
The graph should be taken in context with the text of the book which can be downloaded for free from Leanpub.