Skip to main content
100%

Shapes with SVG and CSS

✓ Published0🌍 Public
MMihir Sawant
Last edited Sep 11, 2018
Created on Sep 10, 2018

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 description

An example including some commonly used features of SVG.

MIT Licensed

Similar vizzes