@texuli/charts
v0.18.0
Published
Chart math and every chart family, one lazy subpath per family.
Maintainers
Readme
@texuli/charts
Accessible Svelte 5 charts and the framework-free chart math behind them. Line, area, bar, pie, treemap, heatmap, Sankey, gauge, box plot and more: every family is its own lazy subpath, every chart renders an accessible summary and a data-table fallback, and the scales, shapes and layouts are plain TypeScript you can use without any component. It is part of Texuli, "Small pieces. Infinite possibilities.": an MIT Svelte 5 component library by Dailybot, Inc., for application developers and for agents that render charts from validated data.
In the stack: layer L4, a domain package on the @texuli/core texels, @texuli/primitives, the @texuli/tokens token engine and the texuli components. @texuli/blocks, the agent catalog, the player and @texuli/tools build on it.
Status: 0.x release.
@texuli/chartsis published on npm as0.18.0, a pre-1.0 release (1.0.0 will be the first stable release). Under 0.x, a new minor (0.14.0) may contain breaking changes, so pin the exact version or use^0.18.0, which accepts only 0.18.x.
Install
npm install @texuli/charts @texuli/tokens sveltesvelte(^5.57.2) is a peer dependency.- Charts style themselves with the Texuli
--tx-*design tokens. Import the token stylesheet once in your app (installing@texuli/tokensdirectly lets your bundler resolve it); each chart imports its own component CSS.
@import '@texuli/tokens/base.css';Quick start
<script lang="ts">
import { LineChart, type CartesianSeries } from '@texuli/charts/cartesian';
const series: CartesianSeries[] = [
{
id: 'signups',
label: 'Sign-ups',
points: [
{ x: 'Jan', y: 120 },
{ x: 'Feb', y: 180 },
{ x: 'Mar', y: 165 },
],
},
];
</script>
<LineChart
title="Monthly sign-ups"
description="Sign-ups rose in February and held steady in March."
{series}
/>title and description are required: they become the chart's accessible
name and summary. The math works on its own, with no Svelte:
import { linearScale, lttbIndices } from '@texuli/charts/math';
const y = linearScale({ domain: [0, 180], range: [320, 0], nice: true });
y(90); // pixel position
y.ticks(5); // tick values
const keep = lttbIndices(xs, ys, 500); // downsample a long series to 500 pointsWhat's inside
Chart families (Svelte components):
| Import | What it gives you |
| --- | --- |
| @texuli/charts/cartesian | LineChart, AreaChart, BarChart, StackedBarChart, ComboChart and the shared CartesianChart |
| @texuli/charts/part-whole | Pie, donut, sunburst and treemap charts |
| @texuli/charts/matrix | Heatmap, scatter and bubble charts, and RampLegend (an accessible color-ramp legend for a heatmap) |
| @texuli/charts/compact | Sparkline, BulletChart, Gauge and ProgressRing, each with an optional formatValue(value) callback |
| @texuli/charts/sparkline-lite | A light Sparkline (same props): the drawing and its accessible description, without the data table, for first screens |
| @texuli/charts/flow | Sankey, funnel and network charts |
| @texuli/charts/geo | Schematic tile and point maps |
| @texuli/charts/histogram | HistogramChart |
| @texuli/charts/pack | PackChart (circle packing) |
| @texuli/charts/calendar | CalendarHeatmap |
| @texuli/charts/statistical | BoxPlotChart, ViolinChart and EcdfChart, with quantile, density and ECDF math |
Building blocks:
| Import | What it gives you |
| --- | --- |
| @texuli/charts/axis | Reusable SVG axes, the tick model and numeric and time tick formatters |
| @texuli/charts/interaction | Tooltip, legend, data table and keyboard exploration pieces |
| @texuli/charts/annotations | AnnotationLayer: reference lines, bands and point callouts |
| @texuli/charts/canvas | A canvas renderer for dense series |
| @texuli/charts/colors | Token-backed categorical, sequential and diverging color scales |
| @texuli/charts/schemas | chartPropSchemas, the prop schema of every family, for builders and inspectors |
| @texuli/charts/heading | setChartTitleLevel: the heading rank a host gives flow, geo and part-whole chart titles (h3 without one) |
Data and math (framework-free TypeScript):
| Import | What it gives you |
| --- | --- |
| @texuli/charts, @texuli/charts/math | Every math export below, from one entry |
| @texuli/charts/math/scales | Linear, log, sqrt, time, band, point and ordinal scales; ticks and nice domains |
| @texuli/charts/math/shapes | Line, area and arc paths, pie, stack, bin and symbols |
| @texuli/charts/math/layout | Treemap, sunburst, pack, Sankey, funnel, gauge, calendar and matrix layouts |
| @texuli/charts/math/downsample | LTTB and min-max downsampling, bisectX |
| @texuli/charts/math/color | A sequential color fallback |
| @texuli/charts/streaming | Immutable, bounded append helpers for live numeric series |
| @texuli/charts/worker, @texuli/charts/worker/entry | Opt-in Web Worker offload for binning and downsampling very large series, with a main-thread fallback; load the entry with new Worker(new URL('@texuli/charts/worker/entry', import.meta.url), { type: 'module' }) |
New in 0.6.0
Ships in 0.6.0; the 0.5.0 release predates it: the chart components that
render a data-table fallback share one stylesheet per table look, so the
lazily loaded chart CSS fell from 34,528 to 29,731 B raw. No API change.
New in 0.5.0
Ships in 0.5.0; the 0.4.0 release predates it:
- New subpath
@texuli/charts/sparkline-lite: a lightSparklinewith the same props, without the data table (charts-sparkline-lite). RampLegendin@texuli/charts/matrix(charts-matrix).formatValue(value)on the compactSparkline,BulletChart,GaugeandProgressRing; it wins overformat(charts-compact).
Key guarantees
- Accessible by default. Every chart has
role="img", a title and a description, plus a data-table fallback: a Show data table button on the cartesian family and adetailsdisclosure everywhere else (except the lightSparkline, which keeps the name and description and drops the table by design). Cartesian charts (and matrix charts withinteractive) add a keyboard explorer: arrow keys, Home/End, Page Up/Down between series, Escape to dismiss. - Right-to-left ready. Captions, legends and tables follow the page direction; each plot keeps a left-to-right coordinate system.
- Themeable. Series colors default to the
--tx-chart-*tokens, so charts follow the active Texuli theme; the full-size families also take amodeoflightordark. - No third-party chart library. The scales, shapes and layouts are written in-house as plain TypeScript.
- Bounded on large data.
Sparklinedraws at most 2,000 samples (longer series fall back to min-max buckets so spikes survive),binmakes at most 1,000 bins, and statistical charts cap groups, outliers and density points. The cartesianrenderer="auto"mode switches to canvas at 5,000 points.
Documentation
- Site: texuli.com and the charts gallery
- Families: cartesian, part-whole, matrix, compact, light sparkline, flow, geo, histogram, pack, calendar, statistical
- Building blocks: axis, interaction and keyboard, annotations, canvas, title heading rank, colors, prop schemas
- Guides: large and streaming series, worker offload, right-to-left layouts
- Source: github.com/DailybotHQ/texuli · Issues: github.com/DailybotHQ/texuli/issues
Contributing
Contributions are welcome; start at the GitHub repository.
License
MIT © Dailybot, Inc. Powered by Dailybot.
