Skip to content

Commit b5633ca

Browse files
authored
Merge pull request #153 from SriRam4552/974431-ForceDirected
974431: Force Directed Tree Layout
2 parents 5952656 + 9333cfe commit b5633ca

File tree

118 files changed

+120135
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+120135
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
9+
<link rel="stylesheet" href="@Assets["app.css"]" />
10+
<link rel="stylesheet" href="@Assets["ForceDirectedTreeDataSource.styles.css"]" />
11+
<ImportMap />
12+
<link rel="icon" type="image/png" href="favicon.png" />
13+
<HeadOutlet @rendermode="InteractiveServer" />
14+
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
15+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
16+
</head>
17+
18+
<body>
19+
<Routes @rendermode="InteractiveServer" />
20+
<script src="_framework/blazor.web.js"></script>
21+
</body>
22+
23+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<main>
5+
@Body
6+
</main>
7+
</div>
8+
9+
<div id="blazor-error-ui" data-nosnippet>
10+
An unhandled error has occurred.
11+
<a href="." class="reload">Reload</a>
12+
<span class="dismiss">🗙</span>
13+
</div>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}
78+
79+
#blazor-error-ui {
80+
color-scheme: light only;
81+
background: lightyellow;
82+
bottom: 0;
83+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
84+
box-sizing: border-box;
85+
display: none;
86+
left: 0;
87+
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
88+
position: fixed;
89+
width: 100%;
90+
z-index: 1000;
91+
}
92+
93+
#blazor-error-ui .dismiss {
94+
cursor: pointer;
95+
position: absolute;
96+
right: 0.75rem;
97+
top: 0.5rem;
98+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Diagram
3+
4+
<SfDiagramComponent Height="600px" NodeCreating="@OnNodeCreating">
5+
<DataSourceSettings ID="Id" ParentID="Manager" DataSource="DataSource"></DataSourceSettings>
6+
<Layout Type="LayoutType.ForceDirectedTree" @bind-ForceDirectedTreeLayoutSettings="@forceDirectedSettings"></Layout>
7+
<SnapSettings Constraints="@SnapConstraints.None"></SnapSettings>
8+
</SfDiagramComponent>
9+
10+
@code
11+
{
12+
public ForceDirectedTreeLayoutSettings forceDirectedSettings = new ForceDirectedTreeLayoutSettings()
13+
{
14+
ConnectorLength = 100,
15+
AttractionStrength = 0.7,
16+
RepulsionStrength = 6000,
17+
MaximumIteration = 350
18+
};
19+
20+
public void OnNodeCreating(IDiagramObject obj)
21+
{
22+
Node node = obj as Node;
23+
node.Height = 40;
24+
node.Width = 40;
25+
node.Shape = new BasicShape()
26+
{
27+
Type = NodeShapes.Basic,
28+
Shape = NodeBasicShapes.Ellipse,
29+
};
30+
node.Style = new ShapeStyle() { Fill = "darkcyan", StrokeWidth = 3, StrokeColor = "Black" };
31+
}
32+
33+
public class ForceDirectedDetails
34+
{
35+
public string Id { get; set; }
36+
public string Role { get; set; }
37+
public string Manager { get; set; }
38+
}
39+
40+
public List<ForceDirectedDetails> DataSource = new List<ForceDirectedDetails>()
41+
{
42+
new ForceDirectedDetails() { Id = "parent", Role = "Board" },
43+
new ForceDirectedDetails() { Id = "1", Role = "General Manager", Manager = "parent" },
44+
new ForceDirectedDetails() { Id = "2", Role = "Human Resource Manager", Manager = "1" },
45+
new ForceDirectedDetails() { Id = "3", Role = "Trainers", Manager = "2" },
46+
new ForceDirectedDetails() { Id = "4", Role = "Recruiting Team", Manager = "2" },
47+
new ForceDirectedDetails() { Id = "5", Role = "Finance Asst. Manager", Manager = "2" },
48+
new ForceDirectedDetails() { Id = "6", Role = "Design Manager", Manager = "1" },
49+
new ForceDirectedDetails() { Id = "7", Role = "Design Supervisor", Manager = "6" },
50+
new ForceDirectedDetails() { Id = "8", Role = "Development Supervisor", Manager = "6" },
51+
new ForceDirectedDetails() { Id = "9", Role = "Drafting Supervisor", Manager = "6" },
52+
new ForceDirectedDetails() { Id = "10", Role = "Operation Manager", Manager = "1" },
53+
new ForceDirectedDetails() { Id = "11", Role = "Statistic Department", Manager = "10" },
54+
new ForceDirectedDetails() { Id = "12", Role = "Logistic Department", Manager = "10" },
55+
new ForceDirectedDetails() { Id = "16", Role = "Marketing Manager", Manager = "1" },
56+
new ForceDirectedDetails() { Id = "17", Role = "Oversea sales Manager", Manager = "16" },
57+
new ForceDirectedDetails() { Id = "18", Role = "Petroleum Manager", Manager = "16" },
58+
new ForceDirectedDetails() { Id = "20", Role = "Service Dept. Manager", Manager = "16" },
59+
new ForceDirectedDetails() { Id = "21", Role = "Quality Department", Manager = "16" }
60+
};
61+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Router AppAssembly="typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
4+
<FocusOnNavigate RouteData="routeData" Selector="h1" />
5+
</Found>
6+
</Router>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using static Microsoft.AspNetCore.Components.Web.RenderMode
7+
@using Microsoft.AspNetCore.Components.Web.Virtualization
8+
@using Microsoft.JSInterop
9+
@using ForceDirectedTreeDataSource
10+
@using ForceDirectedTreeDataSource.Components
11+
@using Syncfusion.Blazor.Diagram
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
11+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35806.99 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ForceDirectedTreeDataSource", "ForceDirectedTreeDataSource.csproj", "{88427A93-7B27-48EE-84D8-7E3E198C3AC3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1E9B921A-FA94-49D4-B518-CA52ACD355AD}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using ForceDirectedTreeDataSource.Components;
2+
using Syncfusion.Blazor;
3+
4+
var builder = WebApplication.CreateBuilder(args);
5+
6+
// Add services to the container.
7+
builder.Services.AddRazorComponents()
8+
.AddInteractiveServerComponents();
9+
builder.Services.AddSyncfusionBlazor();
10+
11+
12+
var app = builder.Build();
13+
14+
// Configure the HTTP request pipeline.
15+
if (!app.Environment.IsDevelopment())
16+
{
17+
app.UseExceptionHandler("/Error", createScopeForErrors: true);
18+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
19+
app.UseHsts();
20+
}
21+
22+
app.UseHttpsRedirection();
23+
24+
25+
app.UseAntiforgery();
26+
27+
app.MapStaticAssets();
28+
app.MapRazorComponents<App>()
29+
.AddInteractiveServerRenderMode();
30+
31+
app.Run();

0 commit comments

Comments
 (0)