Search⌘ K

Elements: Circle, Ellipse, and Rectangle

Explore how to create basic SVG shapes like circles, ellipses, and rectangles in D3.js. Learn the essential attributes for positioning and sizing these elements, along with optional features like curved rectangle corners to enhance your data visualizations.

We'll cover the following...

What is an element?

We will begin by describing what we mean when we talk about an “element.”

There is considerable scope for confusion when talking about elements on a web page. Are we talking about HTML elements, SVG elements, or something different?

In fact, we are going to be describing a subset of SVG elements. Specifically, a collection of common shapes and objects which include circles, ellipses, rectangles, lines, polylines, polygons, text, and paths.

“Text?” I hear you say. “Doesn’t sound like a shape.” I suppose it depends on how you think of it. We can use text in different ways in D3. But for this particular exercise, we can regard text as an SVG element.


Circle

A circle is a simple SVG shape that is ...