We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Handling of 'missing' NaN points

I am using nearly identical SfChart code in a Xamarin Forms app and a UWP app. Missing point YValue in both apps is designated with NaN. In the UWP app the charts with missing points render correctly. In the Xamarin Forms app the chart scale reverts to the range 0.0 to 1.0 and the chart renders wildly out of scale.

The Xamarin Forms documentation does not discuss how to handle missing values or if NaN is supposed to be used. I noticed that the WPF documentation for example does discuss NaN and the ShowEmptyPoints property. I also noticed that UWP behaviour is to skip missing values designated with NaN values. So why doesn't Xamarin Forms discuss missing values?

Is there a way of making the Xamarin Forms SfChart handle missing data points correctly?

Thanks, Greg

6 Replies

UN Unknown February 14, 2017 04:03 AM UTC

I have more information that probably invalidates my question. A colleague has reported that the Xamarin Forms SfChart does show gaps for missing NaN values as expected, and he pointed out that the wildly out of scale charts only resulted when a whole series consisted of NaN points. A complete series of NaN could arguably be considered "bad data" and it's being cleaned to avoid this problem.

So there probably isn't a bug or quirk in the Xamarin Forms SfChart NaN point handling. However it just doesn't seem to have the properties available for UWP and WPF to control behaviour.

Greg


PS Parthiban Sundaram Syncfusion Team February 16, 2017 01:31 PM UTC

Hi Greg,

Thanks for using Syncfusion products.

Current we do not have this support in SfChart for Xamarin.Forms. Could you please let us know how do you want to handle the empty data points so that we can provide you further assistance on this.

In UWP, we have following types to display the empty values.

1. Zero – Replace all the empty values to zero (0).
2. Average – Replace all the empty values with average value.

Reference link: https://help.syncfusion.com/uwp/sfchart/emptypoints

Please let us know if you need any clarifications.

Regards,
Parthiban S



RE redth April 29, 2018 02:14 PM UTC

Opening this again, I see that "ShowEmptyPoints" and "EmptyPointValue" are both still unsupported on Xamarin.Forms.

Are there any plans to expose this feature?  I would really like to be able to show the "Average" empty point values.

For now I will have to try and add my own data to the series manually to achieve this.


DV Divya Venkatesan Syncfusion Team May 2, 2018 02:40 PM UTC

Hi Jonathan, 
 
Thanks for your feedback. 
 
By considering the empty point use cases, we have exposed the API in ChartSegment called Empty to know whether the value of the segment is empty. As of now, this property is available in native chart, so you need to write custom renderer to modify the empty points as per your need. We have prepared a sample to show the average value at empty point indexes, please download the sample from below location. 
 
In UWP we can achieve your requirement by setting ShowEmptyPoints property in in CustomRenderer as per the below code snippet. 
 
Code snippet [C#]: 
protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e) 
        { 
            base.OnElementChanged(e); 
            if (Control != null) 
            { 
                foreach (var series in Control.Series) 
                { 
                    series.ShowEmptyPoints = true; 
                    series.EmptyPointValue = Syncfusion.UI.Xaml.Charts.EmptyPointValue.Average; 
                } 
            } 
        } 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Divya Venkatesan 
 



RE redth replied to Divya Venkatesan June 11, 2018 06:24 PM UTC

Hi Jonathan, 
 
Thanks for your feedback. 
 
By considering the empty point use cases, we have exposed the API in ChartSegment called Empty to know whether the value of the segment is empty. As of now, this property is available in native chart, so you need to write custom renderer to modify the empty points as per your need. We have prepared a sample to show the average value at empty point indexes, please download the sample from below location. 
 
In UWP we can achieve your requirement by setting ShowEmptyPoints property in in CustomRenderer as per the below code snippet. 
 
Code snippet [C#]: 
protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e) 
        { 
            base.OnElementChanged(e); 
            if (Control != null) 
            { 
                foreach (var series in Control.Series) 
                { 
                    series.ShowEmptyPoints = true; 
                    series.EmptyPointValue = Syncfusion.UI.Xaml.Charts.EmptyPointValue.Average; 
                } 
            } 
        } 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Divya Venkatesan 
 


Hi Divya,

This might work on UWP, but what about iOS and Android? Those are the platforms I'm more interested in seeing this functionality on :(


DV Divya Venkatesan Syncfusion Team June 12, 2018 12:16 PM UTC

Hi Redth, 
 
Thanks for contacting Syncfusion support. 
 
For Android and iOS also we have done the empty point implementation in our previous updated sample, we have done the sample to show the average empty point values by overriding CreateSegments method in class extended from LineSeries based on Empty property of ChartSegment. Please refer CustomLineSeries.cs file in platform specific projects. Please find the CustomLineSeries code snippet below. 
 
Code snippet [Android]: 
protected override void CreateSegments() 
{ 
    base.CreateSegments(); 
 
       foreach (var segment in this.Segments) 
       { 
           PropertyInfo emptyInfo = typeof(ChartSegment).GetProperty("Empty", BindingFlags.NonPublic | BindingFlags.Instance); 
           bool isEmpty = (bool)emptyInfo.GetValue(segment, null); 
           if (isEmpty == true) 
           { 
              isEmpty = !isEmpty; 
              emptyInfo.SetValue(segment, isEmpty); 
              HandleEmpltyPoints(segment as LineSegment); 
           } 
      } 
} 
 
Code snippet [iOS]: 
public override void CreateSegments() 
{ 
    base.CreateSegments(); 
       foreach (var segment in this.Segments) 
    {                 
           if (segment.Empty == true) 
        { 
                  segment.Empty = !segment.Empty; 
                      HandleEmpltyPoints(segment as SFLineSegment); 
        } 
    } 
} 
  
 
Please let us know if you need any further assistance.  
 
Regards, 
Divya Venkatesan 


Loader.
Live Chat Icon For mobile
Up arrow icon