Skip to content
Plotcnbeta
DocsChartsBlocksPlaygroundThemesExamples
Get started
Guide
  • Introduction
  • System Design
  • Engine Strategy
  • Installation
  • Project Setup
  • shadcn/ui Setup
  • Plotcn Registry
Fundamentals
  • Usage
  • Theming
  • Accessibility
  • Motion & Animation
  • Performance
  • TypeScript & I18n
Google Charts
  • Google Charts
  • Google GeoChart

System Design

Detailed architecture of Plotcn: three-engine strategy, runtime boundaries, shared visualization layer, and registry distribution.

Edit on GitHub
System Design

Plotcn Architecture

A source-first visualization system composed of three engines, a shared experience layer, and shadcn-compatible registry distribution.

Plotcn is an open-source, source-first visualization architecture for React.

The architecture preserves engine independence while delivering a unified developer and product experience. Recharts, D3.js, and Google Charts remain distinct engines, while Plotcn provides the shared visual tokens, responsive measurement, accessibility shell, and registry distribution layer.

++

High-Level Architecture

Plotcn organizes visualization delivery around two primary branches: the public website application and the shadcn-compatible registry distribution layer.

System Design 2.1

High-Level System Architecture

Three engines, shared visualization experience, shadcn-compatible registry distribution, and local consumer ownership.

ROOT SYSTEM
Three Engines
Plotcn Ecosystem
Source-first visualization platform for modern React applications.
branches into public site & registry

Product Website

Docs
Gallery
Playground

Plotcn Registry

shadcn-compatible

Distributes complete component source, dependencies, and Tailwind tokens as JSON items.

delivers source components
Three Independent Visualization Engines
PRIMARY REACT ENGINE
Declarative React
Recharts
Conventional dashboard, business metrics, Cartesian line/bar/area, and analytics.
Direct SVG Rendering
GEOMETRIC ENGINE
Math & Coordinates
D3.js
Advanced custom math, scales, force-directed layouts, hierarchy, and continuous domains.
React DOM + SVG/Canvas
HOSTED RUNTIME
Hosted Runtime
Google Charts
Enterprise core charts and vector GeoChart choropleths via hosted client loader.
Core Charts & GeoChart
unified through shared chart experience

Shared Visualization Experience

Consistency outside • Freedom inside
Responsive Container
Theme Tokens & CSS Vars
Truthful States
Accessibility & Tables
Tooltip Conventions
Legend Conventions
Formatting Helpers
Reduced Motion
renders to browser output
Recharts OutputInspectable SVG Elements
D3.js OutputSVG Paths or Canvas Surface
Google Charts OutputHosted Runtime Managed DOM

The Plotcn product model solves the problem of rigid third-party visualization libraries by separating engine capability, shared standards, and source ownership:

The Plotcn Product Formulation
Specialized Power
Engine Capability
Recharts, D3, or Google Charts
+
Plotcn Standards
Shared Experience
Responsive, theme, a11y, states
+
Distribution
shadcn Registry
Direct CLI source delivery
=Source-Owned Visualization Component
No black-box packages • You own every line

Plotcn does not attempt to replace the underlying visualization engines. Instead, it provides the production-ready product layer surrounding them.

++

Architectural Domains

The system is partitioned into five major architectural domains with strict unidirectional boundaries:

1. Product Application

HOSTING

Public user-facing surfaces built with Next.js App Router.

  • Documentation
  • Component Gallery
  • Interactive Playground
  • Registry Static Hosting

2. Shared Visualization Layer

STANDARDS

Engine-independent product concerns wrapping each chart.

  • Responsive Container
  • Truthful States
  • Semantic Theming
  • Accessibility Shell
  • Interaction Conventions

3. Visualization Engines

POWER

Three distinct rendering technologies with isolated scopes.

  • Recharts (Declarative SVG)
  • D3.js (Math & Geometry)
  • Google Charts (Hosted Runtime)

4. Registry Distribution

DISTRIBUTION

Static JSON metadata consumed by the official shadcn CLI.

  • Item Catalog
  • Registry Item Manifests
  • NPM Dependencies
  • Registry Dependencies

5. Consumer Application

DESTINATION

Your local codebase where source code is installed and modified.

  • Installed TypeScript Files
  • Direct Component Tweaks
  • Local Styling Overrides
  • No Upstream Lock-in

