# Troubleshooting

> 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](#the-chart-has-the-wrong-height) |
| `height must be a positive number or a CSS length…` | [The chart has the wrong height](#the-chart-has-the-wrong-height) |
| Legend, tooltip and axes are unstyled | [The chart has no styles](#the-chart-has-no-styles) |
| Dates appear as evenly spaced labels | [Dates are plotted as categories](#dates-are-plotted-as-categories) |
| A line has gaps, or a series is empty | [A series has gaps or does not appear](#a-series-has-gaps-or-does-not-appear) |
| `Canvas 2D is not available here…` | [The chart renders as SVG](#the-chart-renders-as-svg) |
| `toPNG()` rejects | [PNG export fails](#png-export-fails) |
| Large series are slow to update | [Large series are slow](#large-series-are-slow) |
| "Birch UI Charts · unlicensed copy" in the corner | [A watermark appears](#a-watermark-appears) |
| `Refused to apply inline style` in the console | [A Content Security Policy blocks the styles](#a-content-security-policy-blocks-the-styles) |
| Two copies of a package, or a large bundle | [Duplicate packages and bundle size](#duplicate-packages-and-bundle-size) |
| Problems only in React, Vue, Svelte or Angular | [Framework adapters](#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:

```ts
createChart(document.querySelector<HTMLElement>('#monthly-orders')!, {
  height: '100%',
  data: monthlyOrders,
  series: [{ type: 'line', xKey: 'month', yKey: 'orders' }],
});
```

```css
#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](https://docs.birchui.com/charts/overview.md#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:

```ts
createChart(container, {
  data: dailyShipments,
  series: [{ type: 'column', xKey: 'day', yKey: 'parcels' }],
  axes: { x: { type: 'time' } },
});
```

See [How the x axis type is chosen](https://docs.birchui.com/charts/axes.md#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](https://docs.birchui.com/charts/series.md#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](https://docs.birchui.com/charts/export.md#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](https://docs.birchui.com/charts/large-data.md#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:

```text
[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/pricing
```

**Fix.** 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](https://docs.birchui.com/frameworks/troubleshooting.md#the-license-key-is-not-applied-with-server-rendering) and [What happens without a valid key](https://docs.birchui.com/getting-started/licensing.md#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](https://docs.birchui.com/frameworks/troubleshooting.md#the-widget-updates-on-every-render)
- [The widget is created twice in development](https://docs.birchui.com/frameworks/troubleshooting.md#the-widget-is-created-twice-in-development)
- [Vue makes large data slow](https://docs.birchui.com/frameworks/troubleshooting.md#vue-makes-large-data-slow) and [Svelte state makes large data slow](https://docs.birchui.com/frameworks/troubleshooting.md#svelte-state-makes-large-data-slow)
- [Using charts in a framework](https://docs.birchui.com/charts/overview.md#using-charts-in-a-framework)

## Related

- [API reference: @birchui/charts](https://docs.birchui.com/api/charts.md)
- [Large data](https://docs.birchui.com/charts/large-data.md)
