🌍 Public
Viewing a saved revision (read-only)
90954f3b7662415e896b9e4d8d5905ab
Drawing SVG rect with D3
This example demonstrates two ways to render a blue SVG rectangle: one statically defined directly in HTML markup, and another generated dynamically using D3’s selection and data-join methods. The code uses `d3.select` to append an `svg` element to the body, then chains an `append('rect')` call to set its width and height attributes via `.attr()` and its fill color via `.style()`. A hand-written `<rect>` element appears above as a visual comparison, while the D3-generated rectangle is rendered below, with both sharing the same dimensions and color.
AI-generated descriptionA bare minimum HTML page.
See also React Starter.