Melting Data for Multiple Lines
✓ Published1🌍 Public
Using D3 v5, this chart visualizes global population trends from 1950 through 2100 by combining two datasets: historical estimates and medium-variant projections. It displays multiple lines, each representing a development region, with a color legend and a vertical line marking the year 2018. The code melts the wide-format data into a tidy structure, then uses `d3.scaleTime`, `d3.scaleLinear`, `d3.axisBottom`, and `d3.axisLeft` to render the SVG chart. A `d3.line` path with `curveBasis` draws each line, and an interactive mouse event on a transparent rectangle captures hover positions. This example demonstrates a data-wrangling technique for creating multi-line charts from time-series data.
AI-generated descriptionMIT Licensed