d3-shape

Graphical shape generators for arcs, lines, areas, pies, and stacks that render as SVG paths or Canvas draw calls.

Library
npm
v3.2.0
2,527stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
50/100Fair
Development Activity0
Maintenance32
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture85
Code Quality78
Innovation72
Learning Curve55

d3-shape is the shape-generation module of D3.js, providing data-driven generators for the visual primitives that most charts are built from: arcs (for pie and donut charts), lines and areas (for line and area charts), symbols (for scatterplots), and stacked layouts (for stacked bar and area charts). Each generator is a configurable function — you feed it data and accessor functions, and it produces either an SVG path string or a sequence of Canvas drawing commands via a pluggable context/curve system.

Because it only produces geometry rather than owning any DOM or rendering pipeline, d3-shape slots into any rendering approach: raw SVG, Canvas, or a component framework like React or Svelte that renders the generated path string itself. It underlies a large share of the JavaScript charting ecosystem, either directly or via libraries that wrap it.

What You Get

  • Arc generator for pie, donut, and radial-bar shapes with corner radius, padding angle, and corner tangent support
  • Line and area generators (plus radial variants) with configurable x/y accessors and a defined() gap-handling hook
  • A pluggable curve system (basis, cardinal, Catmull-Rom, monotone, natural, step, bump, and linear variants) for interpolating between points
  • Stack layout with selectable order (ascending, descending, inside-out, appearance, none) and offset (expand, silhouette, wiggle, diverging, none) algorithms for stacked charts
  • A symbol generator with a dozen built-in marker types (circle, cross, diamond, square, star, triangle, wye, asterisk, plus, times) for scatterplot points
  • Link generators (horizontal, vertical, radial) for drawing curved connectors between nodes, as used in tree and network diagrams

Common Use Cases

  • Rendering pie and donut charts by feeding arc data through the arc generator
  • Drawing line and area charts with smooth or stepped interpolation via the curve system
  • Building stacked bar or area charts using the stack layout’s ordering and offset algorithms
  • Plotting scatterplot markers with the symbol generator’s built-in shape types
  • Drawing curved links between nodes in tree, network, or Sankey-style diagrams

Under The Hood

Architecture Each generator (arc.js, line.js, area.js, pie.js, stack.js, symbol.js) follows the same closure-based factory pattern established across the D3 ecosystem: a function returns a configurable generator closure exposing chained accessor methods (e.g. line.x(), line.y(), line.curve()) that mutate captured local state and return the generator itself for chaining. Rendering is decoupled from geometry through the context/curve abstraction in src/path.js and src/curve/: a generator calls methods like lineStart(), point(), and lineEnd() on whatever context it’s given, which is either a path buffer (producing an SVG path string) or a Canvas 2D context (producing draw calls directly), so the same generator works for both targets with no branching in the generator itself. Curves plug into this same protocol as intermediary contexts, letting line.curve(curveBasis) reroute point calls through interpolation logic before they reach the final output. Stack layout (stack.js) is a separate two-stage pipeline: series construction followed by independently swappable order and offset functions, keeping the layout algorithm decomposed into small single-purpose modules under src/order/ and src/offset/.

Tech Stack Written in plain ES modules with zero runtime dependencies beyond d3-path (used for the shared path-buffer implementation). No framework, bundler-specific runtime, or build-time codegen is used for the library itself; rollup (with rollup-plugin-terser) is used only to produce the published UMD/minified bundles, and the package ships both an ES module entry point and a UMD build for CDN/<script> consumption via unpkg/jsdelivr.

Code Quality Tests are written with mocha against the source modules directly (test/**/*-test.js), covering the public API surface of each generator including edge cases like empty/undefined data, degenerate arcs, and every curve/offset/order variant, and CI runs eslint alongside the test suite on every push and pull request via GitHub Actions. Code style favors compact, low-abstraction procedural functions with var-based closures rather than classes, consistent with the rest of the D3 module family; there is no TypeScript, but the small, focused module boundaries and thorough test coverage substitute for static typing in catching regressions.

What Makes It Unique Rather than being a chart library, d3-shape isolates pure geometry computation from rendering and layout, which is what lets the same arc/line/area/stack math work identically whether the output is SVG, Canvas, or consumed by a completely different rendering layer such as a React component that reads the returned path string. The context/curve protocol is a small but effective abstraction: adding a new interpolation style or a new output target requires implementing one interface, not modifying every generator. This design is why so much of the JavaScript charting ecosystem either depends on d3-shape directly or has independently converged on a similar geometry/rendering split.

Used by 8 apps in this directory

Go
52%
MIT

Bytebase

Devops

14,467

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
92
Repo Health
73
Technical
68
Dependency
Built with
Go52%
TypeScript39%
Updated yesterday
TypeScript
65%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,790

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript65%
Svelte13%
HTML12%
Updated yesterday
Python
65%
MIT

LibrePhotos

File Storage

8,061

Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.

View details
82
Repo Health
78
Technical
66
Dependency
Built with
Python65%
TypeScript32%
Updated 2 days ago
TypeScript
97%
MIT

likec4

Developer Tools · Devops

5,634

Define your software architecture as code and get always up-to-date, interactive C4 diagrams generated automatically from a DSL.

View details
89
Repo Health
83
Technical
77
Dependency
Built with
TypeScript97%
Updated yesterday
Python
54%
Other

PostHog

Analytics · Monitoring · Developer Tools

39,612

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python54%
TypeScript36%
Updated today
Go
40%
Apache 2.0

Rill

Analytics · Data Engineering

2,867

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
64
Dependency
Built with
Go40%
TypeScript37%
Svelte22%
Updated 2 days ago
TypeScript
96%
Other

superglue

AI Agents · Data Engineering · Developer Tools

2,056

superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).

View details
54
Repo Health
79
Technical
71
Dependency
Built with
TypeScript96%
Updated 2 weeks ago
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search