These five domains remain intentionally separated to prevent coupling product UI code to low-level visualization primitives.

++

Engine Architecture

Plotcn features three distinct rendering engines. Each engine is chosen for what it does best, maintaining clean architectural pipelines from typed application data to rendered pixels.

Recharts Pipeline

Declarative React
1. Typed application data
↓
2. Plotcn Recharts component
↓
3. Recharts primitives
↓
4. React DOM reconciler
↓
5. Vector SVG Output

Preserves declarative React conventions without extra proprietary wrappers.

D3.js Pipeline

Math ➔ React DOM
1. Raw or aggregated data
↓
2. D3 calculations (scale, layout, geometry, path)
↓
3. React component manages DOM & state
↓
4. SVG Paths or Canvas Surface

Avoids imperative `d3.select(...)` mutations inside React component lifecycles.

Google Charts Pipeline

Hosted Runtime
1. Typed application data
↓
2. Plotcn wrapper (transforms, theme, a11y)
↓
3. Shared Google loader (dedup, ready state)
↓
4. Google runtime `chart.draw(...)`
↓
5. Google-Managed Chart Output

Protected behind narrow client boundary. Never loaded in root layout or docs shell.

Recharts Architecture

Recharts is the primary engine for conventional React application charts:

  • Line & Area: Continuous time-series metrics, trends, and filled volume distributions
  • Bar & Column: Categorical comparisons, grouped bars, and stacked financial metrics
  • Pie & Donut: Proportional breakdowns, category shares, and center-stat KPI cards
  • Scatter & Bubble: Two-dimensional correlation plots and distribution clusters
  • Radar & Radial: Multi-axis capability scoring and circular progress metrics
  • Composed Charts: Combined line and bar charts sharing a unified time axis

Plotcn preserves Recharts' declarative React model without wrapping every primitive behind proprietary abstractions.

D3.js Architecture

D3 is used for custom mathematical geometries, continuous coordinate systems, and physics simulations:

  • Mathematical Scales: Continuous linear, logarithmic, power, time, and band scales
  • Geometric Paths: Area generators, curved lines, Voronoi tessellations, and contour paths
  • Hierarchy & Trees: Treemaps, circle packing, sunbursts, and dendrograms
  • Physics Layouts: Force-directed simulation nodes and spring networks
  • Interaction Transforms: Dynamic brush selections and smooth coordinate zoom/pan

Plotcn enforces a strict separation: D3 computes the math; React manages the DOM. Imperative mutations (d3.select(...)) are avoided in favor of declarative JSX SVG elements.

Google Charts Architecture

Google Charts requires a dedicated architecture because it uses a browser-loaded, externally hosted visualization runtime:

  • Typed Application Data: Passed as standard JavaScript object arrays
  • Plotcn Google Component: Handles data transformation, CSS variable theme translation, accessible screen-reader shell, and container lifecycle
  • Shared Google Loader: Coordinates script deduplication, on-demand package fetching, and promise caching
  • Google Runtime: Executes chart.draw(dataTable, options) inside an isolated rendering container
Hosted Runtime Boundary: Google Charts must remain behind a narrow client-side runtime boundary. Never load Google Charts from the root layout, documentation shell, component gallery, or application shell. Load it only when a Google visualization is actually mounted.
++

Shared Google Loader

All Google Charts components share a resilient, singleton loader located at @/lib/google-charts/loader.ts.

Shared Google Loader Guarantees

Located at `@/lib/google-charts/loader.ts`

Singleton Runtime Boundary
"idle"

Component unmounted or script not yet requested.

"loading"

Script or package Promise is actively pending.

"ready"

google.visualization API is ready to call .draw().

"error"

Script blocked by CSP, network offline, or timeout.

On-Demand Package Isolation (`googleChartPackages`)
Google Line / Bar / Areacorechart

Core 2D business Cartesian charts

Google GeoChartgeochart

Vector world and regional choropleths

Google Timelinetimeline

Temporal spans and Gantt schedules

Google Sankeysankey

Multi-stage energy and data flow paths

Google Org Chartorgchart

Hierarchical reporting structures

Google Tabletable

Interactive statistical data grid

