Skip to main content
100%

Selecting a Year on a Line Chart

✓ Published0🌍 Public
Wwishcsdev
Last edited Apr 9, 2019
Created on Apr 3, 2019

This line chart visualizes population trends over time by region, sourced from UN population estimates and medium-variant projections (1950–2100). A vertical line highlights the currently selected year, which users change by hovering anywhere on the chart, triggering a re-render via `setSelectedYear`. The chart uses `d3.scaleTime` and `d3.scaleLinear` for axes, `d3.line` with `d3.curveBasis` for smooth paths, and a categorical color legend built from `d3.schemeCategory10`. A semi-transparent rectangle captures `mousemove` events to invert the mouse position back to a date with `xScale.invert`.

AI-generated description
MIT Licensed

Similar vizzes