Skip to content

Commit 6ea3e19

Browse files
Merge pull request #1 from subaa1492/master
Added a Blazor Smith Chart
2 parents 11689ca + dd73b57 commit 6ea3e19

32 files changed

+1433
-1
lines changed

App.razor

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
<Router AppAssembly="@typeof(Program).Assembly">
3+
<Found Context="routeData">
4+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
5+
</Found>
6+
<NotFound>
7+
<LayoutView Layout="@typeof(MainLayout)">
8+
<p>Sorry, there's nothing at this address.</p>
9+
</LayoutView>
10+
</NotFound>
11+
</Router>

BlazorExample.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Syncfusion.Blazor" Version="18.1.0.58" />
9+
</ItemGroup>
10+
11+
</Project>

Data/WeatherForecast.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace BlazorExample.Data
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}

Data/WeatherForecastService.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
5+
namespace BlazorExample.Data
6+
{
7+
public class WeatherForecastService
8+
{
9+
private static readonly string[] Summaries = new[]
10+
{
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
};
13+
14+
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
15+
{
16+
var rng = new Random();
17+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
18+
{
19+
Date = startDate.AddDays(index),
20+
TemperatureC = rng.Next(-20, 55),
21+
Summary = Summaries[rng.Next(Summaries.Length)]
22+
}).ToArray());
23+
}
24+
}
25+
}

Pages/Counter.razor

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/counter"
2+
3+
<h1>Counter</h1>
4+
5+
<p>Current count: @currentCount</p>
6+
7+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
8+
9+
@code {
10+
private int currentCount = 0;
11+
12+
private void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}

Pages/Error.razor

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/error"
2+
3+
4+
<h1 class="text-danger">Error.</h1>
5+
<h2 class="text-danger">An error occurred while processing your request.</h2>
6+
7+
<h3>Development Mode</h3>
8+
<p>
9+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
10+
</p>
11+
<p>
12+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
13+
It can result in displaying sensitive information from exceptions to end users.
14+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
15+
and restarting the app.
16+
</p>

