Skip to main content
100%

Centered text

✓ Published0🌍 Public
MMarta
Last edited Oct 2, 2024
Created on Sep 27, 2024

This example shows how to create a static SVG graphic with a single, perfectly centered text label against a teal background. The code uses D3’s `select` method to append an SVG element to the body and sets its dimensions via `viewBox`. It then appends a `text` element, positions it at the midpoint of the SVG’s width and height, and applies the `text-anchor` and `dominant-baseline` attributes to achieve both horizontal and vertical centering. The text is styled with a 34px font size.

AI-generated description

Trying to learn how this thing works.

ISC Licensed

Similar vizzes