🌍 Public
Viewing a saved revision (read-only)
41becb5642ba4c58b150f07ab6e698ee
Shapes with SVG and CSS
This example demonstrates how SVG shapes can be styled and colored through a combination of D3.js and CSS. It shows four rectangles arranged in a group, each assigned a distinct fill color from a scaleOrdinal mapping. The code uses D3 v5’s select and scaleOrdinal functions to programmatically apply colors to the rectangle IDs. The SVG elements are defined directly in the HTML, while the styling is applied via JavaScript, with additional CSS rules available for stroke and path properties.
AI-generated descriptionAn example including some commonly used features of SVG.