Skip to main content
100%

Selecting a Year on a Line Chart

✓ Published0🌍 Public
Ppplomith
Last edited Apr 24, 2021
Created on Apr 7, 2021

This example shows a multi-line chart of population over time for world regions, with an interactive vertical line that lets users select a specific year. Moving the mouse across the chart updates the selected year, demonstrating how user input can drive state changes in a visualization. The code uses d3.nest to group data, d3.scaleTime and d3.scaleLinear for axes, and a custom colorLegend function with d3.scaleOrdinal. It loads UN population estimates from CSVs and renders the chart as SVG with d3.line and curveBasis.

AI-generated description
MIT Licensed

Similar vizzes