Birch UI v0.1
Pricing

Birch UI Charts overviewCharts

Fast, accessible canvas charts for line, area, bar, column, scatter, bubble, pie, donut, heatmap and combination charts, with SVG and PNG export and grid integration.

Open .md

Birch UI Charts draws fast, accessible charts on a canvas: line, area, column and bar, scatter and bubble, pie and donut, heatmaps, combination charts with a secondary axis, and sparklines for grid cells. Every chart exports to SVG and PNG, lines with a million points render in a fraction of a second, and a range selected in Grid Pro can become a chart in one call.

It is written in plain TypeScript and follows the same widget contract as every Birch UI component, so it works in any framework.

One million telemetry points

Loading demo…

View source

Sample data and small UI helpers are imported from the docs' demos/_shared.ts and demos/_scheduler-data.ts files.

demos/chart-large-line.ts
import { createChart } from '@birchui/charts';
import { button, docsTheme, layout, onDocsThemeChange, seededRandom } from './_shared';

export const meta = { title: 'One million telemetry points', height: 460 };

interface Reading {
  time: number;
  temperature: number;
}

const POINT_COUNT = 1_000_000;
const START = Date.UTC(2026, 9, 1);
const INTERVAL_MS = 2_000;

function makeReadings(): Reading[] {
  const random = seededRandom(17);
  const readings: Reading[] = new Array(POINT_COUNT);
  let value = 21;
  for (let i = 0; i < POINT_COUNT; i++) {
    const daily = Math.sin((i / 43_200) * Math.PI * 2) * 2.5;
    value += (random() - 0.5) * 0.08 - (value - 21) * 0.0005;
    const spike = random() < 0.00002 ? 6 + random() * 4 : 0;
    readings[i] = { time: START + i * INTERVAL_MS, temperature: Math.round((value + daily + spike) * 100) / 100 };
  }
  return readings;
}

export default function mount(el: HTMLElement): () => void {
  const { toolbar, body, status } = layout(el);
  const generated = performance.now();
  const data = makeReadings();
  const started = performance.now();
  const chart = createChart<Reading>(body, {
    title: 'Cold storage unit 4: temperature',
    subtitle: `${POINT_COUNT.toLocaleString()} readings, one every 2 seconds`,
    data,
    series: [{ type: 'line', xKey: 'time', yKey: 'temperature', name: 'Temperature (°C)', decimation: true }],
    axes: { x: { type: 'time' }, y: { title: '°C' } },
    zoom: true,
    legend: false,
    theme: docsTheme(),
    height: '100%',
  });
  const rendered = Math.round(performance.now() - started);
  status.textContent = `Generated in ${Math.round(started - generated)} ms, first render in ${rendered} ms. Drag across the plot to zoom.`;
  toolbar.append(
    button('Zoom to first day', () => chart.setZoom([START, START + 86_400_000])),
    button('Reset zoom', () => chart.resetZoom()),
    button('Download PNG', () => {
      chart.download('png', 'cold-storage-unit-4').catch((error: Error) => {
        status.textContent = `Export failed: ${error.message}`;
      });
    }),
  );
  const offZoom = chart.on('zoomChange', ({ range, source }) => {
    status.textContent = range
      ? `Showing ${new Date(range[0]).toISOString().slice(0, 16)} to ${new Date(range[1]).toISOString().slice(0, 16)} UTC (${source})`
      : 'Showing the full range.';
  });
  const stopTheme = onDocsThemeChange((theme) => chart.update({ theme }));
  return () => {
    offZoom();
    stopTheme();
    chart.destroy();
  };
}

Install#

Terminal
npm install @birchui/core @birchui/charts

@birchui/core provides the shared widget contract and style helpers; @birchui/license comes along as a dependency. The charts package is about 38 KB minified and gzipped, not counting those two.

A first chart#

revenue-chart.ts
import { createChart } from '@birchui/charts';

interface MonthlyRevenue {
  month: string;
  northAmerica: number;
  europe: number;
  asiaPacific: number;
}

const revenue: MonthlyRevenue[] = [
  { month: 'Jan', northAmerica: 412_000, europe: 288_000, asiaPacific: 196_000 },
  { month: 'Feb', northAmerica: 398_000, europe: 276_000, asiaPacific: 204_000 },
  { month: 'Mar', northAmerica: 455_000, europe: 301_000, asiaPacific: 231_000 },
  { month: 'Apr', northAmerica: 471_000, europe: 319_000, asiaPacific: 244_000 },
];

const usd = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', notation: 'compact' });

const chart = createChart<MonthlyRevenue>(document.querySelector<HTMLElement>('#revenue')!, {
  title: 'Monthly revenue by region',
  subtitle: 'Fiscal year 2026, USD',
  data: revenue,
  series: [
    { type: 'column', xKey: 'month', yKey: 'northAmerica', name: 'North America' },
    { type: 'column', xKey: 'month', yKey: 'europe', name: 'Europe' },
    { type: 'column', xKey: 'month', yKey: 'asiaPacific', name: 'Asia Pacific' },
  ],
  axes: { y: { labelFormatter: (value) => usd.format(Number(value)) } },
});

chart.on('pointClick', ({ point }) => console.info(point.seriesName, point.datum.month, point.y));
index.html
<div id="revenue"></div>

