🌍 Public
Viewing a saved revision (read-only)
7e270f5c67d74b5bbe4e2a9a8d8c61d1
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.