-
Notifications
You must be signed in to change notification settings - Fork 107
/
StatisticsLineChart.razor
77 lines (63 loc) · 2.79 KB
/
StatisticsLineChart.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<Card>
<CardBody>
<div class="d-flex align-items-center">
<div class="subheader">Revenue</div>
<div class="ms-auto lh-1">
<Dropdown>
<ChildContent>
<a class="dropdown-toggle text-secondary" aria-haspopup="true" aria-expanded="false">
Last 7 days
</a>
</ChildContent>
<DropdownTemplate>
<DropdownMenu>
<DropdownItem>Last 7 Days</DropdownItem>
<DropdownItem>Last 30 days</DropdownItem>
<DropdownItem>Last 3 months</DropdownItem>
</DropdownMenu>
</DropdownTemplate>
</Dropdown>
</div>
</div>
<div class="d-flex align-items-baseline">
<div class="h1 mb-3 me-2">@orders.Sum(e => e.GrossValue).ToString("N0")$</div>
<div class="me-auto">
<span class="text-red d-inline-flex align-items-center lh-1">
-8%
<Icon class="icon" IconType="@TablerIcons.Trending_down"></Icon>
</span>
</div>
</div>
<div>
<ApexChart TItem="Order"
Height="40"
XAxisType="XAxisType.Datetime"
Options="GetOptions()">
<ApexPointSeries TItem="Order"
Items="orders"
SeriesType="SeriesType.Line"
Name="Gross Value"
XValue="@(e => e.OrderDate.FirstDayOfMonth())"
YAggregate="@(e => Decimal.Round(e.Sum(e => e.GrossValue)))"
OrderBy="e=>e.X" />
<ApexPointSeries TItem="Order"
Items="orders"
Name="Net Value"
XValue="@(e => e.OrderDate.FirstDayOfMonth())"
YAggregate="@(e => Decimal.Round(e.Sum(e => e.NetValue * (decimal)0.2)))"
OrderBy="e=>e.X" />
</ApexChart>
</div>
</CardBody>
</Card>
@code {
private List<Order> orders = SampleData.GetOrders();
private ApexCharts.ApexChartOptions<Order> GetOptions()
{
var options = new ApexCharts.ApexChartOptions<Order>();
options.Colors = new List<string> { "#206bc4" };
options.Chart = new Chart { Sparkline = new ChartSparkline { Enabled = true } };
options.Stroke = new Stroke { Width = 3, DashArray = new int[] { 0, 3 }, Colors = new List<string> { "#206bc4", "#999999" } };
return options;
}
}