Skip to main content
100%

27 - melting data for multiple lines - dataviz 2018

✓ Published0🌍 Public
Zzach b.
Last edited Jan 13, 2022
Created on Jan 12, 2022

A multi-line chart displays population trends over time for various countries and regions, using the United Nations population estimates and projections dataset. The visualization employs multiple vertical reference lines to highlight the current year, a hovered year, and a selected year, which users can change by clicking on the chart. The D3 code uses `d3.nest` to group data by region and `d3.line` with `d3.curveBasis` to draw the smoothed paths, while `d3.scaleOrdinal` and `d3.schemeCategory10` assign colors. A custom color legend function renders the region names and color swatches.

AI-generated description

datraviz 2018 #27 - melting data

"melting" comes from the R community. it refers to taking a dataset with many columns, the "ice cube", and melting it into a dataset with many rows, the "icicle". implementation: nested forEach loops.

--
d3.nest was replaced with d3.group and d3.rollup in v6.0 (src). so i'll be using v5.6.0 like the course example here.

MIT Licensed

Similar vizzes