Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions UG-Samples/Layout/ForceDirectedTreeDataSource/Components/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link rel="stylesheet" href="@Assets["ForceDirectedTreeDataSource.styles.css"]" />
<ImportMap />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet @rendermode="InteractiveServer" />
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
</head>

<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@inherits LayoutComponentBase

<div class="page">
<main>
@Body
</main>
</div>

<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}

.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}

#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}

#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@page "/"
@using Syncfusion.Blazor.Diagram

<SfDiagramComponent @ref="diagram" ID="diagram" Height="700px" @bind-Nodes="@Nodes" @bind-Connectors="@Connectors">
@* <Layout Type="LayoutType.ForceDirectedTree" ForceDirectedTreeLayoutSettings="@LayoutSettings"></Layout> *@
<SnapSettings Constraints="SnapConstraints.None"></SnapSettings>
</SfDiagramComponent>

@code {
private SfDiagramComponent diagram;
private DiagramObjectCollection<Node> Nodes = new();
private DiagramObjectCollection<Connector> Connectors = new();

// ForceDirectedTreeLayoutSettings LayoutSettings = new ForceDirectedTreeLayoutSettings
// {
// RepulsionStrength = 8000,
// AttractionStrength = 0.7,
// MaximumIteration = 500,
// ConnectorLength = 150
// };

protected override void OnInitialized()
{
InitializeCollection();
}

public void InitializeCollection()
{
string[] departments = { "Engineering", "Sales", "Marketing", "Operations" };
string[] teams = { "Core", "Mobile", "Web", "Data" };
Node parent = CreateNode("ceo", "CEO", "#2c3e50");
Nodes.Add(parent);
for (int i = 0; i < 4; i++)
{
string deptName = departments[i];
Node child1 = CreateNode($"vp-{deptName.ToLower()}", $"VP of {deptName}", "#3498db");
Nodes.Add(child1);
for (int j = 0; j < 4; j++)
{
string teamName = teams[j];
Node child2 = CreateNode($"dir-{deptName.ToLower()}-{teamName.ToLower()}", $"{teamName} Director", "#90caf9");
Nodes.Add(child2);
for (int k = 0; k < 1; k++)
{
Node child3 = CreateNode($"lead-{deptName.ToLower()}-{teamName.ToLower()}", $"{teamName} Lead", "#e3f2fd");
Nodes.Add(child3);
Connectors.Add(CreateConnector(child2.ID, child3.ID));
}
Connectors.Add(CreateConnector(child1.ID, child2.ID));
}
Connectors.Add(CreateConnector(parent.ID, child1.ID));
}
}

private Node CreateNode(string id, string label, string fillColor) => new Node
{
ID = id,
Width = 60,
Height = 60,
Shape = new BasicShape() { Shape = NodeBasicShapes.Ellipse },
Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation { Content = label } },
Style = new ShapeStyle() { Fill = fillColor }
};

private Connector CreateConnector(string sourceId, string targetId) => new Connector
{
ID = $"{sourceId}-{targetId}",
SourceID = sourceId,
TargetID = targetId,
TargetDecorator = new DecoratorSettings { Shape = DecoratorShape.None }
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using ForceDirectedTreeDataSource
@using ForceDirectedTreeDataSource.Components
@using Syncfusion.Blazor.Diagram
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35806.99 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ForceDirectedTreeDataSource", "ForceDirectedTreeDataSource.csproj", "{88427A93-7B27-48EE-84D8-7E3E198C3AC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88427A93-7B27-48EE-84D8-7E3E198C3AC3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E9B921A-FA94-49D4-B518-CA52ACD355AD}
EndGlobalSection
EndGlobal
31 changes: 31 additions & 0 deletions UG-Samples/Layout/ForceDirectedTreeDataSource/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using ForceDirectedTreeDataSource.Components;
using Syncfusion.Blazor;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddSyncfusionBlazor();


var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();


app.UseAntiforgery();

app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5196",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7069;http://localhost:5196",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading