Skip to content

Commit

Permalink
Merge pull request #3 from Backiaraj/chart
Browse files Browse the repository at this point in the history
Update the project
  • Loading branch information
rajendranr-5483 authored Oct 30, 2023
2 parents e3c3575 + 733acc5 commit 551b195
Show file tree
Hide file tree
Showing 50 changed files with 1,630 additions and 1,316 deletions.
16 changes: 0 additions & 16 deletions Blazor Charts.csproj

This file was deleted.

9 changes: 0 additions & 9 deletions Blazor Charts.csproj.user

This file was deleted.

22 changes: 12 additions & 10 deletions App.razor → Client/App.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
19 changes: 19 additions & 0 deletions Client/CustomDateTimeAxis.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
<PackageReference Include="Syncfusion.Blazor.Charts" Version="23.1.41" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\CustomDateTimeAxis.Shared.csproj" />
</ItemGroup>

</Project>
34 changes: 18 additions & 16 deletions Pages/Counter.razor → Client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
102 changes: 47 additions & 55 deletions Pages/FetchData.razor → Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
@page "/fetchdata"
@inject HttpClient Http

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[] forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public string Summary { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
@page "/fetchdata"
@using CustomDateTimeAxis.Shared
@inject HttpClient Http

<PageTitle>Weather forecast</PageTitle>

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
}
}
136 changes: 68 additions & 68 deletions Pages/Index.razor → Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
@page "/"

<SfChart Title="Weather Statistics">
@* <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime" Title="Date Time"
LabelFormat="yyyy MMM" Maximum="@(new DateTime(2021, 07, 1))"
Minimum="@(new DateTime(2015, 12, 31))" EdgeLabelPlacement="EdgeLabelPlacement.Shift"
Interval="6" IntervalType="IntervalType.Months">
</ChartPrimaryXAxis>
<ChartPrimaryYAxis Title="Temperature">
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries Type="ChartSeriesType.Line" DataSource="@ChartData" XName="Date"
YName="Temperature">
<ChartMarker Visible="true" Height="10" Width="10"></ChartMarker>
</ChartSeries>
</ChartSeriesCollection>*@
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTimeCategory"
Title="Business Days" LabelFormat="d"
EdgeLabelPlacement="EdgeLabelPlacement.Shift">
</ChartPrimaryXAxis>
<ChartPrimaryYAxis Title="Profit">
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries Type="ChartSeriesType.Column" DataSource="@ChartData" XName="Date"
YName="Profit">
</ChartSeries>
</ChartSeriesCollection>
</SfChart>

