Birch UI v0.1
Pricing

SeriesCharts

Every chart type in Birch UI Charts, from line and area to bar, scatter, bubble, pie, donut, heatmap and combination charts, and the options each series takes.

Open .md

A chart draws one or more series. Each series names the keys it reads from the data with xKey and yKey and chooses how to draw them with type. The chart type follows from its series: put a line and two columns in the same chart and you get a combination chart.

Revenue by region and category

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-bar-pie.ts
import { createChart } from '@birchui/charts';
import { currency, docsTheme, layout, onDocsThemeChange } from './_shared';

export const meta = { title: 'Revenue by region and category', height: 440 };

interface RegionRevenue {
  region: string;
  q1: number;
  q2: number;
  q3: number;
  q4: number;
}

interface CategoryShare {
  category: string;
  revenue: number;
}

const regions: RegionRevenue[] = [
  { region: 'North America', q1: 1_910_000, q2: 1_987_000, q3: 2_048_000, q4: 2_212_000 },
  { region: 'Europe', q1: 2_716_000, q2: 2_624_000, q3: 2_703_000, q4: 2_890_000 },
  { region: 'Asia Pacific', q1: 1_869_000, q2: 1_967_000, q3: 2_201_000, q4: 2_334_000 },
  { region: 'Latin America', q1: 1_257_000, q2: 1_211_000, q3: 1_386_000, q4: 1_402_000 },
];

const categories: CategoryShare[] = [
  { category: 'Furniture', revenue: 12_480_000 },
  { category: 'Electronics', revenue: 15_930_000 },
  { category: 'Accessories', revenue: 4_310_000 },
];

const short = (value: unknown) => (typeof value === 'number' ? `$${(value / 1_000_000).toFixed(1)}M` : String(value));

export default function mount(el: HTMLElement): () => void {
  const { toolbar, body, status } = layout(el);
  body.style.display = 'grid';
  body.style.gridTemplateColumns = 'minmax(0, 3fr) minmax(0, 2fr)';
  const left = document.createElement('div');
  const right = document.createElement('div');
  left.style.minHeight = right.style.minHeight = '0';
  body.append(left, right);
  toolbar.append('Click a legend entry to hide a series. Click a bar or slice for its value.');

  const columns = createChart<RegionRevenue>(left, {
    title: 'Revenue by region, 2026',
    data: regions,
    series: (['q1', 'q2', 'q3', 'q4'] as const).map((quarter) => ({
      type: 'column' as const,
      xKey: 'region' as const,
      yKey: quarter,
      name: quarter.toUpperCase(),
    })),
    axes: { x: { type: 'category' }, y: { labelFormatter: short } },
    theme: docsTheme(),
    height: '100%',
  });
  const donut = createChart<CategoryShare>(right, {
    title: 'Share by category',
    data: categories,
    series: [{ type: 'donut', xKey: 'category', yKey: 'revenue', innerRadius: 0.55, labels: true }],
    theme: docsTheme(),
    height: '100%',
  });

  const offs = [
    columns.on('pointClick', ({ point }) => {
      status.textContent = `${String(point.x)}, ${point.seriesName}: ${currency.format(Number(point.y))}`;
    }),
    donut.on('pointClick', ({ point }) => {
      status.textContent = `${String(point.x)}: ${currency.format(Number(point.y))}`;
    }),
    columns.on('legendToggle', ({ name, visible }) => {
      status.textContent = `${name} ${visible ? 'shown' : 'hidden'}`;
    }),
  ];
  status.textContent = 'Values appear here.';
  const stopTheme = onDocsThemeChange((theme) => {
    columns.update({ theme });
    donut.update({ theme });
  });
  return () => {
    for (const off of offs) off();
    stopTheme();
    columns.destroy();
    donut.destroy();
  };
}

Series types#

type Keys Draws
line xKey, yKey A line, with optional markers, curves and steps
area xKey, yKey A filled area under a line, optionally stacked
column, bar xKey, yKey Bars, grouped by default, optionally stacked or horizontal
scatter xKey, yKey One marker per datum
bubble xKey, yKey, sizeKey Markers whose area is proportional to sizeKey
pie, donut xKey (label), yKey (value) Slices, with outside labels; donuts show the total in the center
heatmap xKey, yKey (categories), colorKey (value) A grid of cells on a sequential color ramp

Every series also accepts:

Option Meaning
id Stable identifier for the API and events. Defaults to yKey; duplicates get a suffix.
name Label in the legend, tooltip and accessible summary. Defaults to yKey.
color Overrides the palette color for this series.
data Rows for this series only, instead of the chart's data.
visible false starts the series hidden; users can show it from the legend.
yAxis The ID of the value axis to plot against, for example 'right'. See Axes.

Series with an unknown type, without string xKey and yKey, or a heatmap without colorKey are skipped with a console.warn naming the problem.

