3 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Mar 2013, 04:42 AM
Hello Antony,
Please have a look into the following C# code to programmatically create gauge range and set different color to those ranges.
C#:
Thanks,
Princy.
Please have a look into the following C# code to programmatically create gauge range and set different color to those ranges.
C#:
//Create new GaugeRange object
GaugeRange gr1 =
new
GaugeRange();
//Set the properties of the new object
gr1.From = 0;
gr1.To = (
decimal
)0.4;
gr1.Color = System.Drawing.Color.Green;
GaugeRange gr2 =
new
GaugeRange();
gr2.From = (
decimal
)0.4;
gr2.To = (
decimal
)0.8;
gr2.Color = System.Drawing.Color.Yellow;
GaugeRange gr3 =
new
GaugeRange();
gr3.From = (
decimal
)0.8;
gr3.To = (
decimal
)1.2;
gr3.Color = System.Drawing.Color.FromArgb(225, 0, 0);
//Add Gauge objects to the RadialGauge
//Let radialGauge be an instance of RadRadialGauge class.
RadRadialGauge radialGauge = new RadRadialGauge();
radialGauge.Scale.Ranges.Add(gr1);
radialGauge.Scale.Ranges.Add(gr2);
radialGauge.Scale.Ranges.Add(gr3);
Thanks,
Princy.
0
Antony
Top achievements
Rank 1
answered on 13 Mar 2013, 09:07 AM
Thanks princy. Also how to set a label for the gauge range values?
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Mar 2013, 09:18 AM
Hello Antony,
You can set labels using the Label tag. Please have a look into the following mark-up that illustrates how to add labels to gauge range values.
ASPX:
Thanks,
Princy.
You can set labels using the Label tag. Please have a look into the following mark-up that illustrates how to add labels to gauge range values.
ASPX:
<
telerik:RadLinearGauge
runat
=
"server"
ID
=
"RadLinearGauge"
Height
=
"100px"
Width
=
"300px"
>
<
Pointer
Value
=
"22"
Color
=
"Silver"
>
</
Pointer
>
<
Scale
Min
=
"-25"
Max
=
"50"
MajorUnit
=
"15"
MinorUnit
=
"1"
MajorTicks-Size
=
"20"
MinorTicks-Size
=
"10"
Vertical
=
"false"
>
<
Labels
Format
=
"{0} °C"
/>
<
Ranges
>
<
telerik:GaugeRange
From
=
"-25"
To
=
"-5"
Color
=
"Blue"
/>
<
telerik:GaugeRange
From
=
"-5"
To
=
"15"
Color
=
"LightBlue"
/>
<
telerik:GaugeRange
From
=
"15"
To
=
"30"
Color
=
"GreenYellow"
/>
<
telerik:GaugeRange
From
=
"30"
To
=
"50"
Color
=
"Red"
/>
</
Ranges
>
</
Scale
>
</
telerik:RadLinearGauge
>
Thanks,
Princy.