Diagram
import { Diagram } from "cx-diagrams"The Diagram component is used to mark the area of the diagram and provide zooming and panning functions. It’s required that all diagrams use this component as a top-level parent element.
import { Diagram } from "cx-diagrams"The Diagram component is used to mark the area of the diagram and provide zooming and panning functions. It’s required that all diagrams use this component as a top-level parent element.
<Svg class="w-auto h-full bg-white">
<Diagram
unitSize={32}
showGrid
zoom={bind("$page.view.zoom")}
offsetX={bind("$page.view.offsetX")}
offsetY={bind("$page.view.offsetY")}
center
>
<Flow gap={1}>
<Cell width={4} height={2}>
<Shape stroke="red" fill="white" text="Red" />
</Cell>
<Cell width={4} height={2}>
<Shape stroke="blue" fill="white" text="Blue" />
</Cell>
</Flow>
</Diagram>
</Svg>
<div
class="absolute border bottom-2 left-2 bg-white text-[10px] uppercase p-1"
text={tpl("Zoom: {$page.view.zoom:p;0} Center ({$page.view.offsetX:n;0}, {$page.view.offsetY:n;0})")}
/> | Property | Description | Type |
|---|---|---|
center | Set to | boolean |
offsetX | Horizontal offset (pan). | number |
offsetY | Vertical offset (pan). | number |
zoom | Current zoom level. Default value is 1. | number |
centerX | Set to | boolean |
centerY | Set to | boolean |
fixed | Set to | boolean |
showGrid | Set to | boolean |
unitSize | Size of the grid unit in pixels. Default is 32. | number |