Skip to main content
100%

D3 Fruits - scaleOrdinal

✓ Published0🌍 Public
YYoung Song
Last edited Jun 23, 2022
Created on Jun 21, 2022

Three fruit categories—apple, lemon, and watermelon—are displayed as colored, sized circles that shift horizontally with animated transitions. Using `d3.scaleOrdinal`, the example maps each fruit domain to distinct size (`r`), fill color, and gap values that adjust the spacing between circles during the render. The SVG groups animate their `transform` position over one second via `transition().duration()`, while labels appear above each circle with matching offsets. The code imports from D3 v7 and relies on a custom render function to coordinate the ordinal scales and dynamic positioning.

AI-generated description
  • Using scaleOridinal for
    • Size control
    • Color control
    • Gab control
MIT Licensed

Similar vizzes