TroubleshootingCharts
Fix charts that render at the wrong size or without styles, dates plotted as categories, gaps in lines, slow large series, failed PNG exports and watermarks.
Charts log problems with the prefix [Birch UI Charts] and keep rendering with a fallback. Check the browser console first.
| Symptom | Jump to |
|---|---|
| The chart is 320 pixels tall, or collapses to nothing | The chart has the wrong height |
height must be a positive number or a CSS length… |
The chart has the wrong height |
| Legend, tooltip and axes are unstyled | The chart has no styles |
| Dates appear as evenly spaced labels | Dates are plotted as categories |
| A line has gaps, or a series is empty | A series has gaps or does not appear |
Canvas 2D is not available here… |
The chart renders as SVG |
toPNG() rejects |
PNG export fails |
| Large series are slow to update | Large series are slow |
| "Birch UI Charts · unlicensed copy" in the corner | A watermark appears |
Refused to apply inline style in the console |
A Content Security Policy blocks the styles |
| Two copies of a package, or a large bundle | Duplicate packages and bundle size |
| Problems only in React, Vue, Svelte or Angular | Framework adapters |
The chart has the wrong height#
Cause. The chart does not take its height from the container by default. Without a height option it is 320 pixels tall. A percentage such as height: '100%' fills the container, so it collapses when the container has no height of its own. A zero, negative or non-numeric height logs [Birch UI Charts] height must be a positive number or a CSS length; using 320px.
Fix. Pass a number of pixels or a CSS length, and give the container a height when you use a percentage:
createChart(document.querySelector<HTMLElement>('#monthly-orders')!, {
height: '100%',
data: monthlyOrders,
series: [{ type: 'line', xKey: 'month', yKey: 'orders' }],
});#monthly-orders {
height: 360px;
}The chart follows its container's width through ResizeObserver, including after a hidden tab becomes visible.
The chart has no styles#
Cause. With injectStyles: false, the chart does not add its stylesheet.
Fix. Import @birchui/charts/styles.css, or insert the exported chartStyles string into a shadow root yourself. See Themes and styles.
A Content Security Policy blocks the styles#
Cause. Injected styles are a <style> element, which a style-src policy without 'unsafe-inline' blocks. The injected element has no nonce option.
Fix. Set injectStyles: false and import @birchui/charts/styles.css through your bundler.
Dates are plotted as categories#
Cause. Without axes.x.type, the x axis type is inferred. Any bar or column series makes it a category axis, so dates get evenly spaced slots and missing days do not leave a gap. Strings that are not ISO dates, such as 'Mar 2026', also give a category axis.
Fix. Use Date objects, epoch milliseconds or ISO strings, and set the type when inference picks the wrong one:
createChart(container, {
data: dailyShipments,
series: [{ type: 'column', xKey: 'day', yKey: 'parcels' }],
axes: { x: { type: 'time' } },
});See How the x axis type is chosen.
A series has gaps or does not appear#
Cause. A null, undefined or non-numeric value leaves a gap in a line instead of drawing to zero. Numbers sent as strings, such as '1250.00' from a CSV, are non-numeric. A series whose xKey or yKey does not match the field names in data has no points.
Fix. Convert values to numbers when you load the data, and check that xKey and yKey match the field names exactly, including case. See Line.
The chart renders as SVG#
Cause. When a canvas 2D context is not available, for example in some test environments or locked-down browsers, the chart logs [Birch UI Charts] Canvas 2D is not available here; the chart is rendered as SVG instead.
Fix. Nothing is broken. The SVG renderer draws the same chart; it is slower for very large series.
PNG export fails#
Cause. toPNG() rejects when there is nothing to export yet, for example right after creation before the first frame, or when the browser cannot create or encode a canvas.
Fix. Export after the ready event or from a user action, and catch the rejection. Use toSVG() where a vector file works. See PNG.
Large series are slow#
Cause. Unsorted x values, ISO strings that must be parsed, animation between updates, decimation: false, or recreating the chart on every data change all add work for series with hundreds of thousands of points.
Fix. Sort by x once when you load the data, use numbers or Date objects for x, set animation: false, keep decimation on, and call setData() instead of destroying the chart. See Getting the most out of it.
A watermark appears#
Cause. The chart checks its key for charts offline. On a non-local host with no valid key, a watermark appears and one warning is logged, for example:
[Birch UI] No license key is set for Birch UI Charts. All features keep working; a watermark is shown on non-local hosts until a valid license key is set. Purchase a license at https://birchui.com/pricingFix. Call setLicenseKey from @birchui/license in the browser bundle, or pass licenseKey to createChart. With server rendering, expose the key through a public variable such as NEXT_PUBLIC_BIRCHUI_LICENSE_KEY; see The license key is not applied with server rendering and What happens without a valid key.
Duplicate packages and bundle size#
Cause. Two installed versions of @birchui/core or @birchui/license split their state, so a key set in one copy is not seen by the other.
Fix. Run npm ls @birchui/core @birchui/license, align all @birchui/* packages on one version and run npm dedupe, or add overrides in package.json. The package is side-effect free apart from its CSS.
Framework adapters#
Wrap a chart with createReactComponent(chartDefinition) or the equivalent factory. A new data or series array on every render resends it each time. See:
- The widget updates on every render
- The widget is created twice in development
- Vue makes large data slow and Svelte state makes large data slow
- Using charts in a framework