Bowl of Fruit - General Update Pattern Special Cases
This example demonstrates the general update pattern in D3, focusing on special cases when data elements are added and removed. As apples are bought and eaten, the visualization animates new fruit entering the bowl while existing fruit exits, with circles and text labels scaling down before removal. The bowl itself resizes to accommodate the changing number of fruits. The code uses D3 v5 APIs including `selection.selectAll`, `.enter()`, `.merge()`, `.exit()`, and transitions with `.duration()`. It renders to SVG with ordinal scales mapping fruit types to colors and radii, with a timeout delaying the bowl’s width adjustment.