Skip to main content
100%

d3 Starter Bowl of Fruit - General Update Pattern

✓ Published0🌍 Public
GgitSushi
Last edited Apr 22, 2020
Created on Apr 22, 2020

This example demonstrates the "general update pattern" in D3.js v5 by rendering a static bowl of fruit—a set of apples and a lemon—as SVG shapes. The visualization dynamically updates the fruit bowl through a series of timed events, removing apples, replacing one with a lemon, and filtering out another, using the `selectAll`, `enter`, `merge`, and `exit` methods (e.g., `selection.selectAll('g').data(fruits)`, `groups.enter().append('g')`) to handle element creation, updating, and removal. The code uses D3's `scaleOrdinal` for color and radius mapping, with the SVG rendered directly as `rect`, `circle`, and `text` elements. Data is generated via `range(5)` and `makeFruit` functions, reacting to `setTimeout` callbacks that call `render()`.

AI-generated description

data visualisation with D3.js : stopped at 06:05:00

From freeCodeCamp tutorial, on youtube FCC channel, by Curran Kelleher.

MIT Licensed

Similar vizzes