Guide

Charting Library architecture

Maintainer overview of the dual build, public entry, and WordPress registration.

Role in the platform

@prc/charting-library is the shared visualization runtime. Chart Builder and other chart consumers import controllers from this package rather than individual chart files.

Authoritative chart-type routing lives in src/lib/controller/ChartBuilder.tsx (layout.type values). Some types resolve to two renderers by orientation (for example barBarHorizontal or BarVertical).

Dual build

webpack.config.js exports two configs from one source tree:

BuildOutputWordPress registrationRuntimeInteractivity store
Editorbuild/editor.jsClassic script prc-charting-libraryReact 18none — useChartStore is a no-op
Frontendbuild/view.jsScript Module @prc/charting-libraryPreact via preact/compatprc-chart-builder/chart store

PHP registration and publicPath: 'auto' handling live in class-prc-charting-library.php and src/publicPath.js. Chunks resolve relative to the loading module so VIP path contexts stay correct.

The Preact bundle also exposes window.prcChartingLibrary as a compat shim for prc-custom-charts (not yet on the dual-build path).

Public surface

The package entry (export.js / src) exports ChartBuilder* controllers. Consumers pass layout, data, and theme props; the controller picks the renderer.

Shared compute helpers and map utilities come from @prc/charting-utilities.

Map loading

Map topology is lazy-loaded so non-map charts do not pay for TopoJSON. See bundle optimization.

Build

npx turbo build --filter=@prc/charting-library

Was this helpful?