Skip to main content
Public

Share visualization

Loading preview…

Line Chart Using a Qualitative Color Scale with D3

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Line Chart Using a Qualitative Color Scale with D3

0 stars1Public
OOlha
Last edited Apr 18, 2022
Created on Mar 8, 2022

This line chart tracks abortion rates over time across multiple U.S. states, with each state represented by a separate colored line using a qualitative Set1 color scale from ColorBrewer. A legend to the right identifies each state, and hovering over individual data points reveals an interactive tooltip with the year, state, and rate. The visualization is built with D3 v7, using `d3.scaleOrdinal` for color assignment, `d3.line` for path generation, and SVG rendering with animated tooltip transitions.

AI-generated description

Assignment 6 part A+

Line chart with at least 4 separate lines colored using a qualitative color scale with the appropriate legend.

I've generated and used this color schema: https://colorbrewer2.org/?type=qualitative&scheme=Set1&n=8 but later I've got that I can load colors directly fromt the https://colorbrewer2.org/export/colorbrewer.js and use in the code.

Provided example refers to the v3 of D3 and some of the methods mentioned are deprecated, e.g. scale.category10. Also http should be changed to https in order colorbrew to work.

documentation https://github.com/d3/d3/blob/main/API.md

Comments

Sign in to join the discussion.

MIT Licensed