Skip to content

Commit 18037e7

Browse files
authored
Merge pull request #172 from apexcharts/improve-data
Improve data
2 parents bdf1502 + 33b48a8 commit 18037e7

File tree

16 files changed

+176
-8
lines changed

16 files changed

+176
-8
lines changed

docs/BlazorApexCharts.Docs.Server/Pages/_Host.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
<title>Blazor ApexCharts Docs</title>
1414
<base href="~/" />
1515

16-
<link rel="stylesheet" href="@("https://unpkg.com/@tabler/core@1.0.0-beta2/dist/css/tabler.min.css")">
16+
<link rel="stylesheet" href="@("https://unpkg.com/@tabler/core@1.0.0-beta15/dist/css/tabler.min.css")">
1717
<link rel="stylesheet" href="_content/TabBlazor/css/tabblazor.min.css" />
1818
<script src="_content/TabBlazor/js/tabblazor.js"></script>
1919

2020
<link href="_content/BlazorApexCharts.Docs/css/docs.css" rel="stylesheet" />
2121

2222
</head>
2323
<body>
24-
<component type="typeof(App)" render-mode="ServerPrerendered" />
24+
<component type="typeof(App)" render-mode="Server" />
2525

2626
<div id="blazor-error-ui">
2727
<environment include="Staging,Production">

