@protoyard/charts-ui
v1.9.4
Published
Svelte chart components for Protoyard: thin re-exports and adapters over @texuli/charts families.
Maintainers
Readme
@protoyard/charts-ui
Svelte 5 chart components for Protoyard prototypes. Every family re-exports
the charts of Texuli
(@texuli/charts), with thin adapters that keep Protoyard's props
(docs/texuli-charts.md). The math comes from
@protoyard/charts, which re-exports
@texuli/charts/math (ADR-044). Each chart family
has its own subpath, so a prototype pays only for the families its screens
import. Nothing here is re-exported from the @protoyard/ui barrel.
ChartRoot is a compatibility wrapper around Texuli chart families: it keeps
Protoyard's named-group focus target and data-py-chart marker while using
Texuli's cx helper for its styling. CellPlot is a direct alias of the
Texuli-backed Heatmap adapter. RampLegend preserves its optional-label
Protoyard prop while delegating rendering and accessibility to
@texuli/charts/matrix from Texuli 0.5.0.
Install in a workspace prototype
Add "@protoyard/charts-ui": "workspace:*" to the prototype dependencies and
import the styles after Tailwind and the theme/UI styles:
@import 'tailwindcss';
@import '@protoyard/themes/base.css';
@import '@protoyard/ui/styles.css';
@import '@protoyard/charts-ui/styles.css';Entry points
| Import | Family |
| --- | --- |
| @protoyard/charts-ui | CHART_FAMILIES and the data contract types only (imports no family) |
| @protoyard/charts-ui/cartesian | Line, area, bar, combo, scatter |
| @protoyard/charts-ui/part-whole | Pie, donut, funnel, treemap, sankey |
| @protoyard/charts-ui/matrix | Histogram, heatmap, calendar heatmap |
| @protoyard/charts-ui/compact | Sparkline, gauge, radial progress |
| @protoyard/charts-ui/canvas | Canvas renderer for dense series |
| @protoyard/charts-ui/geo | Tile-grid choropleth |
| @protoyard/charts-ui/flow | Funnel, sankey and network graph, straight from @texuli/charts/flow |
| @protoyard/charts-ui/interaction | The shared interaction layer (InteractivePlot, Legend, ChartTable, TableToggle, brush, zoom and keyboard helpers) from @texuli/charts/interaction |
What each subpath ships:
./cartesian: LineChart, AreaChart, BarChart, ComboChart, ScatterChart;./part-whole: DonutChart, PieChart, FunnelChart, Treemap, SankeyChart, plus Texuli's TreemapChart and SunburstChart;./matrix: Heatmap, CalendarHeatmap, Histogram, RampLegend;./compact: Sparkline, Gauge, RadialProgress;./geo: TileMap;./canvas: the Canvas renderer used by the dense line and scatter charts;./flowand./interaction: Texuli's flow charts and interaction layer.
Sizes, measured by pnpm exec tsx scripts/bench-charts.ts --skip-browser
--check (a real Vite build with one lazy import per family; gzip level 9 of
the chunks each family downloads beyond the app entry): cartesian 13,466 B,
part-whole 9,819 B, matrix 15,923 B, compact 7,213 B, canvas 1,647 B, geo
4,651 B. A LineChart + BarChart view is 8,977 B (12,718 B on Texuli 0.9.0),
within the bench's 13,354 B guard.
The platform guide with every chart's props, the data contracts and the
measured numbers is docs/CHARTS.md. sideEffects lists only CSS,
so a bundler keeps just the components a screen imports from a subpath. Load a family from a lazy route (load: () => import('./Screen.svelte'))
so charts stay out of the initial chunk.
Families and props
Each subpath re-exports Texuli's charts, through an adapter where Protoyard's props differ (docs/texuli-charts.md):
./cartesian: LineChart, AreaChart, BarChart and ComboChart passemptyMessageanddescriptionto Texuli'sdescription, drop Protoyard-only series fields, and forwardxKind,formatXandlocale:xKind="time"reads epoch milliseconds as UTC dates on the axis, live region, tooltip and table. Atimeorlinearkind on string x keeps Texuli's inferred axis instead of throwing. ScatterChart mapsseries[]to Texuli's matrixpoints[]../part-whole: Pie and Donut default the tablelabelsand mapheighttosize; FunnelChart mapscounttovalue; Texuli's TreemapChart and SunburstChart are re-exported as they are../matrixand./geo: Histogram bins with@texuli/charts/mathbinand draws a BarChart; CalendarHeatmap lays out cells withcalendarLayout; TileMap draws Texuli'sGeoMap(WORLD_TILESandREGION_TILESre-exported)../compact: RadialProgress draws Texuli'sProgressRing../canvas,./flow,./interaction: Texuli's, unchanged.
Many older props are accepted but ignored (units and currency
formatting, axis kinds, curve, renderer, loading / error /
onretry, showLegend / showTable / hidden, among others). The exact
props each adapter forwards, the data contracts, the keyboard and screen
reader behavior, the palette and the renderers are documented in
docs/CHARTS.md from the adapter source.
Tests
pnpm vitest run packages/charts-ui
pnpm --filter @protoyard/charts-ui typecheck
pnpm exec tsx scripts/bench-charts.ts --skip-browser --check # Node math + real Vite bundle sizesPackage output
The repository keeps source exports for workspace development. pnpm build:packages --filter svelte creates the compiled ESM, declarations and Svelte components under dist/ that the packed manifest exposes.
