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.
Unfortunately, activation email could not send to your email. Please try again.

Handling of 'missing' NaN points

Thread ID:

Created:

Updated:

Platform:

Replies:

128879 Feb 13,2017 08:15 PM Jun 12,2018 08:16 AM Xamarin.Forms 6
loading
Tags: SfChart
Greg Keogh
Asked On February 13, 2017 08:15 PM

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

Greg Keogh
Replied On February 13, 2017 11:03 PM

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

Parthiban Sundaram [Syncfusion]
Replied On February 16, 2017 08:31 AM

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


redth
Replied On April 29, 2018 10:14 AM

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.

Divya Venkatesan [Syncfusion]
Replied On May 2, 2018 10:40 AM

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 
 


redth
Replied On June 11, 2018 02:24 PM

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 :(

Divya Venkatesan [Syncfusion]
Replied On June 12, 2018 08:16 AM

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;