Skip to content

Commit 1547950

Browse files
authored
Merge pull request #192 from apexcharts/add-total-formatter
Added RadialBar total formatter
2 parents 3768630 + d87230a commit 1547950

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

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": "features/chart-data",
6+
"launchUrl": "radialbar-charts",
77
"environmentVariables": {
88
"ASPNETCORE_ENVIRONMENT": "Development"
99
}

docs/BlazorApexCharts.Docs/Components/ChartTypes/RadialBarCharts/RadialBarCharts.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@
88
</Snippet>
99
</CodeSnippet>
1010

11+
<CodeSnippet Title="Total Formatter" ClassName=@typeof(TotalFormatter).ToString()>
12+
<Snippet>
13+
<TotalFormatter />
14+
</Snippet>
15+
</CodeSnippet>
16+
1117
</DocExamples>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
<DemoContainer>
3+
<ApexChart TItem="Order"
4+
Title="Discount"
5+
Options="options">
6+
7+
<ApexPointSeries TItem="Order"
8+
Items="orders"
9+
SeriesType=SeriesType.RadialBar
10+
Name="Gross Value"
11+
XValue="@(e => e.Country)"
12+
YAggregate="@(e => decimal.Round(e.Average(e => e.DiscountPercentage)))"
13+
OrderByDescending="e=>e.Y" />
14+
</ApexChart>
15+
</DemoContainer>
16+
17+
18+
19+
@code {
20+
private List<Order> orders = SampleData.GetOrders();
21+
private ApexChartOptions<Order> options = new();
22+
23+
protected override void OnInitialized()
24+
{
25+
26+
options.PlotOptions = new PlotOptions
27+
{
28+
RadialBar = new PlotOptionsRadialBar
29+
{
30+
DataLabels = new RadialBarDataLabels
31+
{
32+
Total = new RadialBarDataLabelsTotal
33+
{
34+
Show = true,
35+
Label = "My Total",
36+
FontSize = "24",
37+
Formatter = @"function (w) {
38+
return '[' + w.globals.seriesTotals.reduce((a, b) => {
39+
return a + b
40+
}, 0) / w.globals.series.length + '%' + ']'
41+
}"
42+
}
43+
}
44+
}
45+
};
46+
47+
}
48+
}

src/Blazor-ApexCharts/Models/ApexChartOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@ public class RadialBarDataLabelsTotal
11191119
public object FontWeight { get; set; }
11201120
public string Label { get; set; }
11211121
public bool? Show { get; set; }
1122+
public string Formatter { get; set; }
11221123
}
11231124

11241125
public class RadialBarDataLabelsValue

0 commit comments

Comments
 (0)