Pages/FetchData.razor

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@page "/fetchdata"
2+
3+
@using BlazorExample.Data
4+
@inject WeatherForecastService ForecastService
5+
6+
<h1>Weather forecast</h1>
7+
8+
<p>This component demonstrates fetching data from a service.</p>
9+
10+
@if (forecasts == null)
11+
{
12+
<p><em>Loading...</em></p>
13+
}
14+
else
15+
{
16+
<table class="table">
17+
<thead>
18+
<tr>
19+
<th>Date</th>
20+
<th>Temp. (C)</th>
21+
<th>Temp. (F)</th>
22+
<th>Summary</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach (var forecast in forecasts)
27+
{
28+
<tr>
29+
<td>@forecast.Date.ToShortDateString()</td>
30+
<td>@forecast.TemperatureC</td>
31+
<td>@forecast.TemperatureF</td>
32+
<td>@forecast.Summary</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
}
38+
39+
@code {
40+
private WeatherForecast[] forecasts;
41+
42+
protected override async Task OnInitializedAsync()
43+
{
44+
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
45+
}
46+
}

Pages/Index.razor

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
@page "/"
2+
3+
<SfSmithchart>
4+
<SmithchartTitle Text="Impedance Transmission"></SmithchartTitle>
5+
<SmithchartLegendSettings Visible="true">
6+
</SmithchartLegendSettings>
7+
<SmithchartSeriesCollection>
8+
<SmithchartSeries Points="PointSeries" Fill="#0F94C4" Name="Tranmission 1">
9+
<SmithchartSeriesMarker Visible="true">
10+
<SmithchartSeriesDatalabel Visible="true">
11+
</SmithchartSeriesDatalabel>
12+
</SmithchartSeriesMarker>
13+
<SmithchartSeriesTooltip Visible="true">
14+
</SmithchartSeriesTooltip>
15+
</SmithchartSeries>
16+
<SmithchartSeries DataSource="@TransmissionSeries" Name="Tranmission 2"
17+
Resistance="Resistancevalue" Reactance="Reactancevalue" Fill="#EE0C88">
18+
<SmithchartSeriesMarker Visible="true">
19+
</SmithchartSeriesMarker>
20+
<SmithchartSeriesTooltip Visible="true">
21+
</SmithchartSeriesTooltip>
22+
</SmithchartSeries>
23+
</SmithchartSeriesCollection>
24+
</SfSmithchart>
25+
26+
@code {
27+
28+
public class ChartData
29+
{
30+
public double Resistancevalue { get; set; }
31+
public double Reactancevalue { get; set; }
32+
}
33+
34+
public List<ChartData> TransmissionSeries = new List<ChartData>
35+
{
36+
new ChartData { Resistancevalue= 10, Reactancevalue= 25 },
37+
new ChartData { Resistancevalue= 8, Reactancevalue= 6 },
38+
new ChartData { Resistancevalue= 6, Reactancevalue= 4.5 },
39+
new ChartData { Resistancevalue= 4.5, Reactancevalue= 2 },
40+
new ChartData { Resistancevalue= 3.5, Reactancevalue= 1.6 },
41+
new ChartData { Resistancevalue= 2.5, Reactancevalue= 1.3 },
42+
new ChartData { Resistancevalue= 2, Reactancevalue= 1.2 },
43+
new ChartData { Resistancevalue= 1.5, Reactancevalue= 1 },
44+
new ChartData { Resistancevalue= 1, Reactancevalue= 0.8 },
45+
new ChartData { Resistancevalue= 0.5, Reactancevalue= 0.4 },
46+
new ChartData { Resistancevalue= 0.3, Reactancevalue= 0.2 },
47+
new ChartData { Resistancevalue= 0.001, Reactancevalue= 0.15 }
48+
};
49+
50+
public List<ISmithChartPoint> PointSeries = new List<ISmithChartPoint>
51+
{
52+
new ISmithChartPoint { Resistance= 20, Reactance= -50 },
53+
new ISmithChartPoint { Resistance= 10, Reactance= -10 },
54+
new ISmithChartPoint { Resistance= 9, Reactance= -4.5 },
55+
new ISmithChartPoint { Resistance= 8, Reactance= -3.5 },
56+
new ISmithChartPoint { Resistance= 7, Reactance= -2.5 },
57+
new ISmithChartPoint { Resistance= 6, Reactance= -1.5 },
58+
new ISmithChartPoint { Resistance= 5, Reactance= -1 },
59+
new ISmithChartPoint { Resistance= 4.5, Reactance= -0.5 },
60+
new ISmithChartPoint { Resistance= 2, Reactance= 0.5 },
61+
new ISmithChartPoint { Resistance= 1.5, Reactance= 0.4 },
62+
new ISmithChartPoint { Resistance= 1, Reactance= 0.4 },
63+
new ISmithChartPoint { Resistance= 0.5, Reactance= 0.2 },
64+
new ISmithChartPoint { Resistance= 0.3, Reactance= 0.1 },
65+
new ISmithChartPoint { Resistance= 0.001, Reactance= 0.05 }
66+
};
67+
68+
}
69+
70+

Pages/_Host.cshtml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@page "/"
2+
@namespace BlazorExample.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@{
5+
Layout = null;
6+
}
7+
8+
<!DOCTYPE html>
9+
<html lang="en">
10+
<head>
11+
<meta charset="utf-8" />
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
13+
<title>BlazorExample</title>
14+
<base href="~/" />
15+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
16+
<link href="css/site.css" rel="stylesheet" />
17+
<link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
18+
</head>
19+
<body>
20+
<app>
21+
<component type="typeof(App)" render-mode="ServerPrerendered" />
22+
</app>
23+
24+
<div id="blazor-error-ui">
25+
<environment include="Staging,Production">
26+
An error has occurred. This application may no longer respond until reloaded.
27+
</environment>
28+
<environment include="Development">
29+
An unhandled exception has occurred. See browser dev tools for details.
30+
</environment>
31+
<a href="" class="reload">Reload</a>
32+
<a class="dismiss">🗙</a>
33+
</div>
34+
35+
<script src="_framework/blazor.server.js"></script>
36+
</body>
37+
</html>

Program.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Hosting;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace BlazorExample
13+
{
14+
public class Program
15+
{
16+
public static void Main(string[] args)
17+
{
18+
CreateHostBuilder(args).Build().Run();
19+
}
20+
21+
public static IHostBuilder CreateHostBuilder(string[] args) =>
22+
Host.CreateDefaultBuilder(args)
23+
.ConfigureWebHostDefaults(webBuilder =>
24+
{
25+
webBuilder.UseStartup<Startup>();
26+
});
27+
}
28+
}

Properties/launchSettings.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:64434",
7+
"sslPort": 44372
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"BlazorExample": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
# create-blazor-smith-chart-in-a-blazor-application
1+
# Add a Blazor Smith Chart to a Blazor Server App
2+
3+
Learn how easily you can create and configure Syncfusion Blazor Smith Chart in a Blazor server app using Visual Studio 2019. A Blazor Smith Chart is used to visualize the impedance of a transmission line in high-frequency circuit applications. In this video, you will learn how to populate list data, add legends, and enable data labels and tooltips.
4+
5+
Example: https://blazor.syncfusion.com/demos/smith-chart/default-functionalities
6+
7+
Documentation: https://blazor.syncfusion.com/documentation/smith-chart/getting-started
8+
9+
## Project pre-requisites
10+
Make sure that you have the compatible versions of Visual Studio 2019 and .NET Core SDK latest version(3.1.2) in your machine before starting to work on this project.
11+
12+
## How to run this application?
13+
To run this application, you need to first clone the create-blazor-smith-chart-in-a-blazor-application repository and then open it in Visual Studio 2019. Now, simply build and run your project to view the output.
14+

Shared/MainLayout.razor

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="sidebar">
4+
<NavMenu />
5+
</div>
6+
7+
<div class="main">
8+
<div class="top-row px-4">
9+
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
10+
</div>
11+
12+
<div class="content px-4">
13+
@Body
14+
</div>
15+
</div>

Shared/NavMenu.razor

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div class="top-row pl-4 navbar navbar-dark">
2+
<a class="navbar-brand" href="">BlazorExample</a>
3+
<button class="navbar-toggler" @onclick="ToggleNavMenu">
4+
<span class="navbar-toggler-icon"></span>
5+
</button>
6+
</div>
7+
8+
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
9+
<ul class="nav flex-column">
10+
<li class="nav-item px-3">
11+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
12+
<span class="oi oi-home" aria-hidden="true"></span> Home
13+
</NavLink>
14+
</li>
15+
<li class="nav-item px-3">
16+
<NavLink class="nav-link" href="counter">
17+
<span class="oi oi-plus" aria-hidden="true"></span> Counter
18+
</NavLink>
19+
</li>
20+
<li class="nav-item px-3">
21+
<NavLink class="nav-link" href="fetchdata">
22+
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
23+
</NavLink>
24+
</li>
25+
</ul>
26+
</div>
27+
28+
@code {
29+
private bool collapseNavMenu = true;
30+
31+
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
32+
33+
private void ToggleNavMenu()
34+
{
35+
collapseNavMenu = !collapseNavMenu;
36+
}
37+
}

0 commit comments

Comments
 (0)