Setting range and color of gauge

4 posts, 2 answers
  1. Antony
    Antony avatar
    32 posts
    Member since:
    Feb 2013

    Posted 11 Mar 2013 Link to this post

    Hello,

    How to programmatically create gauge range and set different color to those range?

    Thank  you,
    Antony.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2013 Link to this post

    Hello Antony,

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Antony
    Antony avatar
    32 posts
    Member since:
    Feb 2013

    Posted 13 Mar 2013 Link to this post

    Thanks princy. Also how to set a label for the gauge range values?
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Mar 2013 Link to this post

    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:
    <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.
Back to Top