@btndprojects/loam-charts
v0.2.1
Published
Loam charts — the headless, platform-agnostic chart engine shared by @btndprojects/loam-ui-web and @btndprojects/loam-ui-native.
Readme
This package is headless: plain TypeScript, no React, no DOM, no device APIs. The Loam components (Chart and Charts on the web and on native) are built on it, and you can use it on its own — on a server, in a worker, or under your own UI.
Install
npm install @btndprojects/loam-chartsUsage
import { linePath, lttb, stackSeries } from '@btndprojects/loam-charts';
// SVG path data for a smooth line through screen-space points.
const d = linePath([[0, 10], [50, 30], [100, 20]], 'monotoneX');
// "M0,10C16.67,16.67 33.33,30 50,30C66.67,30 83.33,23.33 100,20"
// Downsample 10 000 points to 500, keeping the visual shape (Largest-Triangle-Three-Buckets).
const raw = Array.from({ length: 10_000 }, (_, i): [number, number] => [i, Math.sin(i / 200)]);
const points = lttb(raw, 500);
// Stack series for area and bar charts.
const stacked = stackSeries([
{ id: 'web', stack: 'total', data: [3, 5, 4] },
{ id: 'mobile', stack: 'total', data: [2, 1, 3] },
]);
stacked[1]?.stacked; // [[3, 5], [5, 6], [4, 7]]Documentation
Guides, live examples and the full API are on loam.btndprojects.com — start with Chart.
Related packages
@btndprojects/loam-ui-web— theChartcomponent@btndprojects/loam-ui-native— the nativeChartcomponent
License
MIT © Nuszpl Botond
