Selecting a Year on a Line Chart
Lines show U.N. population estimates and projections by global region from 1950 to 2100, colored with a categorical scale. Hovering over the chart updates a vertical line marking the selected year, and the visualization redraws accordingly. The code uses d3.csv, d3.nest, d3.line, d3.scaleTime, d3.scaleLinear, and d3.axisBottom to render SVG paths and axes. A legend built with d3.scaleOrdinal and custom colorLegend.js shows region colors.