Skip to main content
100%

Selecting a Year on a Line Chart

✓ Published1🌍 Public
BBKirst3
Last edited Mar 7, 2021
Created on Mar 7, 2021

This example shows a line chart of population over time for world regions, using a vertical grey line to highlight a selected year (2021). The chart is rendered with SVG, and the code uses d3.scaleTime, d3.scaleLinear, d3.line with curveBasis, and d3.nest to group data by region. A transparent rectangle covers the plot area, and its mousemove event uses d3.mouse and xScale.invert to log the year under the cursor. Data comes from the UN population estimates and medium variant CSV datasets, processed with d3.csv and d3.timeParse.

AI-generated description
MIT Licensed

Similar vizzes