🌍 Public
Viewing a saved revision (read-only)
a485468a5b014eb68505b1f598b8b9d7
Loading Data with React and D3
This example demonstrates how to load external data with D3 utilities while using React state to manage the fetched result. The dataViz component initializes with null data, then uses the useEffect hook to call d3.csv on a remote CSV file containing emission data, storing the result via setData. Once loaded, the message function displays formatted statistics about the dataset, including its size in kilobytes, row count, and column count. The code imports React, ReactDOM, and D3 v7 directly from CDN links in the HTML file, with the data rendered inside a pre element.
AI-generated descriptionA program that loads in some data using D3 Utilities, and uses React state to keep track of the data.