-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.razor
More file actions
64 lines (56 loc) · 2.04 KB
/
Copy pathApp.razor
File metadata and controls
64 lines (56 loc) · 2.04 KB
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
<div style="max-width: 600px; margin: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px;">
<IgbLegend @ref="_legend"></IgbLegend>
<IgbDataChart Width="100%"
Height="300px"
Legend="_legend"
ComputedPlotAreaMarginMode="ComputedPlotAreaMarginMode.Series">
<IgbCategoryXAxis Name="xAxis"
DataSource="_data"
Label="@nameof(DataItem.Index)"
MajorStroke="1">
</IgbCategoryXAxis>
<IgbNumericYAxis Name="yAxis" MinimumValue="10" MaximumValue="16" Interval="1"></IgbNumericYAxis>
<IgbLineSeries Title="Sample Data"
DataSource="_data"
XAxisName="xAxis"
YAxisName="yAxis"
ShowDefaultTooltip="false"
ValueMemberPath="@nameof(DataItem.Value)">
<TooltipTemplate>
@if (context?.Item is DataItem item)
{
<div style="padding: 4px;">
<div><strong>Sample Data</strong></div>
<div><strong>Index:</strong> @item.Index</div>
<div><strong>Value:</strong> @item.Value 件</div>
</div>
}
</TooltipTemplate>
</IgbLineSeries>
</IgbDataChart>
</div>
@code {
public class DataItem
{
public int Index { get; set; }
public double? Value { get; set; }
}
private List<DataItem> _data = new()
{
new(){ Index = 0, Value = 12 },
new(){ Index = 1, Value = 14 },
new(){ Index = 2, Value = 11 },
new(){ Index = 3, Value = 13 },
new(){ Index = 4, Value = 15 },
new(){ Index = 5, Value = 12 },
new(){ Index = 6, Value = 14 },
};
private IgbLegend? _legend;
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
this.StateHasChanged();
}
}
}