forked from syncfusion/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarCustomization.razor
199 lines (180 loc) · 6.81 KB
/
BarCustomization.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@page "/bullet-chart/bar-customization"
@using Syncfusion.Blazor.Charts
@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.DropDowns
@using Newtonsoft.Json;
@using Newtonsoft.Json.Linq;
@using Syncfusion.Blazor
@inject NavigationManager NavigationManager
@inherits SampleBaseComponent;
<SampleDescription>
<p>This sample illustrates a customization of feature bar and comparative bar type in terms of color and width.</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="row">
<div class="control-section col-md-8">
<SfBulletChart DataSource="@BulletChartData" Type="@Type" ValueField="ActualValue" Theme="@theme" TargetField="Targetvalue" Minimum="0" Maximum="300" Interval="50"
ValueFill="@valueFillColor" TargetColor="@targetFillColor" Title="New Customers" Subtitle="in Thousands" TitlePosition="TextPosition.Left">
<BulletChartTooltip TValue="ChartData" Enable="true"></BulletChartTooltip>
<BulletChartRangeCollection>
<BulletChartRange End="150"> </BulletChartRange>
<BulletChartRange End="250"></BulletChartRange>
<BulletChartRange End="300"></BulletChartRange>
</BulletChartRangeCollection>
</SfBulletChart>
</div>
<div class="col-md-4 property-section">
<table style="width: 100%">
<tr style="height:50px"><th>Properties</th></tr>
<tr style="height: 50px">
<td style="width: 60%">
<div>Actual Value:</div>
</td>
<td style="width: 40%;">
<div>
<SfSlider @bind-Value="@actualValue" Min="0" Max="300" Step="10">
<SliderTooltip IsVisible="true"></SliderTooltip>
<SliderEvents TValue="double" OnChange="ChangeActualValue"></SliderEvents>
</SfSlider>
</div>
</td>
</tr>
<tr style="height: 50px">
<td style="width: 60%">
<div>Target Value:</div>
</td>
<td style="width: 40%;">
<div>
<SfSlider @bind-Value="@targetValue" Min="0" Max="300" Step="10">
<SliderTooltip IsVisible="true"></SliderTooltip>
<SliderEvents TValue="double" OnChange="ChangeTagetValue"></SliderEvents>
</SfSlider>
</div>
</td>
</tr>
<tr style="height: 50px">
<td style="width: 60%">
Feature Bar Type:
</td>
<td style="width: 40%;">
<SfDropDownList TValue="string" Placeholder="Rect" TItem="Data" DataSource="@DropDowmData" @bind-Value="@Value">
<DropDownListFieldSettings Value="ID"></DropDownListFieldSettings>
<DropDownListEvents TValue="string" TItem="Data" ValueChange="ChangeType"></DropDownListEvents>
</SfDropDownList>
</td>
</tr>
<tr style="height: 50px">
<td style="width: 60%">
<div>Feature Bar Color:</div>
</td>
<td style="width: 40%;">
<div>
<SfColorPicker Value="@valueFillColor" Mode="ColorPickerMode.Palette" ValueChange="FeatureBarColor"></SfColorPicker>
</div>
</td>
</tr>
<tr style="height: 50px">
<td style="width: 60%">
<div>Target Color:</div>
</td>
<td style="width: 40%;">
<div>
<SfColorPicker Value="@targetFillColor" Mode="ColorPickerMode.Palette" ValueChange="TargetColor"></SfColorPicker>
</div>
</td>
</tr>
</table>
</div>
</div>
@code{
private double targetValue { get; set; } = 250;
private double actualValue { get; set; } = 270;
FeatureType Type;
private string valueFillColor { get; set; } = "#000000";
private string targetFillColor { get; set; } = "#000000";
public GetCurrentValue ColorValue { get; set; }
string Value = "Rect";
public class GetCurrentValue
{
public string hex { get; set; }
public string rgba { get; set; }
}
public void FeatureBarColor(ColorPickerEventArgs args)
{
this.valueFillColor = args.CurrentValue.Hex;
}
public void TargetColor(ColorPickerEventArgs args)
{
this.targetFillColor = args.CurrentValue.Hex;
}
public void ChangeActualValue(SliderChangeEventArgs<double> args)
{
BulletChartData = new List<ChartData>
{
new ChartData { ActualValue = args.Value, Targetvalue = this.BulletChartData[0].Targetvalue }
};
}
public void ChangeTagetValue(SliderChangeEventArgs<double> args)
{
BulletChartData = new List<ChartData>
{
new ChartData { ActualValue = this.BulletChartData[0].ActualValue, Targetvalue = args.Value }
};
}
public class Data
{
public string ID { get; set; }
}
private List<Data> DropDowmData = new List<Data>()
{
new Data(){ ID= "Rect"},
new Data(){ ID= "Dot"}
};
private void ChangeType(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, Data> args)
{
this.Type = (FeatureType)Enum.Parse(typeof(FeatureType), args.Value, true);
StateHasChanged();
}
public class ChartData
{
public double ActualValue { get; set; }
public double Targetvalue { get; set; }
}
public List<ChartData> BulletChartData = new List<ChartData>
{
new ChartData { ActualValue = 270, Targetvalue = 250 }
};
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;
}
}
}