This is a migrated thread and some comments may be shown as answers.

Numeric Gauge - Initial value showing as NaN

3 Answers 193 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
Shanmugam
Top achievements
Rank 1
Shanmugam asked on 10 Dec 2010, 11:37 AM
I have binded the data to the numeric gauge control, data which ever binded is showing perfectly, but at inital level it shows value as NaN in the NumericPositions.

Please find the attached screenshot and here is my code

<telerik:RadGauge x:Name="radGauge"
                          Height="45"
                          VerticalAlignment="Stretch"
                          HorizontalAlignment="Stretch"
                          Margin="-15,0,0,0"
                          BorderThickness="0">
            <telerik:NumericScale Min="0" Width="155" BorderThickness="0" >
                <telerik:IndicatorList BorderThickness="0" >
                    <telerik:NumericIndicator x:Name="numericIndicator"
                                              Format="{}{0:F2}"
                         Foreground="DarkBlue"
                                              Left="0"
                                              Top="0"
                                              Value="{Binding ProjectVisibilityDataProp.Visibility}"
                                              RelativeWidth="1.009"
                                              RelativeHeight="0.99"
                                              Background="White"
                                              BorderThickness="0"
                                              FontSize="45">
                        <telerik:NumberPosition CornerRadius="0" />
                        <telerik:NumberPosition CornerRadius="0" />
                        <telerik:NumberPosition CornerRadius="0"  RelativeWidth="0.5" />
                        <telerik:NumberPosition CornerRadius="0" />
                        <telerik:NumberPosition CornerRadius="0" />
                    </telerik:NumericIndicator>
                </telerik:IndicatorList>
            </telerik:NumericScale>
        </telerik:RadGauge>

Thanks
Shanmugam

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 15 Dec 2010, 08:39 AM
Hello Shanmugam,

It is hard to say without your code, but I suppose that you didn't set an initial value to the correspondent property in your data context. I've created a sample application which uses a data model to bind numeric indicator value to. All things works just fine. The numeric indicator shows an initial value properly. Here it is XAML and code:

<telerik:RadGauge x:Name="radGauge"
        Height="45"
        VerticalAlignment="Stretch" 
        HorizontalAlignment="Stretch"
        BorderThickness="0">
    <telerik:NumericScale Name="numericScale" Min="0" Width="155" BorderThickness="0" >
        <telerik:IndicatorList BorderThickness="0" >
            <telerik:NumericIndicator x:Name="numericIndicator" 
                Format="{}{0:F2}"
                Foreground="DarkBlue" 
                Left="0" 
                Top="0" 
                Value="{Binding Value}"
                RelativeWidth="1.009"
                RelativeHeight="0.99"
                Background="White" 
                BorderThickness="0"
                FontSize="45">
                <telerik:NumberPosition CornerRadius="0" />
                <telerik:NumberPosition CornerRadius="0" />
                <telerik:NumberPosition CornerRadius="0"  RelativeWidth="0.5" />
                <telerik:NumberPosition CornerRadius="0" />
                <telerik:NumberPosition CornerRadius="0" />
                </telerik:NumericIndicator>
        </telerik:IndicatorList>
    </telerik:NumericScale>
</telerik:RadGauge>

public class GaugeDataModel : INotifyPropertyChanged
{
    private double valueToShow;
  
    public double Value
    {
        get
        {
            return this.valueToShow;
        }
  
        set
        {
            this.valueToShow = value;
            OnPropertyChanged("Value");
        }
    }
  
    public event PropertyChangedEventHandler PropertyChanged;
  
    private void OnPropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

public partial class MainPage : UserControl
{
    private Random rnd = new Random();
  
    public MainPage()
    {
        InitializeComponent();
  
        GaugeDataModel model = new GaugeDataModel()
        {
            Value = this.GetNewValue(this.numericScale)
        };
        this.DataContext = model;
    }
  
    private double GetNewValue(RangedControl scale)
    {
        return scale.Min + (scale.Max - scale.Min) * rnd.NextDouble();
    }
}


Greetings,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Shanmugam
Top achievements
Rank 1
answered on 15 Dec 2010, 08:50 AM
Thank you very much for your reply.

I am binding the value as you explained below, am facing problem when its getting loaded, before gets load of value it shows the value as NaN, Value="NaN" appears for a 1 or 2 sec's and after that binded value appears..

Thanks
0
Accepted
Andrey
Telerik team
answered on 17 Dec 2010, 01:53 PM
Hello Shanmugam,

I suppose that you populate your data from the kind of web or WCF service. So the ProjectVisibilityDataProp.Visibility property has not initial value. The default value for any unset doubles is NaN. If you want to show something other than NaN in the numeric indicator while actual values will be loaded you should set this initial value to the correspondent property like it is done in my code snippet, posted previously.

Best wishes,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Gauge
Asked by
Shanmugam
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Shanmugam
Top achievements
Rank 1
Share this question
or