forked from syncfusion/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Legend.razor
71 lines (67 loc) · 2.45 KB
/
Legend.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
@page "/bullet-chart/legend"
@using Syncfusion.Blazor.Charts
@using Syncfusion.Blazor
@inject NavigationManager NavigationManager
@inherits SampleBaseComponent;
<SampleDescription>
<p>This sample illustrates a bullet chart with legend. Legend is used to know what the colors and shapes represent in bullet chart.</p>
</SampleDescription>
<ActionDescription>
<p>Tooltip is enabled in this example, to see the tooltip in action, hover a feature bar or comparative bar on the bullet chart.</p>
</ActionDescription>
<div class="control-section">
<div align="center">
<SfBulletChart DataSource="@BulletChartData0" ValueField="value" Theme="@theme" TargetField="target" Minimum="0" Maximum="30" Interval="5"
Title="Package Downloads" Subtitle="in Thousands" Width="70%" Height="160">
<BulletChartTooltip TValue="ChartData" Enable="true"></BulletChartTooltip>
<BulletChartLegendSettings Visible="true"></BulletChartLegendSettings>
<BulletChartRangeCollection>
<BulletChartRange End="8" Color="#CA4218" Name="Poor"> </BulletChartRange>
<BulletChartRange End="18" Color="#EFC820" Name="Avg"></BulletChartRange>
<BulletChartRange End="30" Color="#599C20" Name="Good"></BulletChartRange>
</BulletChartRangeCollection>
</SfBulletChart>
</div>
</div>
@code{
public bool visible = true;
public class ChartData
{
public double value { get; set; }
public double[] target { get; set; }
}
public List<ChartData> BulletChartData0 = new List<ChartData>
{
new ChartData { value = 25, target = new double[] { 20, 26, 28 } }
};
private string CurrentUri;
private Theme theme { get; set; }
protected override void OnInitialized()
{
CurrentUri = NavigationManager.Uri;
if (CurrentUri.IndexOf("material") > -1)
{
theme = Theme.Material;
}
else if (CurrentUri.IndexOf("fabric") > -1)
{
theme = Theme.Fabric;
}
else if (CurrentUri.IndexOf("bootstrap") > -1)
{
theme = Theme.Bootstrap;
}
else if (CurrentUri.IndexOf("highcontrast") > -1)
{
theme = Theme.HighContrast;
}
else if (CurrentUri.IndexOf("tailwind") > -1)
{
theme = Theme.Tailwind;
}
else
{
theme = Theme.Bootstrap4;
}
}
}