The chart fills the width of its container and follows it as it resizes. Its height is 320 pixels by default; set height to a number of pixels or any CSS length. A percentage such as '100%' makes the chart fill a container that has its own height.

xKey and yKey are typed against your datum type, so a misspelled key is a compile error.

The widget contract#

createChart(container, options) returns a ChartApi. Like every Birch UI widget it has:

Member Description
element The chart's root element
update(partial) Apply only the options you pass. Data and series changes animate.
on(event, listener) Subscribe to an event; returns an unsubscribe function
destroy() Remove the chart and release every listener, observer and animation frame

On top of that it adds data, zoom, visibility and export methods. See the API reference.

TypeScript
chart.update({ theme: 'dark', subtitle: 'Fiscal year 2026, USD, updated hourly' });
chart.setData(await fetchRevenue());
chart.setSeries(chart.getOptions().series.map((series) => ({ ...series, stacked: true })));

chartDefinition describes the widget for framework adapters and custom elements: its name is BirchChart, its tag name birchui-chart, and its events are ready, pointClick, legendToggle, zoomChange and seriesHover.

createChart() throws a TypeError only for programmer errors: a missing container or a missing options object. Invalid series, unknown series types and bad option values produce one console.warn each and are skipped or replaced with a safe default, and errors thrown in your callbacks (formatters, renderers) are reported with console.error without breaking the chart.

Themes and styles#

theme is 'light', 'dark' or 'auto'. It defaults to 'auto', which follows the user's prefers-color-scheme. The root element gets the class lq-chart-theme-light, lq-chart-theme-dark or lq-chart-theme-auto.

Colors come from CSS custom properties read from the chart's computed style: the shared --lq-* properties (--lq-fg, --lq-bg, --lq-muted-fg, --lq-border, --lq-accent, --lq-font-family, --lq-font-size and others), plus chart-specific ones:

Property Used for
--lq-chart-grid Grid lines
--lq-chart-color-1 … --lq-chart-color-8 The categorical series palette
--lq-chart-heat-1 … --lq-chart-heat-4 The sequential heatmap ramp
--lq-chart-tooltip-shadow Tooltip shadow

Override them in CSS, or pass palette: ['#…', …] to set series colors directly. A series color always wins.

CSS
.lq-chart.lq-chart-theme-light {
  --lq-chart-color-1: #0a6c9e;
  --lq-chart-color-2: #b54708;
}

Styles are injected into the document head the first time a chart is created. Set injectStyles: false and import @birchui/charts/styles.css to ship them in your own bundle; the CSS is also exported as the string chartStyles.

Licensing#

Every chart checks for a license when it is created by calling checkLicense('charts', { key, host }) from @birchui/license. The check runs entirely in the browser; no network request is ever made.

  • Pass the key with the licenseKey option, or set it once for the whole app with setLicenseKey(key) from @birchui/license. Charts created without an explicit licenseKey pick up a key set later, without being recreated.
  • Without a valid key, every feature keeps working. The chart shows a small "unlicensed copy" watermark and the console shows one warning per page load.
  • On localhost and other local development hosts, the watermark is not shown, so you can evaluate and develop without a key.
  • Changing licenseKey through update() re-runs the check.
TypeScript
import { setLicenseKey } from '@birchui/license';

setLicenseKey(import.meta.env.VITE_BIRCHUI_LICENSE_KEY);

See Licensing & activation for key formats, seats and how updates work, and Pricing for every product.

Using charts in a framework#

The framework adapters do not ship a ready-made chart component, and there is no /charts subpath. Each adapter exports the generic factory it uses for its own components. Pass it chartDefinition and you get a component that creates the chart on mount, sends changed props to update() and forwards every chart event.

TypeScript
import { createChart } from '@birchui/charts';

const chart = createChart(document.getElementById('sessions')!, {
  title: 'Website sessions',
  data: sessions,
  series: [{ type: 'line', xKey: 'date', yKey: 'sessions', name: 'Sessions' }],
});

chart.on('pointClick', ({ point }) => openDay(point.datum.date));

Notes per adapter:

  • React and Solid: options are props, events are on… props (onPointClick, onZoomChange), and ref gives you the ChartApi.
  • Vue: pass options as attributes (kebab-case is converted to camelCase) or as an options object. Events are kebab-case (@point-click, @zoom-change).
  • Angular: injectBirchWidget needs one output per chart event, which is why the wrapper declares all five. Read the instance from api after the first render.
  • Svelte: createSvelteAction gives you an action. Its parameter is the options plus on (handlers keyed by event name) and onReady (called once with the API).
  • Web Component: createElementClass turns the definition into a custom element. optionKeys become properties, attributes are observed and converted to camelCase options, and requiredOptions: ['series'] waits for series before creating the chart. Option names that already exist on HTMLElement, such as title, do not become properties; set them with element.set('title', …). Events are kebab-case CustomEvents with the payload in detail, and element.api is the ChartApi. Define the element in the browser only; the class needs a DOM.

Next steps#

  • Series: every chart type and its options.
  • Axes: category, linear, log and time axes, and secondary axes.
  • Interaction: tooltips, legend, zoom and pan.
  • Large data: a million points in a line chart.
  • Grid integration: charts from Grid Pro ranges and sparklines in cells.

↑ ↓ to move, Enter to open, Esc to close