TroubleshootingDiagram
Fix a small or unstyled diagram canvas, nodes piled at the origin, missing edges and ports, lost undo history in frameworks, export differences, watermarks and slow large graphs.
The diagram never throws on bad data. It skips or repairs what it cannot use and logs a warning with the prefix [Birch UI Diagram], so check the console first.
| Symptom | Jump to |
|---|---|
| The canvas is a 240 pixel strip | The canvas is too small |
| Nodes and edges are unstyled | The diagram has no styles |
| Every node sits on top of the others | All nodes are at the same position |
ignoring edge … because it refers to a missing node |
An edge or node is missing |
unknown node type "…" |
A node renders with the wrong shape |
… has an invalid or duplicate port… |
A port is missing |
| A connection is refused | A connection is refused |
| Undo history clears in React, Vue or Svelte | Undo history clears after every edit |
| PNG export looks different from the screen | Exports do not match the screen |
| "Birch UI Diagram · 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 |
| Large graphs are slow | Large graphs are slow |
The canvas is too small#
Cause. Without width and height, the diagram root fills its container (height: 100%) with a minimum height of 240 pixels. A container without a height gives that minimum.
Fix. Give the container a height, or pass fixed width and height in pixels:
createDiagram(document.querySelector<HTMLElement>('#purchase-approval')!, {
ariaLabel: 'Purchase approval workflow',
height: 560,
nodes,
edges,
});width and height accept numbers only; use CSS on the container for lengths such as calc(100vh - 120px). A diagram in a hidden tab re-measures through ResizeObserver when it becomes visible; call zoomToFit() then if the initial fit happened at zero size.
The diagram has no styles#
Cause. With injectStyles: false, the diagram does not add its stylesheet.
Fix. Import @birchui/diagram/styles.css, or insert the exported diagramStyles string into a shadow root yourself. See Importing the CSS file.
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/diagram/styles.css through your bundler.
All nodes are at the same position#
Cause. Nodes are placed at their x and y. Data without coordinates, or with x: 0, y: 0 for every node, stacks them at the origin. A node without finite coordinates logs node "…" needs finite x and y; placing it at 0.
Fix. Run auto-layout once and store the positions:
await diagram.layout({ type: 'layered' });See Layout types.
An edge or node is missing#
Cause. The model is validated when it loads:
[Birch UI Diagram] ignoring duplicate node id "manager"
[Birch UI Diagram] ignoring edge "manager-finance" because it refers to a missing node
[Birch UI Diagram] ignoring edge without id: edges need an id, a source and a target
[Birch UI Diagram] node "erp" has an invalid parent "systems"; making it top-levelFix. Give every node and edge a unique string id, and point source.node and target.node at existing nodes. See Edges.
A node renders with the wrong shape#
Cause. A type that is neither built in nor registered in nodeTypes logs unknown node type "…"; rendering it as "…" once and falls back to the default type.
Fix. Register the type in nodeTypes, or use a built-in type. Type names are case-sensitive.
A port is missing#
Cause. Each port needs a unique id and a side. Otherwise the diagram logs node "…" has an invalid or duplicate port; ports need a unique id and a side of top, right, bottom, left and skips it. ports that is not an array logs node "…" has ports that are not an array; ignoring them.
Fix. Correct the port definitions. See Ports.
A connection is refused#
Cause. Self-loops, exact duplicates and targets with connectable: false are always refused. Everything else goes through validateConnection, and a readOnly diagram allows no edits.
Fix. Check the validateConnection callback with the source and target in the refused drag. See Connecting.
Undo history clears after every edit#
Cause. Passing a new nodes or edges array to a framework component reloads the document and clears the undo history. Feeding each change event back into those props does that on every edit.
Fix. Load once, let the diagram own the model, and keep your copy up to date from the change events or toJSON(). Pass new arrays only when you open a different diagram. See Loading and framework state and Changes to rows do not reach the widget.
Exports do not match the screen#
Cause. toPNG() never includes HTML node content, because drawing foreignObject onto a canvas taints it; HTML nodes fall back to their shape and label. toSVG() includes HTML as foreignObject unless you pass includeHtml: false.
Fix. Return SVG from the template when ctx.isExport is true. See Templates and export.
A watermark appears#
Cause. The diagram checks its key for diagram 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 Diagram. 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 createDiagram. 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.
Large graphs are slow#
Cause. Calling addNodes once per node, running layout on every load, force layout on large graphs and heavy node templates all add work.
Fix. Load the model once, batch API edits in arrays, store coordinates after one layout, prefer layered or tree, and keep templates light. See Guidelines for large graphs.
Framework adapters#
Wrap the diagram with createReactComponent(diagramDefinition) or the equivalent factory. See Framework troubleshooting for Strict Mode, Vue proxies, Svelte state and the Angular zone.