Skip to content

Commit ea399df

Browse files
committed
Add performance demo
1 parent 573b42d commit ea399df

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@page "/demos/performance"
2+
@layout DemoLayout
3+
@inherits PerformanceCompoent
4+
@inject LayoutData LayoutData
5+
6+
@code {
7+
protected override void OnInitialized()
8+
{
9+
base.OnInitialized();
10+
11+
LayoutData.Title = "Performance";
12+
LayoutData.Info = "This diagram contains 64 nodes and 32 links";
13+
LayoutData.DataChanged();
14+
}
15+
}
16+
17+
<CascadingValue Name="DiagramManager" Value="diagramManager">
18+
<DiagramCanvas></DiagramCanvas>
19+
</CascadingValue>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Blazor.Diagrams.Core;
2+
using Blazor.Diagrams.Core.Models;
3+
using Microsoft.AspNetCore.Components;
4+
5+
namespace SharedDemo.Demos
6+
{
7+
public class PerformanceCompoent : ComponentBase
8+
{
9+
protected readonly DiagramManager diagramManager = new DiagramManager();
10+
11+
protected override void OnInitialized()
12+
{
13+
base.OnInitialized();
14+
15+
for (int r = 0; r < 8; r++)
16+
{
17+
for (int c = 0; c < 8; c += 2)
18+
{
19+
var node1 = new NodeModel(new Point(10 + c * 10 + c * 120, 10 + r * 100));
20+
var node2 = new NodeModel(new Point(10 + (c + 1) * 130, 10 + r * 100));
21+
22+
var sourcePort = node1.AddPort(PortAlignment.RIGHT);
23+
var targetPort = node2.AddPort(PortAlignment.LEFT);
24+
25+
diagramManager.AddNodes(node1, node2);
26+
diagramManager.AddLink(sourcePort, targetPort);
27+
}
28+
}
29+
}
30+
31+
private NodeModel NewNode(double x, double y)
32+
{
33+
var node = new NodeModel(new Point(x, y));
34+
node.AddPort(PortAlignment.BOTTOM);
35+
node.AddPort(PortAlignment.TOP);
36+
node.AddPort(PortAlignment.LEFT);
37+
node.AddPort(PortAlignment.RIGHT);
38+
return node;
39+
}
40+
}
41+
}

samples/SharedDemo/Layouts/DemoLayout.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<a href="demos/events" class="list-group-item list-group-item-action bg-light">Events</a>
3737
<a href="demos/dynamic-insertions" class="list-group-item list-group-item-action bg-light">Dynamic insertions</a>
3838
<a href="demos/custom-node" class="list-group-item list-group-item-action bg-light">Custom node</a>
39+
<a href="demos/performance" class="list-group-item list-group-item-action bg-light">Performance</a>
3940
</div>
4041
</div>
4142
<div id="page-content-wrapper">

0 commit comments

Comments
 (0)