Skip to content

Commit c096c62

Browse files
Merge pull request #4 from Backiaraj/chart
Update the project
2 parents 85fbd14 + b7b3b35 commit c096c62

Some content is hidden

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

50 files changed

+1609
-1309
lines changed

Blazor Charts.csproj

Lines changed: 0 additions & 16 deletions
This file was deleted.

Blazor Charts.csproj.user

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

Client/CustomChartAxis.Client.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.Charts" Version="23.1.41" />
13+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="23.1.41" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\Shared\CustomChartAxis.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
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-
}
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
1-
@page "/fetchdata"
2-
@inject HttpClient Http
3-
4-
<h1>Weather forecast</h1>
5-
6-
<p>This component demonstrates fetching data from the server.</p>
7-
8-
@if (forecasts == null)
9-
{
10-
<p><em>Loading...</em></p>
11-
}
12-
else
13-
{
14-
<table class="table">
15-
<thead>
16-
<tr>
17-
<th>Date</th>
18-
<th>Temp. (C)</th>
19-
<th>Temp. (F)</th>
20-
<th>Summary</th>
21-
</tr>
22-
</thead>
23-
<tbody>
24-
@foreach (var forecast in forecasts)
25-
{
26-
<tr>
27-
<td>@forecast.Date.ToShortDateString()</td>
28-
<td>@forecast.TemperatureC</td>
29-
<td>@forecast.TemperatureF</td>
30-
<td>@forecast.Summary</td>
31-
</tr>
32-
}
33-
</tbody>
34-
</table>
35-
}
36-
37-
@code {
38-
private WeatherForecast[] forecasts;
39-
40-
protected override async Task OnInitializedAsync()
41-
{
42-
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43-
}
44-
45-
public class WeatherForecast
46-
{
47-
public DateTime Date { get; set; }
48-
49-
public int TemperatureC { get; set; }
50-
51-
public string Summary { get; set; }
52-
53-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54-
}
55-
}
1+
@page "/fetchdata"
2+
@using CustomChartAxis.Shared
3+
@inject HttpClient Http
4+
5+
<PageTitle>Weather forecast</PageTitle>
6+
7+
<h1>Weather forecast</h1>
8+
9+
<p>This component demonstrates fetching data from the server.</p>
10+
11+
@if (forecasts == null)
12+
{
13+
<p><em>Loading...</em></p>
14+
}
15+
else
16+
{
17+
<table class="table">
18+
<thead>
19+
<tr>
20+
<th>Date</th>
21+
<th>Temp. (C)</th>
22+
<th>Temp. (F)</th>
23+
<th>Summary</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
@foreach (var forecast in forecasts)
28+
{
29+
<tr>
30+
<td>@forecast.Date.ToShortDateString()</td>
31+
<td>@forecast.TemperatureC</td>
32+
<td>@forecast.TemperatureF</td>
33+
<td>@forecast.Summary</td>
34+
</tr>
35+
}
36+
</tbody>
37+
</table>
38+
}
39+
40+
@code {
41+
private WeatherForecast[]? forecasts;
42+
43+
protected override async Task OnInitializedAsync()
44+
{
45+
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
46+
}
47+
}
Lines changed: 46 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,46 @@
1-
@page "/"
2-
3-
<SfChart Title="Weather Statistics">
4-
5-
@*Chart Axis Customization*@
6-
@*<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Title="Days of the Week"
7-
CrossesAt="30" CrossesInAxis="YAxis">
8-
<ChartAxisMajorTickLines Width="5" Color="red" />
9-
<ChartAxisMajorGridLines Width="1" Color="blue" />
10-
</ChartPrimaryXAxis>
11-
<ChartPrimaryYAxis Title="Temperature" LabelFormat="{value}°F" Minimum="0" Maximum="100" Interval="20"
12-
OpposedPosition="true" IsInversed="true" CrossesAt="2">
13-
<ChartAxisMajorTickLines Width="5" Color="red" />
14-
<ChartAxisMajorGridLines Width="1" Color="blue" />
15-
</ChartPrimaryYAxis>*@
16-
17-
@*Multiple Axis Code*@
18-
19-
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Title="Days of the Week"
20-
CrossesAt="30" CrossesInAxis="YAxis1">
21-
</ChartPrimaryXAxis>
22-
<ChartPrimaryYAxis Title=" Temperature " LabelFormat=" {value} F" Minimum="0" Maximum="100" Interval="20"
23-
CrossesAt="2">
24-
</ChartPrimaryYAxis>
25-
<ChartAxes>
26-
<ChartAxis Name="YAxis1" Minimum="24" Maximum="36" Interval="2"
27-
LabelFormat="{value}°C" OpposedPosition="true"></ChartAxis>
28-
</ChartAxes>
29-
<ChartSeriesCollection>
30-
<ChartSeries DataSource="@ChartData" XName="Days" YName="Temperature" Type="ChartSeriesType.Column">
31-
</ChartSeries>
32-
<ChartSeries Type="ChartSeriesType.Line" DataSource="@ChartData" XName="Days"
33-
YName="Temperature1" YAxisName="YAxis1">
34-
<ChartMarker Visible="true" Width="10" Height="10">
35-
<ChartMarkerBorder Color="#F8AB1D" Width="2"></ChartMarkerBorder>
36-
</ChartMarker>
37-
</ChartSeries>
38-
</ChartSeriesCollection>
39-
</SfChart>
40-
41-
@code {
42-
43-
public class ChartDataModel
44-
{
45-
public string Days { get; set; }
46-
public double Temperature { get; set; }
47-
public double Temperature1 { get; set; }
48-
}
49-
50-
public List<ChartDataModel> ChartData = new List<ChartDataModel>
51-
{
52-
new ChartDataModel { Days = "Sunday", Temperature = 35, Temperature1 = 30 },
53-
new ChartDataModel { Days = "Monday" , Temperature = 40, Temperature1 = 28 },
54-
new ChartDataModel { Days = "Tuesday", Temperature = 80, Temperature1 = 29 },
55-
new ChartDataModel { Days = "Wednesday" , Temperature = 70, Temperature1 = 30 },
56-
new ChartDataModel { Days = "Thursday", Temperature = 65, Temperature1 = 33 },
57-
new ChartDataModel { Days = "Friday", Temperature = 55, Temperature1 = 32 },
58-
new ChartDataModel { Days = "Saturday", Temperature = 50, Temperature1 = 34 }
59-
};
60-
61-
}
1+
@page "/"
2+
3+
<SfChart Title="Weather Statistics">
4+
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Title="Days of the Week"
5+
CrossesAt="30" CrossesInAxis="YAxis1">
6+
</ChartPrimaryXAxis>
7+
<ChartPrimaryYAxis Title=" Temperature " LabelFormat=" {value} F" Minimum="0" Maximum="100" Interval="20"
8+
CrossesAt="2">
9+
</ChartPrimaryYAxis>
10+
<ChartAxes>
11+
<ChartAxis Name="YAxis1" Minimum="24" Maximum="36" Interval="2"
12+
LabelFormat="{value}°C" OpposedPosition="true"></ChartAxis>
13+
</ChartAxes>
14+
<ChartSeriesCollection>
15+
<ChartSeries DataSource="@ChartData" XName="Days" YName="Temperature" Type="ChartSeriesType.Column">
16+
</ChartSeries>
17+
<ChartSeries Type="ChartSeriesType.Line" DataSource="@ChartData" XName="Days"
18+
YName="Temperature1" YAxisName="YAxis1">
19+
<ChartMarker Visible="true" Width="10" Height="10">
20+
<ChartMarkerBorder Color="#F8AB1D" Width="2"></ChartMarkerBorder>
21+
</ChartMarker>
22+
</ChartSeries>
23+
</ChartSeriesCollection>
24+
</SfChart>
25+
26+
@code {
27+
28+
public class ChartDataModel
29+
{
30+
public string Days { get; set; }
31+
public double Temperature { get; set; }
32+
public double Temperature1 { get; set; }
33+
}
34+
35+
public List<ChartDataModel> ChartData = new List<ChartDataModel>
36+
{
37+
new ChartDataModel { Days = "Sunday", Temperature = 35, Temperature1 = 30 },
38+
new ChartDataModel { Days = "Monday" , Temperature = 40, Temperature1 = 28 },
39+
new ChartDataModel { Days = "Tuesday", Temperature = 80, Temperature1 = 29 },
40+
new ChartDataModel { Days = "Wednesday" , Temperature = 70, Temperature1 = 30 },
41+
new ChartDataModel { Days = "Thursday", Temperature = 65, Temperature1 = 33 },
42+
new ChartDataModel { Days = "Friday", Temperature = 55, Temperature1 = 32 },
43+
new ChartDataModel { Days = "Saturday", Temperature = 50, Temperature1 = 34 }
44+
};
45+
46+
}

Client/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CustomChartAxis.Client;
2+
using Microsoft.AspNetCore.Components.Web;
3+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
4+
using Syncfusion.Blazor;
5+
6+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
7+
builder.RootComponents.Add<App>("#app");
8+
builder.RootComponents.Add<HeadOutlet>("head::after");
9+
10+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
11+
builder.Services.AddSyncfusionBlazor();
12+
await builder.Build().RunAsync();

0 commit comments

Comments
 (0)