Loading Data with React and D3
This example demonstrates how to load and parse a CSV dataset of fatal police shootings in the US using D3 and React, displaying the data’s size, row count, and column count as text. The visualization shows a simple loading state until the data arrives, then presents the parsed summary. It uses `d3.csv` to fetch the dataset from a URL and React’s `useState` and `useEffect` hooks to manage the asynchronous data fetching and re-rendering. The data originates from the Washington Post’s police shootings database.
AI-generated descriptionA program that loads and parses some CSV fatal police shooting data collected by the Washington Post on fatal police shootings in the US from 2015-present (Sept 9, 2020). The original data is updated in near real time and so may differ slightly from the data contained in this gist.
Additional information can be found at the study web page
Using D3 to load and React states to keep track of the data