SeriesOptionsinterface@birchui/chartsFull reference
PropertyTypeDescription
typeSeriesType—
xKeyDataKey<TDatum>—
yKeyDataKey<TDatum>—
sizeKeyoptionalDataKey<TDatum>—
colorKeyoptionalDataKey<TDatum>—
idoptionalstring—
nameoptionalstring—
coloroptionalstring—
dataoptionalreadonly TDatum[]—
visibleoptionalboolean—
stackedoptionalStackMode—
stackGroupoptionalstring—
yAxisoptionalstring—
horizontaloptionalboolean—
curveoptionalCurveType—
markersoptionalboolean | MarkerOptions—
lineWidthoptionalnumber—
fillOpacityoptionalnumber—
innerRadiusoptionalnumber—
labelsoptionalboolean—
decimationoptionalboolean—

Line#

monthly-orders.ts
import { createChart } from '@birchui/charts';

const orders = [
  { month: '2026-01-01', online: 1840, retail: 1210, wholesale: 420 },
  { month: '2026-02-01', online: 1925, retail: 1180, wholesale: 455 },
  { month: '2026-03-01', online: 2210, retail: 1295, wholesale: null },
  { month: '2026-04-01', online: 2380, retail: 1340, wholesale: 510 },
  { month: '2026-05-01', online: 2465, retail: 1405, wholesale: 530 },
];

createChart(document.querySelector<HTMLElement>('#orders')!, {
  title: 'Monthly orders by channel',
  data: orders,
  series: [
    { type: 'line', xKey: 'month', yKey: 'online', name: 'Online', curve: 'smooth', markers: true },
    { type: 'line', xKey: 'month', yKey: 'retail', name: 'Retail', markers: { size: 6, shape: 'square' } },
    { type: 'line', xKey: 'month', yKey: 'wholesale', name: 'Wholesale', curve: 'step', lineWidth: 1.5 },
  ],
});
Option Values Default
curve 'linear', 'smooth', 'step', 'stepBefore', 'stepAfter' 'linear'
markers true, false or { enabled, size, shape } with shape one of 'circle', 'square', 'diamond', 'triangle' Automatic: shown when points are at least 18 pixels apart, hidden on dense or decimated lines and on areas. Size 8, circles.
lineWidth Stroke width in pixels theme default
decimation false turns off min/max decimation for long lines on

A missing value (null, undefined or a non-numeric value) leaves a gap in the line rather than drawing to zero, as with the March wholesale figure above. Lines with many more points than pixels are decimated automatically; see Large data.

Area#

Areas take every line option plus fillOpacity and stacked.

sessions-by-channel.ts
createChart(document.querySelector<HTMLElement>('#sessions')!, {
  title: 'Website sessions by channel',
  data: dailySessions,
  series: [
    { type: 'area', xKey: 'date', yKey: 'organic', name: 'Organic search', stacked: true },
    { type: 'area', xKey: 'date', yKey: 'paid', name: 'Paid search', stacked: true },
    { type: 'area', xKey: 'date', yKey: 'referral', name: 'Referral', stacked: true },
    { type: 'area', xKey: 'date', yKey: 'direct', name: 'Direct', stacked: true, fillOpacity: 0.5 },
  ],
});

Stacking#

Bars and areas stack when stacked is set:

stacked Result
true or 'normal' Values are added on top of each other
'percent' Each category is scaled to 100%, showing shares; the value axis reads 0 to 100%
false (default) Bars are grouped side by side; areas overlap

Series stack together when they have the same kind (bar or area), the same yAxis, the same stackGroup and the same stacking mode. Use stackGroup to draw several stacks side by side:

TypeScript
import type { SeriesOptions } from '@birchui/charts';

const series: SeriesOptions[] = [
  { type: 'column', xKey: 'quarter', yKey: 'newBusiness2025', name: 'New business 2025', stacked: true, stackGroup: '2025' },
  { type: 'column', xKey: 'quarter', yKey: 'renewals2025', name: 'Renewals 2025', stacked: true, stackGroup: '2025' },
  { type: 'column', xKey: 'quarter', yKey: 'newBusiness2026', name: 'New business 2026', stacked: true, stackGroup: '2026' },
  { type: 'column', xKey: 'quarter', yKey: 'renewals2026', name: 'Renewals 2026', stacked: true, stackGroup: '2026' },
];

Column and bar#

column and bar are interchangeable names for the same bar series. Both draw vertical bars; set horizontal: true for horizontal bars. If any bar series in a chart is horizontal, the whole chart is drawn horizontally, with categories on the vertical axis.

revenue-by-region.ts
const revenueByRegion = [
  { region: 'North America', q1: 1_265_000, q2: 1_511_000 },
  { region: 'Europe', q1: 865_000, q2: 1_005_000 },
  { region: 'Asia Pacific', q1: 731_000, q2: 802_000 },
  { region: 'Latin America', q1: 214_000, q2: 249_000 },
];

createChart(document.querySelector<HTMLElement>('#regions')!, {
  title: 'Revenue by region',
  data: revenueByRegion,
  series: [
    { type: 'bar', xKey: 'region', yKey: 'q1', name: 'Q1', horizontal: true },
    { type: 'bar', xKey: 'region', yKey: 'q2', name: 'Q2', horizontal: true },
  ],
});

