Skip to main content
100%

NYC Crash Bar Chart Interactive Legend with React & D3

✓ Published0🌍 Public
JJose Morales
Last edited Nov 6, 2025
Created on Oct 30, 2025

This stacked bar chart displays NYC collision data by hour, breaking down each bar into injuries, deaths, and other crashes. Hovering over legend items highlights the corresponding stack with a black stroke and fades others to 20% opacity. The visualization uses React for state management and D3 v7 for rendering, including `d3.stack`, `d3.scaleLinear`, and `d3.axisBottom`. It loads hourly crash statistics from a CSV file via `d3.csv` and handles window resizing with dynamic SVG dimensions.

AI-generated description

Stacked Bar Chart - NYC Collision Data

This visualization shows a stacked bar chart of NYC collision data by hour, displaying injuries, deaths, and other crashes.

Interactions

  • Hover over the legend items to highlight the corresponding bars in the chart
  • Hovered bars are highlighted with a black stroke and brought to the front
  • Non-hovered bars fade to 20% opacity when hovering

Data

The data shows hourly collision statistics including:

  • Total injuries
  • Total deaths
  • Remaining crashes (crashes without injuries or deaths)
MIT Licensed

Similar vizzes