This is a migrated thread and some comments may be shown as answers.
Documentation?
4 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
JK
Top achievements
Rank 1
JK asked on 17 Feb 2017, 09:54 PM

If there is documentation for the gauges I cannot find it.

 

For example, how do you change the value on the gauge that an indicator is pointing at?

 

            gauge.Indicators.Add(new GaugeNeedleIndicator { Value = 50, Offset = 30, Position = GaugeElementPosition.Start });

So that indicator is pointing at 50, how do you change the value?

4 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 20 Feb 2017, 10:44 AM
Hello Justin,

You can find the gauges related documentation in our Welcome to UI for Xamarin Forms page. You can navigate to the Gauges pages from the list on the right, which includes all our controls or by clicking the Controls expander on the left. In order to change where the needle points, you need to update the Value property of the indicator.

Regards,
Petar Marchev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
JK
Top achievements
Rank 1
answered on 21 Feb 2017, 01:59 PM

"you need to update the Value property of the indicator."

 

Sure, but how?

 

            gauge.Axis = new GaugeLinearAxis { Minimum = 0, Maximum = 200, Step = 25 };
            gauge.Indicators.Add(new GaugeNeedleIndicator { Value = 50, Offset = 30, Position = GaugeElementPosition.Start });
            gauge.Indicators.Add(new GaugeShapeIndicator { Value = 180 });
            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);

 

 

I then have 'gauge.Indicators[0].SetValue()`  This function takes a "BindablePropety` and then an object value.

 

Is this even the right function to call? If so what is a BindableProperty......?

0
JK
Top achievements
Rank 1
answered on 21 Feb 2017, 02:46 PM

This is the closest I could get to 'changing the value', and it has no effect

 

`(gauge.Indicators[0] as GaugeNeedleIndicator).Value = (random.NextDouble() * (199.5 - 1.0) + 1.0);`

0
Lance | Manager Technical Support
Telerik team
answered on 21 Feb 2017, 06:03 PM
Hello Justin,

Yes, you set the Indicator's Value property. Here's a simple example you can use to confirm this:

XAML
<Grid>
    <Grid.RowDefinitions>
      <RowDefinition/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
 
    <telerikGauges:RadRadialGauge>
      <telerikGauges:RadRadialGauge.Axis>
        <telerikGauges:GaugeLinearAxis Minimum="0" Maximum="100" Step="25" />
      </telerikGauges:RadRadialGauge.Axis>
      <telerikGauges:RadRadialGauge.Indicators>
        <telerikGauges:GaugeNeedleIndicator x:Name="Indicator" Value="0" Offset="30" />
      </telerikGauges:RadRadialGauge.Indicators>
      <telerikGauges:RadRadialGauge.Ranges>
        <telerikGauges:GaugeRangesDefinition>
          <telerikGauges:GaugeGradientRange From="0" To="100">
            <common:RadGradientStop Color="Green" Offset="0" />
            <common:RadGradientStop Color="Yellow" Offset="50" />
            <common:RadGradientStop Color="Red" Offset="100" />
          </telerikGauges:GaugeGradientRange>
        </telerikGauges:GaugeRangesDefinition>
      </telerikGauges:RadRadialGauge.Ranges>
    </telerikGauges:RadRadialGauge>
     
    <Slider x:Name="MySlider"
            Minimum="0"
            Maximum="100"
            ValueChanged="MySlider_OnValueChanged"
            Margin="20"
            Grid.Row="1"/>
</Grid>

C#
private void MySlider_OnValueChanged(object sender, ValueChangedEventArgs e)
{
    Indicator.Value = e.NewValue;
}

Here's the demo at runtime:





If I change my approach above to use the Gauge.Indicators collection, it still works as expected:

private void MySlider_OnValueChanged(object sender, ValueChangedEventArgs e)
{
    var indicator = MyGauge?.Indicators[0] as GaugeNeedleIndicator;
 
    if(indicator!=null)
        indicator.Value = e.NewValue;
}



As far as your specific problem goes, I would put a breakpoint there and make sure that you're getting a valid GaugeNeedleIndicator object before setting the Value. 

Let us know how it goes.

If you're still seeing a problem, update the attached ContentPage so that it replicates the problem and send it back. with the reproducible, we can debug it directly.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
JK
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
JK
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or