Getting Started
This article will guide you through the steps needed to add a basic RadGauge control in your application.
1. Setting up the app
Take a look at these articles and follow the instructions to setup your app:
2. Adding the required Telerik references
You have two options:
- Add the Telerik UI for Xamarin Nuget package following the instructions in Telerik NuGet package server topic.
If you don't want to add the all Telerik.UI.for.Xamarin nuget package, you have the option to add a separate nuget package. For RadGauge control you have to install the Telerik.UI.for.Xamarin.DataVisualization nuget package. This nuget will automatically refer the Telerik.UI.for.Xamarin.Common and Telerik.UI.for.Xamarin.SkiaSharp nuget packages.
- Add the references to Telerik assemblies manually, check the list below with the required assemblies for RadGauge component:
Platform | Assemblies |
---|---|
Portable | Telerik.XamarinForms.Common.dll Telerik.XamarinForms.DataVisualization.dll Telerik.XamarinForms.SkiaSharp.dll |
Android | Telerik.Xamarin.Android.Common.dll Telerik.XamarinForms.Common.dll Telerik.XamarinForms.DataVisualization.dll Telerik.XamarinForms.SkiaSharp.dll |
iOS | Telerik.XamarinForms.Common.dll Telerik.XamarinForms.DataVisualization.dll Telerik.XamarinForms.SkiaSharp.dll |
UWP | Telerik.XamarinForms.Common.dll Telerik.XamarinForms.DataVisualization.dll Telerik.XamarinForms.SkiaSharp.dll |
3. Adding RadGauge control
You could use one of the following approaches:
Drag the control from the Toolbox.
Take a look at the following topics on how to use the toolbox:
Create the control definition in XAML or C#.
The snippet below shows a simple RadGauge definition:
<telerikGauges:RadRadialGauge x:Name="gauge">
<telerikGauges:RadRadialGauge.Axis>
<telerikGauges:GaugeLinearAxis Maximum="200"
Minimum="0"
Step="25" />
</telerikGauges:RadRadialGauge.Axis>
<telerikGauges:RadRadialGauge.Indicators>
<telerikGauges:GaugeNeedleIndicator Offset="30" Value="60" />
<telerikGauges:GaugeShapeIndicator Value="80" />
</telerikGauges:RadRadialGauge.Indicators>
<telerikGauges:RadRadialGauge.Ranges>
<telerikGauges:GaugeRangesDefinition>
<telerikGauges:GaugeRange Color="Green"
From="0"
To="150" />
<telerikGauges:GaugeGradientRange From="150" To="200">
<telerikCommon:RadGradientStop Offset="150" Color="Yellow" />
<telerikCommon:RadGradientStop Offset="200" Color="Red" />
</telerikGauges:GaugeGradientRange>
</telerikGauges:GaugeRangesDefinition>
</telerikGauges:RadRadialGauge.Ranges>
</telerikGauges:RadRadialGauge>
RadRadialGauge gauge = new RadRadialGauge();
gauge.Axis = new GaugeLinearAxis { Minimum = 0, Maximum = 200, Step = 25 };
gauge.Indicators.Add(new GaugeNeedleIndicator { Value = 60, Offset = 30, });
gauge.Indicators.Add(new GaugeShapeIndicator { Value = 80 });
gauge.Ranges.Ranges.Add(new GaugeRange { From = 0, To = 150, Color = Color.Green });
GaugeGradientRange gradientRange = new GaugeGradientRange { From = 150, To = 200 };
gradientRange.GradientStops.Add(new RadGradientStop { Color = Color.Yellow, Offset = 150 });
gradientRange.GradientStops.Add(new RadGradientStop { Color = Color.Red, Offset = 200 });
gauge.Ranges.Ranges.Add(gradientRange);
In addition to this, you need to add the following namespace:
xmlns:telerikCommon="clr-namespace:Telerik.XamarinForms.Common;assembly=Telerik.XamarinForms.Common"
xmlns:telerikGauges="clr-namespace:Telerik.XamarinForms.DataVisualization.Gauges;assembly=Telerik.XamarinForms.DataVisualization"
using Telerik.XamarinForms.Common;
using Telerik.XamarinForms.DataVisualization.Gauges;
This is the result:
You can follow this tutorial to set up also the RadVerticalGauge and RadHorizontalGauge controls which expose the same API.
Gauge types
There are 2 gauge types that you can use to display different layout - radial and linear (horizontal and vertical). You can read more about these types at the listed articled below:
SDK Browser and QSF applications contain different examples that show Gauges' main features. You can find the applications in the Examples and QSF folders of your local Telerik UI for Xamarin installation.