@code {

public class ChartDataModel
{
public DateTime Date { get; set; }
public double Temperature { get; set; }
public int Profit { get; set; }
}

// Date time category Axis
List<ChartDataModel> ChartData = new List<ChartDataModel>
{
new ChartDataModel { Date = new DateTime(2020, 12, 21), Profit = 21 },
new ChartDataModel { Date = new DateTime(2020, 12, 22), Profit = 24},
new ChartDataModel { Date = new DateTime(2020, 12, 24), Profit = 25 },
new ChartDataModel { Date = new DateTime(2020, 12, 28), Profit = 70 },
new ChartDataModel { Date = new DateTime(2021, 1, 4), Profit = 82 },
new ChartDataModel { Date = new DateTime(2021, 1, 6), Profit = 53 },
new ChartDataModel { Date = new DateTime(2021, 1, 8), Profit = 45 },
new ChartDataModel { Date = new DateTime(2021, 1, 11), Profit = 60 }
};

// Date time Axis
//List<ChartDataModel> ChartData = new List<ChartDataModel>
//{
// new ChartDataModel { Date = new DateTime(2016, 3, 1), Temperature = 6.3 },
// new ChartDataModel { Date = new DateTime(2016, 5, 1), Temperature = 13.3 },
// new ChartDataModel { Date = new DateTime(2017, 7, 1), Temperature = 8.0 },
// new ChartDataModel { Date = new DateTime(2017, 4, 1), Temperature = 17.3 },
// new ChartDataModel { Date = new DateTime(2018, 5, 1), Temperature = 19.8 },
// new ChartDataModel { Date = new DateTime(2018, 9, 1), Temperature = 5.1 },
// new ChartDataModel { Date = new DateTime(2019, 2, 1), Temperature = 10.1 },
// new ChartDataModel { Date = new DateTime(2019, 7, 1), Temperature = 9.6 },
// new ChartDataModel { Date = new DateTime(2020, 5, 1), Temperature = 18.1 },
// new ChartDataModel { Date = new DateTime(2020, 12, 15), Temperature = 8.2 }
//};
@page "/"

<SfChart Title="Weather Statistics">
@* <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime" Title="Date Time"
LabelFormat="yyyy MMM" Maximum="@(new DateTime(2021, 07, 1))"
Minimum="@(new DateTime(2015, 12, 31))" EdgeLabelPlacement="EdgeLabelPlacement.Shift"
Interval="6" IntervalType="IntervalType.Months">
</ChartPrimaryXAxis>
<ChartPrimaryYAxis Title="Temperature">
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries Type="ChartSeriesType.Line" DataSource="@ChartData" XName="Date"
YName="Temperature">
<ChartMarker Visible="true" Height="10" Width="10"></ChartMarker>
</ChartSeries>
</ChartSeriesCollection>*@
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTimeCategory"
Title="Business Days" LabelFormat="d"
EdgeLabelPlacement="EdgeLabelPlacement.Shift">
</ChartPrimaryXAxis>
<ChartPrimaryYAxis Title="Profit">
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries Type="ChartSeriesType.Column" DataSource="@ChartData" XName="Date"
YName="Profit">
</ChartSeries>
</ChartSeriesCollection>
</SfChart>

@code {

public class ChartDataModel
{
public DateTime Date { get; set; }
public double Temperature { get; set; }
public int Profit { get; set; }
}

// Date time category Axis
List<ChartDataModel> ChartData = new List<ChartDataModel>
{
new ChartDataModel { Date = new DateTime(2020, 12, 21), Profit = 21 },
new ChartDataModel { Date = new DateTime(2020, 12, 22), Profit = 24},
new ChartDataModel { Date = new DateTime(2020, 12, 24), Profit = 25 },
new ChartDataModel { Date = new DateTime(2020, 12, 28), Profit = 70 },
new ChartDataModel { Date = new DateTime(2021, 1, 4), Profit = 82 },
new ChartDataModel { Date = new DateTime(2021, 1, 6), Profit = 53 },
new ChartDataModel { Date = new DateTime(2021, 1, 8), Profit = 45 },
new ChartDataModel { Date = new DateTime(2021, 1, 11), Profit = 60 }
};

// Date time Axis
//List<ChartDataModel> ChartData = new List<ChartDataModel>
//{
// new ChartDataModel { Date = new DateTime(2016, 3, 1), Temperature = 6.3 },
// new ChartDataModel { Date = new DateTime(2016, 5, 1), Temperature = 13.3 },
// new ChartDataModel { Date = new DateTime(2017, 7, 1), Temperature = 8.0 },
// new ChartDataModel { Date = new DateTime(2017, 4, 1), Temperature = 17.3 },
// new ChartDataModel { Date = new DateTime(2018, 5, 1), Temperature = 19.8 },
// new ChartDataModel { Date = new DateTime(2018, 9, 1), Temperature = 5.1 },
// new ChartDataModel { Date = new DateTime(2019, 2, 1), Temperature = 10.1 },
// new ChartDataModel { Date = new DateTime(2019, 7, 1), Temperature = 9.6 },
// new ChartDataModel { Date = new DateTime(2020, 5, 1), Temperature = 18.1 },
// new ChartDataModel { Date = new DateTime(2020, 12, 15), Temperature = 8.2 }
//};
}
12 changes: 12 additions & 0 deletions Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CustomDateTimeAxis.Client;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Syncfusion.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();
Loading

0 comments on commit 551b195

Please sign in to comment.