Import these from @grafloria/renderer.
Functions
attachCanvasPlugins
tsfunction attachCanvasPlugins(
instance: CanvasPluginHost,
options: CanvasPluginOptions = {}
): CanvasPlugins
createBackground
Create the background grid inside root, tracking viewport.
tsfunction createBackground(
root: HTMLElement,
viewport: ViewportController,
options: BackgroundOptions = {}
): BackgroundHandle
createControls
tsfunction createControls(
root: HTMLElement,
viewport: ViewportController,
options: ControlsOptions = {}
): ControlsHandle
createMiniMap
tsfunction createMiniMap(
root: HTMLElement,
viewport: ViewportController,
getModel: () => DiagramModel,
options: MiniMapOptions = {}
): MiniMapHandle
Constants
BACKGROUND_LAYER_CLASS
tsconst BACKGROUND_LAYER_CLASS: "grafloria-background-layer"
Interfaces
BackgroundHandle
tsinterface BackgroundHandle
Properties
| Name | Type | Default | Description |
|---|---|---|---|
element | SVGSVGElement |
Members
update(options: Partial<BackgroundOptions>): void— Change any option; re-renders immediately.setVisible(visible: boolean): void— Show/hide without tearing down (this is whatgridEnableddrives).isVisible(): booleandispose(): void
BackgroundOptions
tsinterface BackgroundOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
variant? | BackgroundVariant | Pattern style. Default 'dots'. | |
gap? | number | Grid spacing in WORLD units. Default 20. | |
size? | number | Dot radius / line thickness in CSS px. Default 1 (dots) or 1 (lines). | |
color? | string | Pattern colour. Default a theme-neutral grey. | |
backgroundColor? | string | Page colour painted under the pattern. Default transparent. | |
majorEvery? | number | Draw a heavier line every N cells (graph-paper look). 0 = off (default). Only meaningful for 'lines' / 'cross'. | |
majorColor? | string | Colour of the major lines. Defaults to color at higher opacity. | |
minZoom? | number | Hide the grid below this zoom, so it does not turn into visual mud when you zoom way out. Default 0.25. Set 0 to always draw. | |
idSuffix? | string | Unique-ish suffix for the pattern id, when several diagrams share a page. |
CanvasPluginHost
The structural surface the plugins actually need. DiagramInstance
satisfies it; so does any framework canvas that keeps a live
ViewportController (the Angular wrapper builds exactly this adapter).
tsinterface CanvasPluginHost
Properties
| Name | Type | Default | Description |
|---|---|---|---|
container | HTMLElement | ||
viewport | DiagramInstance['viewport'] |
Members
getModel(): DiagramModelgetEngine(): DiagramEnginefitView(padding?: number): void
CanvasPluginOptions
tsinterface CanvasPluginOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
background? | boolean | BackgroundOptions | Background grid. true = defaults; an object = options; omitted/false = off. When the engine's gridEnabled flag is present it OVERRIDES visibility. | |
minimap? | boolean | MiniMapOptions | MiniMap. Visibility is additionally gated by the store's showMinimap. | |
controls? | boolean | ControlsOptions | Zoom/fit/lock toolbar. | |
bindToStore? | boolean | Honour DiagramStore.gridEnabled / showMinimap and keep them in sync. Default true — this is what makes the flags real. Turn it off if you want the component visibility to be purely declarative. |
CanvasPlugins
tsinterface CanvasPlugins
Properties
| Name | Type | Default | Description |
|---|---|---|---|
background? | BackgroundHandle | ||
minimap? | MiniMapHandle | ||
controls? | ControlsHandle | ||
dispose | Disposer |
ControlsHandle
tsinterface ControlsHandle
Properties
| Name | Type | Default | Description |
|---|---|---|---|
portal | Portal | ||
element | HTMLElement |
Members
setVisible(visible: boolean): voidisVisible(): booleansetLocked(locked: boolean): void— Reflect a lock state changed elsewhere (keepsaria-pressedhonest).dispose(): void
ControlsOptions
tsinterface ControlsOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
placement? | PortalPlacement | ||
offset? | number | ||
showZoom? | boolean | Which buttons to show. Default: all except lock. | |
showFitView? | boolean | ||
showLock? | boolean | ||
orientation? | 'vertical' | 'horizontal' | Lay the buttons out horizontally instead of vertically. | |
zoomStep? | number | Zoom step per click (multiplicative). Default 1.2. | |
onFitView? | () | Called when "fit view" is pressed. Wire this to instance.fitView(). | |
onToggleLock? | (locked: boolean) | Called when the lock is toggled. Return/ignore as you like. | |
locked? | boolean | Initial lock state. |
MiniMapHandle
tsinterface MiniMapHandle
Properties
| Name | Type | Default | Description |
|---|---|---|---|
portal | Portal | ||
element | SVGSVGElement |
Members
refresh(): void— Rebuild the node layer (call when the model changed).setVisible(visible: boolean): voidisVisible(): booleanupdate(options: Partial<MiniMapOptions>): voiddispose(): void
MiniMapOptions
tsinterface MiniMapOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
placement? | PortalPlacement | ||
offset? | number | ||
width? | number | ||
height? | number | ||
padding? | number | Padding (world units) around the content in the minimap's viewBox. | |
nodeColor? | string | ((node: NodeModel) | Node fill. A function lets you colour-code by type/state. | |
maskColor? | string | Fill of the camera rectangle. | |
maskStroke? | string | Stroke of the camera rectangle. | |
panelBackground? | string | ||
panelBorder? | string | ||
interactive? | boolean | Allow click/drag-to-pan and wheel-to-zoom. Default true. | |
showLinks? | boolean | Draw links too. Default false (nodes carry the shape of a diagram). | |
linkColor? | string | ||
ariaLabel? | string | ARIA label on the panel. |
Types
BackgroundVariant
tstype BackgroundVariant = 'dots' | 'lines' | 'cross' | 'none';
Was this page helpful?