liveBook · Manning

Geometric primitive

As explained in D3.js in Action, Third Edition

A geometric primitive is a simple graphical form such as a point, line, circle, or rectangle that can be combined into more complex graphics.

A geometric primitive, also called a graphical primitive, is a simple shape used as a building block for graphics. Points, lines, circles, and rectangles can be combined into richer visual displays. section 1.2.2

In SVG, primitives become visible elements positioned in a coordinate system. A line uses two endpoints; rectangles use position and dimensions; circles and ellipses use a center and radii. Fill, stroke, and stroke width control their appearance. section 1.2.2

Think in primitives to break a visualization into manageable parts:

  • Tree layouts can be understood as circles connected by lines. section 1.2.2
  • Interactive timelines can be treated as collections of rectangles and points. section 1.2.2
  • Geographic graphics can be reduced to polygons, points, and lines. section 1.2.2

Build an SVG shape gallery

Place a line, several rectangles, a circle, an ellipse, and a path inside an SVG container. Give each shape coordinates and styling, then add text labels to make the role of each primitive clear. section 1.2.2

Figure 1.8 Gallery of fundamental SVG shapes that we’ll build in this section
figure

A gallery makes the distinct forms of fundamental SVG primitives easy to compare at a glance. section 1.2.2

How D3.js in Action, Third Edition covers it

How deep it goes
Defines primitives and works through SVG shape attributes, stopping short of a comprehensive SVG reference.
Examples
Uses an SVG gallery containing a line, styled rectangles, circle, ellipse, path, and text labels.
What it assumes
Introduces the basic SVG knowledge needed for D3 projects without requiring a comprehensive SVG guide.
What you can do after
Build it from scratch by composing and styling basic SVG shapes for a visualization.
How it connects
Connects SVG coordinate systems, lines, rectangles, circles, ellipses, paths, tree layouts, timelines, and geographic data.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.