The loader guarantees:

  • Single Script Injection: The external loader script (https://www.gstatic.com/charts/loader.js) is injected at most once across the entire application lifecycle.
  • Request Deduplication: Concurrent requests await the same pending initialization Promise.
  • On-Demand Package Loading: Only the packages required by active visualizations (corechart, geochart, timeline, sankey, orgchart, table) are fetched.
  • Explicit State Machine: Transitions through strongly typed states (idle → loading → ready | error).
  • SSR Safety: Guards against accessing window or document during server-side pre-rendering.
TypeScript
export type GoogleChartsLoaderState =  | "idle"  | "loading"  | "ready"  | "error"

Packages are mapped dynamically:

TypeScript
export const googleChartPackages = {  core: ["corechart"],  geo: ["geochart"],  timeline: ["timeline"],  sankey: ["sankey"],  org: ["orgchart"],  table: ["table"],} as const
++

Rendering Architecture

Plotcn implements three distinct rendering models, each reflecting the underlying engine's technical paradigm:

Recharts

Declarative React SVG
React Component
↓
Recharts Primitives
↓
SVG DOM Elements

Direct declarative React JSX rendering with built-in SVG transitions.

D3.js

Math-Driven React SVG/Canvas
Raw Data
↓
D3 Scale & Geometry
↓
React SVG Paths / Canvas

React owns state and DOM lifecycle. D3 computes coordinates and paths.

Google Charts

Hosted Client Runtime
Plotcn React Wrapper
↓
Singleton Loader
↓
Google Runtime Output

Isolated behind client-side wrapper. Redraws managed via ResizeObserver.

This distinction remains explicit throughout the codebase. No engine is forced to mimic another engine's internal execution model.

++

Shared Chart Layer

The shared chart layer encapsulates engine-independent product concerns while keeping engine-specific visualization mechanics native:

What the Shared Layer Owns

  • ChartContainer & ResizeObserver measurement
  • Truthful states (loading, empty, error, offline)
  • Semantic CSS variable theme tokens
  • Accessibility shell & screen-reader data tables
  • Number & currency formatting utilities
  • Tooltip & Legend visual design conventions
  • Reduced-motion-aware interaction conventions
  • Standardized registry item metadata

What the Shared Layer Excludes

  • Recharts-specific primitives (e.g. <XAxis>, <Tooltip>)
  • D3 scale calculations or force simulation engines
  • Google ChartOptions or google.visualization globals
  • Google loader internals or external network calls
  • Engine-specific event types or proprietary wrappers
  • Monolithic 'universal chart' abstractions

Shared Experience vs. Shared Implementation

The guiding rule of Plotcn is:

Share the experience when possible. Keep engine mechanics native.

Plotcn standardizes visual language, state transitions, accessibility requirements, and responsive conventions across all three engines without forcing an artificial, leaky universal chart abstraction.

++

Architectural Boundary Rules

Twelve architectural invariants govern every component in Plotcn:

RULE 1
Never force D3 through Recharts

D3 stays idiomatic React + modular D3. Do not create artificial Recharts adapters.

RULE 2
Never force Google Charts through Recharts

Google Charts retains its native loader, data model, and option semantics.

RULE 3
Do not create one universal chart API

Universal <Chart engine='google' /> abstractions hide engine strengths. Keep APIs engine-specific.

RULE 4
shadcn/ui is not a visualization engine

shadcn/ui provides surrounding dialogs, tabs, and registry conventions—not mathematical chart algorithms.

RULE 5
Registry code must remain readable

Installed components should be clean, readable TypeScript with zero obscure build helpers.

RULE 6
Prefer SVG as default renderer

SVG is responsive, accessible, inspectable, and CSS-friendly for normal chart densities.

RULE 7
Canvas is an optimization path

Introduce Canvas only when data point density and framerates genuinely justify it.

RULE 8
WebGL requires justification

Never add WebGL overhead unless extreme visual volume or 3D coordinate space demands it.

RULE 9
React owns component state

D3 computes geometry and scales; React owns rendering, state, and DOM lifecycle.

RULE 10
Google owns its runtime DOM

Google Charts controls its inner chart surface. React owns wrapper, container, and accessibility.

RULE 11
Google must never become a global dependency

The root layout, docs shell, and Recharts gallery must never load the Google script.

RULE 12
No cross-engine dependency leakage

Installing Recharts items never installs D3 or Google packages, and vice versa.

++

Client / Server Boundaries

The Plotcn website and consumer implementations follow Next.js server-first principles:

Server Environment

SSR / RSC
  • • Documentation prose & headings
  • • Server-rendered Shiki syntax highlighting
  • • Registry item catalog & manifests
  • • SEO metadata & OpenGraph tags
  • • Static layout skeletons & navigation

Client Environment

"use client"
  • • Interactive chart hover & tooltips
  • • Brush, pan, and zoom gestures
  • • Container ResizeObserver callbacks
  • • Google Charts runtime initialization
  • • Playground state & code preview tabs
Google Charts SSR Hydration Sequence
Server Render: Stable Container Skeleton➔Client Hydration: Mount Trigger➔Shared Loader: Fetch Script & Package➔Runtime Draw: SVG Output Rendered

Documentation prose, syntax highlighting, and registry manifests render statically on the server. Interactive chart interactions, hover tooltips, gesture zooms, and the Google Charts runtime initialize exclusively on the client behind explicit boundaries.

++

Responsive Architecture

Responsiveness in Plotcn is driven by the chart container, not merely the viewport window:

Container-First Responsiveness

Charts adapt to their bounding parent, not merely viewport width

ResizeObserver
MarginsDynamic Padding
TicksAuto Density
LabelsRotate / Hide
LegendsTop / Bottom / Wrap
AnnotationsCollapsible Notes
TouchTouch-Friendly Hitboxes
Google Charts Redraw Policy:

ResizeObserver detects width change ➔ Debounces 150ms to prevent thrashing ➔ Invokes `chart.draw(data, options)` ➔ Clean up listener on unmount.

Using ResizeObserver, charts respond fluidly whether placed inside full-width pages, responsive dashboard grids, narrow sidebar cards, or mobile modal drawers. Google Charts uses a 150ms debounced redraw schedule to prevent layout thrashing during continuous resize events.

++

Theme & Accessibility Architecture

Visual theming and screen-reader accessibility exist outside individual engine assumptions:

Semantic Theme Flow

1. Application CSS Variables (`--chart-1` ... `--chart-5`, `--background`)
↓
2. Plotcn Semantic Role Tokens (`primary`, `accent`, `muted`, `grid`)
↓
Recharts (CSS/SVG)
D3 (CSS/SVG)
Google (Options)

Universal Accessibility Contract

1. Visualization Component Root (`role="region"`, `aria-label`)
↓
Accessible Name
Live Summary
Data Table
↓
Full Screen-Reader & Keyboard Accessibility
  • Theme Flow: Inherits semantic application CSS variables (--chart-1 through --chart-5, --background, --foreground) and adapts them for Recharts SVG fills, D3 color scales, or Google Charts options objects.
  • Accessibility Flow: Every visualization implements role="region", aria-label, hidden natural-language screen-reader summaries, and accessible data disclosure tables.
++

Registry & Dependency Distribution

The Plotcn Registry is a distribution system, not an immutable runtime package.

Registry Distribution Flow

Remote: plotcn.vercel.app/r/{name}.json
↓
Local: npx shadcn@latest add @plotcn/{name}
↓
Consumer Repo: `@/components/charts/...` (You own every line)

Engine Sibling Model

Shared Chart Experience Layer
/ | \ (Siblings, Not Layers)
Recharts (SVG)
D3 (SVG/Canvas)
Google (Hosted)

Never stacked Recharts → D3 → Google. Each engine is an independent peer.

Visualizations are distributed as static JSON item manifests from the production registry origin (https://plotcn.vercel.app/r/{name}.json) and installed directly into your repository via the shadcn CLI:

Terminal
npx shadcn@latest add @plotcn/line-basic

Installed components are regular TypeScript and React files in your project. You own every line, with zero opaque node_modules lock-in.

++

Technology Stack

The Plotcn system leverages modern, production-hardened web standards:

Layer Technology Primary Responsibility
LayerTechnologyPrimary Responsibility
ApplicationNext.js App Router, React 19, TypeScriptDocumentation, gallery, registry hosting, SEO, playground shell
StylingTailwind CSS v4, CSS Variables, shadcn/uiDesign tokens, glassmorphism, responsive utilities, surrounding controls
IconsHugeicons ReactNavigation, action buttons, technical badges, status indicators
MotionMotion for React + D3 transitionsState transitions, data updates, reduced-motion-aware animations
Standard ChartsRechartsConventional Cartesian dashboard charts, analytics, and business metrics
Advanced GeometryModular D3 (d3-shape, d3-scale, d3-force)Custom math, continuous scales, hierarchies, Voronoi, and physics layouts
Enterprise & GeoGoogle Charts & GeoChartStatistical choropleth mapping, Gantt timelines, Sankey flows, and data grids
Google RuntimeShared Plotcn Google LoaderScript deduplication, on-demand package loading, readiness lifecycle
Primary RenderingVector SVGDefault renderer for Plotcn-owned Recharts and D3 visualizations
High-DensityCanvas APIHigh-throughput D3 visualizations where data density justifies it
Distributionshadcn Registry SchemaSource-available component delivery and dependency resolution
DocumentationMDX + Server-Side ShikiRich technical guides, live interactive examples, and syntax highlighting
++

Testing Boundaries

Quality assurance in Plotcn is organized across clear boundaries:

  • Shared Layer Tests: Validates ResizeObserver policies, theme token translation, screen-reader data table disclosure, and truthful state fallbacks.
  • Recharts Tests: Verifies component composition, tooltip rendering, reduced-motion overrides, and responsive breakpoints.
  • D3.js Tests: Tests mathematical coordinate projections, scale ranges, and geometric path generators independently of DOM rendering.
  • Google Charts Tests: Isolates local React wrapper unit tests from live external Google CDN integration tests.
  • Registry Installation Tests: Verifies that installed component source builds cleanly inside empty, fresh consumer projects.
++

Core Architectural Invariants

Eighteen immutable principles maintain Plotcn's architectural integrity as the catalog grows:

1Registry is distribution, not runtime.
2Installed source remains understandable.
3Recharts, D3.js and Google Charts remain independent engines.
4Shared code contains engine-independent product concerns.
5Engine-specific capabilities remain accessible.
6React owns Plotcn component state and composition.
7D3 primarily owns visualization math.
8Google owns its hosted rendering runtime.
9SVG remains the default Plotcn-owned renderer.
10Canvas is introduced only where density justifies it.
11Accessibility is part of the component contract.
12Responsiveness follows the container.
13Theme begins with semantic application tokens.
14No engine is loaded globally without need.
15Registry items install only required dependencies.
16Documentation never advertises nonexistent components or commands.
17Google GeoChart remains Google Charts, not Google Maps.
18The future Plotcn domain can replace the current Vercel origin centrally.
++

Final System Mental Model

Plotcn brings Recharts, D3.js, and Google Charts into one coherent developer ecosystem:

System Design 2.28

Final System Mental Model

Three visualization engines. One shared product experience. No unnecessary cross-engine abstraction.

PLOTCN SYSTEM
Three Engines
Plotcn Architecture
Source-first visualization ecosystem for modern React applications.
originates from
Product SiteDocs • Gallery • Playground
Registryshadcn CLI Source Distribution
delivers
RECHARTS
Declarative SVG
Conventional React
Line, Bar, Area, Pie, Scatter, Radar, Composed.
D3.JS
React DOM + SVG/Canvas
Mathematical Geometry
Continuous scales, force layouts, hierarchy, brush/zoom.
GOOGLE CHARTS
Hosted Runtime
Enterprise & Geo
Core charts, GeoChart choropleths via shared loader.
standardized by
SHARED PLOTCN EXPERIENCE

Semantic Tokens • Responsive Measurement • Truthful States • Accessibility Shell • Tooltip & Legend Standards

installed into
CONSUMER CODEBASE
Full Ownership
Your Git Repository
Complete, editable TypeScript source code. 100% owned and customized by you.
Three visualization engines. One shared product experience. Complete source ownership.

Recharts remains Recharts. D3 remains idiomatic React + D3. Google Charts retains its enterprise runtime and option model. Plotcn provides the unifying layer that makes all three feel intentional, consistent, responsive, accessible, and source-available for modern React applications.

PreviousIntroductionNextEngine Strategy

On this page

  • High-Level Architecture
  • Architectural Domains
  • Engine Architecture
  • Recharts Architecture
  • D3.js Architecture
  • Google Charts Architecture
  • Shared Google Loader
  • Rendering Architecture
  • Shared Chart Layer
  • Shared Experience vs. Shared Implementation
  • Architectural Boundary Rules
  • Client / Server Boundaries
  • Responsive Architecture
  • Theme & Accessibility Architecture
  • Registry & Dependency Distribution
  • Technology Stack
  • Testing Boundaries
  • Core Architectural Invariants
  • Final System Mental Model