StraightLine
import { StraightLine } from "cx-diagrams"The StraightLine component is used to connect shapes with straight lines. Lines are drawn from shapes edges which allows simple placing of markers.
import { StraightLine } from "cx-diagrams"The StraightLine component is used to connect shapes with straight lines. Lines are drawn from shapes edges which allows simple placing of markers.
<Diagram unitSize={64} center showGrid>
<Flow gap={1} align="center">
<Cell>
<Shape fill="lightgray" text="1" id="1" />
</Cell>
<Flow direction="down" gap={1}>
<Cell>
<Shape fill="lightgray" text="2" id="2" />
</Cell>
<Cell>
<Shape fill="lightgray" text="3" id="3" />
</Cell>
<Cell>
<Shape fill="lightgray" text="4" id="4" />
</Cell>
</Flow>
<Flow direction="down" gap={1}>
<Cell>
<Shape fill="lightgray" text="5" id="5" shape="circle" />
</Cell>
<Cell>
<Shape fill="lightgray" text="6" id="6" shape="circle" />
</Cell>
<Cell>
<Shape fill="lightgray" text="7" id="7" shape="circle" />
</Cell>
</Flow>
<Cell>
<Shape fill="lightgray" text="8" id="8" shape="circle" />
</Cell>
<StraightLine from="1" to="2" stroke="black">
<Shape anchors="0 0 0 0" margin={-3} shape="circle" fill="white" stroke="blue" />
<Shape anchors="1 1 1 1" margin={-3} shape="circle" fill="white" stroke="blue" />
</StraightLine>
<StraightLine from="1" to="3" stroke="black">
<Shape anchors="0 0 0 0" margin={-3} shape="circle" fill="white" stroke="blue" />
<Shape anchors="1 1 1 1" margin={-3} shape="circle" fill="white" stroke="blue" />
</StraightLine>
...
</Flow>
</Diagram> | Property | Description | Type |
|---|---|---|
from | Id of the first (start) shape. | string |
stroke | Color of the line. | string |
strokeWidth | Line thickness. | string |
to | Id of the second (end) shape. | string |
anchors | Anchor defines how child bounds are tied to the parent. Zero aligns with the top/left edge. One aligns with the bottom/right edge. | string/number/rect |
class | Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list. | string/object |
items | List of child elements. | array |
layout | Define an inner layout. | string/object |
margin | Apply margin to the given boundaries. | string/number/rect |
mod | Appearance modifier. For example, | string/array |
offset | Move boundaries specified by the offset. | string/number/rect |
outerLayout | Defines the outer layout which wraps the widget. | widget |
padding | Padding to be applied to the boundaries rectangle before passing to the children. | string/number/rect |
plainText | Set to | boolean |
preserveWhitespace | Keep whitespace in text based children. Default is | boolean |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
trimWhitespace | Remove all whitespace in text based children. Default is | boolean |
vdomKey | Key that will be used as the key when rendering the React component. | string |
visible | Visibility of the widget. Defaults to | boolean |