Skip navigation

Pie Charts & Geometry

A Mathematical Construction of Pie Charts Using Cubic Bézier Curves

This page demonstrates how a pie chart can be constructed mathematically using circle primitives, cubic Bézier curves, and 2D rotation, rather than relying on built-in arc primitives.

All geometry is intentionally constructed in a single, fixed quadrant first, then rotated into position. This constraint simplifies both the math and the rendering pipeline, while remaining fully general.

Prework: Data Normalization & Angular Planning

Before any geometry is drawn, the data must be converted into angular space.

Instructions

  1. Collect the dataset. Begin with an ordered list of non-negative values. The order determines the order of slices in the pie.
  2. Compute the total. Sum all values to get a single total.
  3. Convert values into angles. Map each value to a proportion of 360°.
  4. Accumulate start angles. Each slice’s start angle is the sum of all previous slice angles.
  5. Result. Each slice is now defined purely in terms of a sweep angle and a start angle. No geometry has been constructed yet.
Loading…

To construct the full chart:

  1. Normalize the dataset.
  2. Compute slice angles.
  3. For each slice:
    • Build primitives.
    • Construct Bézier arcs (subdividing if necessary).
    • Rotate geometry into position.
  4. Render slices sequentially.

Each slice is independent. Continuity emerges naturally from accumulation and rotation.

Why This Approach Works

  • Geometry is local and predictable.
  • Rotation is cheaper than recomputation.
  • Bézier approximation avoids SVG arc quirks.
  • Interactivity remains smooth under repeated updates.

The result is a pie chart whose geometry is explicit, reproducible, and responsive under interaction.

A note on coordinate systems (optional)

Readers familiar with mathematical coordinate systems may notice that the vertical axis in the visualization appears inverted relative to textbook Cartesian diagrams.

This is intentional. Screen-based graphics systems (SVG, Canvas, and most UI frameworks) use a coordinate system where the origin is at the top-left of the viewport and the y-axis increases downward. Trigonometric calculations are performed using standard mathematical conventions and then mapped into screen coordinates for display.

This distinction does not affect the geometry itself, but it is worth keeping in mind when comparing formulas or diagrams across different contexts.

For further background, see:

Design Note

In addition to the geometric model described above, the visualization follows a deliberate visual and interaction system. Decisions around typographic scale, luminance hierarchy, stroke weight, color semantics, and interaction affordances are treated as structural rather than decorative.

For readers interested in how these choices were made, see Design Rationale: Visual Encoding in the Pie & Bézier Studies.