Skip to content

Commit b95f794

Browse files
Files added for line chart
Files added for line chart
1 parent e61bab5 commit b95f794

35 files changed

+1467
-0
lines changed

Diff for: App.razor

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
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>

Diff for: Data/WeatherForecast.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace LineChart.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+
}

Diff for: Data/WeatherForecastService.cs

+25
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 LineChart.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+
}

Diff for: LineChart.csproj

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Syncfusion.Blazor.Charts" Version="18.4.0.47" />
9+
</ItemGroup>
10+
11+
</Project>

Diff for: LineChart.csproj.user

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
4+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
5+
</PropertyGroup>
6+
<PropertyGroup>
7+
<ActiveDebugProfile>LineChart</ActiveDebugProfile>
8+
</PropertyGroup>
9+
</Project>

Diff for: Pages/Counter.razor

+16
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+
}

Diff for: Pages/Error.cshtml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@page
2+
@model LineChart.Pages.ErrorModel
3+
4+
<!DOCTYPE html>
5+
<html>
6+
7+
<head>
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
10+
<title>Error</title>
11+
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
12+
<link href="~/css/app.css" rel="stylesheet" />
13+
</head>
14+
15+
<body>
16+
<div class="main">
17+
<div class="content px-4">
18+
<h1 class="text-danger">Error.</h1>
19+
<h2 class="text-danger">An error occurred while processing your request.</h2>
20+
21+
@if (Model.ShowRequestId)
22+
{
23+
<p>
24+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
25+
</p>
26+
}
27+
28+
<h3>Development Mode</h3>
29+
<p>
30+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
31+
</p>
32+
<p>
33+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
34+
It can result in displaying sensitive information from exceptions to end users.
35+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
36+
and restarting the app.
37+
</p>
38+
</div>
39+
</div>
40+
</body>
41+
42+
</html>

Diff for: Pages/Error.cshtml.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace LineChart.Pages
11+
{
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
[IgnoreAntiforgeryToken]
14+
public class ErrorModel : PageModel
15+
{
16+
public string RequestId { get; set; }
17+
18+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19+
20+
private readonly ILogger<ErrorModel> _logger;
21+
22+
public ErrorModel(ILogger<ErrorModel> logger)
23+
{
24+
_logger = logger;
25+
}
26+
27+
public void OnGet()
28+
{
29+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30+
}
31+
}
32+
}

Diff for: Pages/FetchData.razor

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@page "/fetchdata"
2+
3+
@using LineChart.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+
}

Diff for: Pages/Index.razor

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Charts
3+
@using Syncfusion.Blazor
4+
5+
<h1>Line Chart</h1>
6+
7+
<div class="control-section">
8+
<SfChart Title="Inflation - Consumer Price">
9+
<ChartArea><ChartAreaBorder Width="0"></ChartAreaBorder></ChartArea>
10+
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime" LabelFormat="yyyy" IntervalType="IntervalType.Years" EdgeLabelPlacement="EdgeLabelPlacement.Shift">
11+
<ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
12+
</ChartPrimaryXAxis>
13+
<ChartPrimaryYAxis LabelFormat="{value}%" RangePadding="ChartRangePadding.None" Minimum="0" Maximum="100" Interval="20">
14+
<ChartAxisLineStyle Width="0"></ChartAxisLineStyle>
15+
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
16+
</ChartPrimaryYAxis>
17+
<ChartTooltipSettings Enable="true"></ChartTooltipSettings>
18+
<ChartSeriesCollection>
19+
<ChartSeries DataSource="@ChartData" Name="Germany" XName="Period" Width="2"
20+
Opacity="1" YName="ENG_InflationRate" Type="ChartSeriesType.Line">
21+
<ChartMarker Visible="true" Width="10" Height="10">
22+
</ChartMarker>
23+
</ChartSeries>
24+
<ChartSeries DataSource="@ChartData" Name="England" XName="Period" Width="2"
25+
Opacity="1" YName="GER_InflationRate" Type="ChartSeriesType.Line">
26+
<ChartMarker Visible="true" Width="10" Height="10">
27+
</ChartMarker>
28+
</ChartSeries>
29+
</ChartSeriesCollection>
30+
</SfChart>
31+
</div>
32+
@code{
33+
public List<LineChartData> ChartData = new List<LineChartData>
34+
{
35+
new LineChartData { Period = new DateTime(2005, 01, 01), ENG_InflationRate = 21, GER_InflationRate = 28 },
36+
new LineChartData { Period = new DateTime(2006, 01, 01), ENG_InflationRate = 24, GER_InflationRate = 44 },
37+
new LineChartData { Period = new DateTime(2007, 01, 01), ENG_InflationRate = 36, GER_InflationRate = 48 },
38+
new LineChartData { Period = new DateTime(2008, 01, 01), ENG_InflationRate = 38, GER_InflationRate = 50 },
39+
new LineChartData { Period = new DateTime(2009, 01, 01), ENG_InflationRate = 54, GER_InflationRate = 66 },
40+
new LineChartData { Period = new DateTime(2010, 01, 01), ENG_InflationRate = 57, GER_InflationRate = 78 },
41+
new LineChartData { Period = new DateTime(2011, 01, 01), ENG_InflationRate = 70, GER_InflationRate = 84 },
42+
};
43+
public class LineChartData
44+
{
45+
public DateTime Period { get; set; }
46+
public double ENG_InflationRate { get; set; }
47+
public double GER_InflationRate { get; set; }
48+
}
49+
}

Diff for: Pages/_Host.cshtml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@page "/"
2+
@namespace LineChart.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>LineChart</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="LineChart.styles.css" rel="stylesheet" />
18+
<link href="https://cdn.syncfusion.com/blazor/18.1.43/bootstrap4.css" rel="stylesheet" />
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js" crossorigin="anonymous"></script>
20+
</head>
21+
<body>
22+
<component type="typeof(App)" render-mode="ServerPrerendered" />
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>

Diff for: Program.cs

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

Diff for: Properties/launchSettings.json

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

Diff for: Shared/MainLayout.razor

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

0 commit comments

Comments
 (0)