|
2 | 2 |
|
3 | 3 | @using Syncfusion.Blazor.Diagram |
4 | 4 |
|
5 | | -<SfDiagramComponent Height="600px" Nodes="@nodes" Connectors="@connectors" NodeCreating="@OnNodeCreating" ConnectorCreating="@OnConnectorCreating"> |
6 | | - <Layout Type="LayoutType.HierarchicalTree" @bind-HorizontalSpacing="@HorizontalSpacing" @bind-VerticalSpacing="@VerticalSpacing"> |
| 5 | +<SfDiagramComponent Height="600px" Nodes="@_nodes" Connectors="@_connectors" NodeCreating="@OnNodeCreating" ConnectorCreating="@OnConnectorCreating"> |
| 6 | + <Layout Type="LayoutType.HierarchicalTree" @bind-HorizontalSpacing="@_horizontalSpacing" @bind-VerticalSpacing="@_verticalSpacing"> |
7 | 7 | </Layout> |
8 | 8 | <SnapSettings> |
9 | 9 | <HorizontalGridLines LineColor="white" LineDashArray="2,2"> |
|
15 | 15 |
|
16 | 16 | @code |
17 | 17 | { |
18 | | - private int left = 40; |
19 | | - private int top = 50; |
20 | | - private DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>(); |
21 | | - private DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>(); |
22 | | - private int HorizontalSpacing = 40; |
23 | | - private int VerticalSpacing = 40; |
| 18 | + private DiagramObjectCollection<Node> _nodes = new DiagramObjectCollection<Node>(); |
| 19 | + private DiagramObjectCollection<Connector> _connectors = new DiagramObjectCollection<Connector>(); |
| 20 | + private int _horizontalSpacing = 40; |
| 21 | + private int _verticalSpacing = 40; |
24 | 22 |
|
25 | 23 | private void OnNodeCreating(IDiagramObject obj) |
26 | 24 | { |
|
47 | 45 | protected override void OnInitialized() |
48 | 46 | { |
49 | 47 | //Initialize the node and connectors. |
50 | | - nodes = new DiagramObjectCollection<Node>() |
| 48 | + _nodes = new DiagramObjectCollection<Node>() |
51 | 49 | { |
52 | 50 | new Node() { ID="node1", CanAutoLayout = true, Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Steve-Ceo"} } }, |
53 | 51 | new Node() { ID="node2", CanAutoLayout = true, Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Kevin-Manager"} } }, |
|
57 | 55 | new Node() { ID="node6", CanAutoLayout = true, Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="John-Manager"} } }, |
58 | 56 | new Node() { ID="node7", CanAutoLayout = false, Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Mary-CSE"} } }, |
59 | 57 | }; |
60 | | - connectors = new DiagramObjectCollection<Connector>() |
| 58 | + _connectors = new DiagramObjectCollection<Connector>() |
61 | 59 | { |
62 | 60 | new Connector() { ID="connector1", SourceID="node1", TargetID="node2" }, |
63 | 61 | new Connector() { ID="connector2", SourceID="node1", TargetID="node3" }, |
|
0 commit comments