Skip to main content
100%

Multi-line graph 2 with v6: Colours

✓ Published0🌍 Public
Dd3noob
Last edited Sep 18, 2020
Created on Sep 15, 2020

This chart displays monthly stock prices for Microsoft, Amazon, and IBM from 2000 to 2010 using a multi-line graph, with each company's price trend distinguished by a unique color from the `d3.schemeCategory10` palette. The data is loaded from a CSV file using `d3.csv()`, then parsed and grouped by symbol with `d3.group()`. Lines are drawn as SVG paths via `d3.line()`, with colors assigned dynamically from a `d3.scaleOrdinal` color scale based on each group's index, while axes are rendered using `d3.axisBottom` and `d3.axisLeft`.

AI-generated description

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

mit Licensed

Similar vizzes