Melting Data for Multiple Lines
✓ Published0🌍 Public
This example shows four stacked line charts tracking cumulative counts of different infection sources—travel to Hubei, relatives, social contacts, and public transit—over time. The code uses d3.nest() to group the CSV data by category, then renders each category as a separate SVG path with d3.line(). A color legend is built using a custom colorLegend function with d3.scaleOrdinal. The x-axis uses d3.scaleTime for date parsing, while the y-axis uses d3.scaleLinear for counts.
AI-generated descriptionMIT Licensed