Viewing a saved revision (read-only)
KNlC19Atud3l14bg_paNs
This example shows a React and D3 interactive scatter plot of five clickable circles loaded from a local CSV file. Clicking a circle highlights it by changing its fill to white and adding a black stroke, using React state to track the selected circle’s ID. The visualization rescales circle positions with `d3.scaleLinear` based on container dimensions tracked by a `ResizeObserver` hook. Rendering is handled imperatively through `d3.select`, `selection.join`, and event listeners, while React manages data loading and state updates.
Rainbow Moving Circles
An interactive D3 + React visualization of five colorful circles that drift and pulse around the screen, cycling through rainbow hues over time, with a live Voronoi overlay.
Features
- Rainbow colors: Each circle cycles through the full hue spectrum using HSL colors
- Smooth motion: Circles bob and sway along gentle sine/cosine paths
- Pulsing size: Circle radii gently expand and contract
- Voronoi overlay: A Voronoi diagram (via d3-delaunay) is drawn over the circles; cells tinted with each circle's hue follow the moving circles in real time
- Interactivity: Click a circle to select it (it turns white with a black outline, and its Voronoi cell is highlighted)
- Responsive: Fills the window and adapts to resizes
Usage
Open index.html in a browser. The animation runs automatically.