A chart with bars uses a category x axis by default, even for dates, so each date gets its own evenly spaced bar. Set axes: { x: { type: 'time' } } to place bars on a time scale instead.

Scatter and bubble#

deal-size.ts
const deals = [
  { daysToClose: 18, value: 24_000, seats: 40, owner: 'Amira Haddad' },
  { daysToClose: 45, value: 96_000, seats: 180, owner: 'Lukas Brandt' },
  { daysToClose: 31, value: 52_000, seats: 75, owner: 'Priya Nair' },
  { daysToClose: 62, value: 148_000, seats: 320, owner: 'Diego Alvarez' },
];

createChart(document.querySelector<HTMLElement>('#deals')!, {
  title: 'Deal value by sales cycle',
  data: deals,
  series: [{ type: 'bubble', xKey: 'daysToClose', yKey: 'value', sizeKey: 'seats', name: 'Closed deals' }],
  axes: { x: { title: 'Days to close' }, y: { title: 'Deal value (USD)' } },
});

A scatter series draws one marker per datum and takes the same markers options as lines. A bubble series sizes each marker so that its area, not its radius, is proportional to sizeKey, which keeps large values from looking exaggerated. Numeric x values give a linear x axis.

Pie and donut#

sales-by-channel.ts
createChart(document.querySelector<HTMLElement>('#channels')!, {
  title: 'Sales by channel',
  subtitle: 'Q2 2026',
  data: [
    { channel: 'Online store', revenue: 1_842_000 },
    { channel: 'Retail partners', revenue: 1_120_000 },
    { channel: 'Field sales', revenue: 764_000 },
    { channel: 'Marketplaces', revenue: 412_000 },
  ],
  series: [{ type: 'donut', xKey: 'channel', yKey: 'revenue', name: 'Revenue' }],
});
  • xKey is the slice label and yKey the slice value.
  • A donut has an inner radius of 60% of the outer radius by default; set innerRadius (0 to 1) to change it. A pie with an innerRadius above 0 is drawn as a donut. Donuts show the total in the center.
  • Slice labels are placed outside the pie and moved apart so they never overlap. Set labels: false to hide them.
  • Each slice has its own legend entry, and clicking one hides that slice. setSeriesVisible(label, false) does the same from code.
  • A pie or donut chart draws one series. If you add more, the first pie or donut series is used and the console warns that the others were ignored.

Heatmap#

A heatmap shows a value for each pair of categories. xKey and yKey name the two category keys, and colorKey the numeric value.

ticket-heatmap.ts
const weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
const hours = ['08:00', '10:00', '12:00', '14:00', '16:00'];

const tickets = weekdays.flatMap((day, d) =>
  hours.map((hour, h) => ({ day, hour, tickets: 12 + ((d * 7 + h * 11) % 37) })),
);

createChart(document.querySelector<HTMLElement>('#support-load')!, {
  title: 'Support tickets by hour',
  data: tickets,
  series: [{ type: 'heatmap', xKey: 'hour', yKey: 'day', colorKey: 'tickets', name: 'Tickets' }],
});

Cells are colored on the sequential ramp from --lq-chart-heat-1 to --lq-chart-heat-4, with a gradient legend. Values are printed in cells that are at least 34 by 18 pixels; set labels: false to hide them. Like pies, a heatmap chart draws one heatmap series.

Combination charts#

Mix bar, line, area and scatter series in one chart. Give a series yAxis: 'right' to plot it on a secondary value axis:

revenue-and-margin.ts
const months = [
  { month: 'Jan', revenue: 896_000, margin: 0.312 },
  { month: 'Feb', revenue: 878_000, margin: 0.298 },
  { month: 'Mar', revenue: 987_000, margin: 0.335 },
  { month: 'Apr', revenue: 1_034_000, margin: 0.341 },
];

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

createChart(document.querySelector<HTMLElement>('#revenue-margin')!, {
  title: 'Revenue and gross margin',
  data: months,
  series: [
    { type: 'column', xKey: 'month', yKey: 'revenue', name: 'Revenue' },
    { type: 'line', xKey: 'month', yKey: 'margin', name: 'Gross margin', yAxis: 'right', markers: true },
  ],
  axes: {
    y: [
      { id: 'left', labelFormatter: (v) => usd.format(Number(v)) },
      { id: 'right', position: 'right', labelFormatter: (v) => percent.format(Number(v)), gridLines: false },
    ],
  },
});

There is no separate combo type: the combination comes from the series you list. Pie, donut and heatmap series cannot be combined with other series.

Changing series at runtime#

TypeScript
chart.setSeries([...chart.getOptions().series, { type: 'line', xKey: 'month', yKey: 'target', name: 'Target' }]);

chart.setSeriesVisible('retail', false);
chart.isSeriesVisible('retail');

setSeries() and setData() animate from the old values to the new ones over 450 ms; pass animation: false or animation: { duration: 200 } to change that. Animation is skipped when the user prefers reduced motion.

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