docs/BlazorApexCharts.Docs.Server/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"IIS Express": {
44
"commandName": "IISExpress",
55
"launchBrowser": true,
6-
"launchUrl": "eatures/chart-size",
6+
"launchUrl": "features/chart-data",
77
"environmentVariables": {
88
"ASPNETCORE_ENVIRONMENT": "Development"
99
}

docs/BlazorApexCharts.Docs.Wasm/wwwroot/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<title>Blazor ApexCharts Documentation</title>
99
<base href="/" />
1010

11-
<link rel="stylesheet" href="https://unpkg.com/@tabler/core@1.0.0-beta2/dist/css/tabler.min.css">
11+
<link rel="stylesheet" href="https://unpkg.com/@tabler/core@1.0.0-beta15/dist/css/tabler.min.css">
1212
<link rel="stylesheet" href="_content/TabBlazor/css/tabblazor.min.css" />
1313
<script src="_content/TabBlazor/js/tabblazor.js"></script>
1414

docs/BlazorApexCharts.Docs/BlazorApexCharts.Docs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="ColorCode.HTML" Version="2.0.13" />
1515
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.3" />
1616
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
17-
<PackageReference Include="TabBlazor" Version="0.6.0-alpha" />
17+
<PackageReference Include="TabBlazor" Version="0.7.2-alpha" />
1818
</ItemGroup>
1919

2020
<ItemGroup>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@page "/features/chart-data"
2+
3+
<DocExamples Title="Chart Data">
4+
5+
<CodeSnippet Title="Data Async" ClassName=@typeof(DataAsync).ToString()>
6+
<Snippet>
7+
<DataAsync />
8+
</Snippet>
9+
</CodeSnippet>
10+
11+
<CodeSnippet Title="No Data" ClassName=@typeof(NoData).ToString()>
12+
<Snippet>
13+
<NoData />
14+
</Snippet>
15+
</CodeSnippet>
16+
17+
</DocExamples>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<DemoContainer>
2+
@if (orders != null)
3+
{
4+
<ApexChart TItem="Order"
5+
Title="Load data async"
6+
Options="options"
7+
@ref="chart">
8+
9+
<ApexPointSeries TItem="Order"
10+
Items="orders"
11+
SeriesType="@SeriesType.Bar"
12+
Name="Gross Value"
13+
XValue="@(e => e.Country)"
14+
YAggregate="@(e => e.Sum(e => e.GrossValue))"
15+
OrderByDescending="e=>e.Y" />
16+
17+
<ApexPointSeries TItem="Order"
18+
Items="orders"
19+
SeriesType="@SeriesType.Bar"
20+
Name="Net Value"
21+
XValue="@(e => e.Country)"
22+
YAggregate="@(e => e.Sum(e => e.NetValue))"
23+
OrderByDescending="e=>e.Y" />
24+
25+
</ApexChart>
26+
27+
}
28+
else
29+
{
30+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; display: block; max-height: 250px;" width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
31+
<g transform="rotate(180 50 50)">
32+
<rect x="15" y="15" width="10" height="40" fill="#ebebeb">
33+
<animate attributeName="height" values="50;70;30;50" keyTimes="0;0.33;0.66;1" dur="1s" repeatCount="indefinite" calcMode="spline" keySplines="0.5 0 0.5 1;0.5 0 0.5 1;0.5 0 0.5 1" begin="-0.4s"></animate>
34+
</rect>
35+
<rect x="35" y="15" width="10" height="40" fill="#f0f0f0">
36+
<animate attributeName="height" values="50;70;30;50" keyTimes="0;0.33;0.66;1" dur="1s" repeatCount="indefinite" calcMode="spline" keySplines="0.5 0 0.5 1;0.5 0 0.5 1;0.5 0 0.5 1" begin="-0.2s"></animate>
37+
</rect>
38+
<rect x="55" y="15" width="10" height="40" fill="#ebebeb">
39+
<animate attributeName="height" values="50;70;30;50" keyTimes="0;0.33;0.66;1" dur="1s" repeatCount="indefinite" calcMode="spline" keySplines="0.5 0 0.5 1;0.5 0 0.5 1;0.5 0 0.5 1" begin="-0.6s"></animate>
40+
</rect>
41+
<rect x="75" y="15" width="10" height="40" fill="#f0f0f0">
42+
<animate attributeName="height" values="50;70;30;50" keyTimes="0;0.33;0.66;1" dur="1s" repeatCount="indefinite" calcMode="spline" keySplines="0.5 0 0.5 1;0.5 0 0.5 1;0.5 0 0.5 1" begin="-1s"></animate>
43+
</rect>
44+
</g>
45+
</svg>
46+
}
47+
</DemoContainer>
48+
49+
@code {
50+
private List<Order> orders { get; set; }
51+
private ApexChartOptions<Order> options { get; set; } = new();
52+
private ApexChart<Order> chart;
53+
54+
protected override async Task OnInitializedAsync()
55+
{
56+
await LoadData();
57+
}
58+
59+
private async Task LoadData()
60+
{
61+
await Task.Delay(3000); //Simulate External Api call
62+
orders = SampleData.GetOrders();
63+
}
64+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<DemoContainer>
2+
<ApexChart TItem="Order"
3+
Title="Null"
4+
Options="options"
5+
@ref=chart>
6+
7+
<ApexPointSeries TItem="Order"
8+
Items="orders"
9+
SeriesType="@SeriesType.Area"
10+
Name="Gross Value"
11+
XValue="@(e => e.Country)"
12+
YAggregate="@(e => e.Sum(e => e.GrossValue))"
13+
OrderByDescending="e=>e.Y" />
14+
15+
<ApexPointSeries TItem="Order"
16+
Items="orders"
17+
SeriesType="@SeriesType.Area"
18+
Name="Net Value"
19+
XValue="@(e => e.Country)"
20+
YAggregate="@(e => e.Sum(e => e.NetValue))"
21+
OrderByDescending="e=>e.Y" />
22+
</ApexChart>
23+
24+
@if(isLoading) {
25+
<Progress Indeterminate />
26+
}
27+
28+
29+
</DemoContainer>
30+
31+
@code {
32+
private List<Order> orders { get; set; }
33+
private ApexChartOptions<Order> options { get; set; } = new();
34+
private ApexChart<Order> chart;
35+
private bool isLoading;
36+
37+
protected override async Task OnInitializedAsync()
38+
{
39+
options.NoData = new ApexCharts.NoData { Text = "No Data..." };
40+
await LoadData();
41+
}
42+
43+
44+
private async Task LoadData()
45+
{
46+
isLoading = true;
47+
48+
await Task.Delay(3000); //Simulate Slow api
49+
orders = SampleData.GetOrders();
50+
StateHasChanged();
51+
await chart.UpdateSeriesAsync(true);
52+
53+
isLoading = false;
54+
}
55+
56+
57+
}

docs/BlazorApexCharts.Docs/Components/Methods/UpdateOptions/MaintainZoom.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
seriesName = "Gross Value " + dateString;
6666

6767
await Task.Yield(); // We need this in order to update the title and series name
68+
6869
await chart.UpdateOptionsAsync(false, false, false, zoomOptions);
6970
}
7071
}

docs/BlazorApexCharts.Docs/Shared/MainNavigation.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<SubMenu>
123123
<NavbarMenuItem Text="Annotations" Href="features/annotations" />
124124
<NavbarMenuItem Text="Axis" Href="features/axis" />
125+
<NavbarMenuItem Text="Data" Href="features/chart-data" />
125126
<NavbarMenuItem Text="Export" Href="features/export" />
126127
<NavbarMenuItem Text="Formatters" Href="features/formatters" />
127128
<NavbarMenuItem Text="Legend" Href="features/legend" />

src/Blazor-ApexCharts/ApexChart.razor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ private void SetSeries()
502502
Options.Series = new List<Series<TItem>>();
503503
var isMixed = apexSeries.Select(e => e.GetChartType()).Distinct().Count() > 1;
504504

505+
if (apexSeries == null || !apexSeries.Any()) { throw new Exception($"Chart {chartId} must have at least one series"); };
506+
505507
foreach (var apxSeries in apexSeries)
506508
{
507509
var series = new Series<TItem>

0 commit comments

Comments
 (0)