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

Chart line series null value ERROR

1 Answer 79 Views
Chart
This is a migrated thread and some comments may be shown as answers.
XamDev
Top achievements
Rank 1
XamDev asked on 25 Jan 2020, 07:08 PM

When our data is loaded and have a null value it causes crash to our app and catches an "Object reference not set to an instance of an object". 
But this issue is only happening on iOS platform. Can someone help me this is a crucial issue for me and my team. 

public class NumericalData
{
    public object XData { get; set; }
 
    public double? YData { get; set; }
}


{System.NullReferenceException: Object reference not set to an instance of an object
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.AddPoints (TelerikUI.TKChartSeries series, System.Collections.IList newItems) [0x00196] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartRenderer`1[T].Telerik.XamarinForms.Chart.IChartRenderer.OnSeriesSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Object series) [0x0004e] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at Telerik.XamarinForms.Chart.ChartSeries.OnItemsSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00017] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196 
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:71 
  at NutritionalFitness.Mobile.ViewModels.ProgramPhaseViewModel.SetGraphsData (System.Collections.Generic.IEnumerable`1[T] weightIns, System.Collections.Generic.IEnumerable`1[T] waterIntakes) [0x00152] in D:\Work\NutritionalFitness\NutritionalFitness.Dev\NutritionalFitnessMobile\NutritionalFitness.Mobile\ViewModels\ProgramPhaseViewModel.cs:184 
  at NutritionalFitness.Mobile.ViewModels.ProgramPhaseViewModel.SetProgramPhaseComponents () [0x002d4] in D:\Work\NutritionalFitness\NutritionalFitness.Dev\NutritionalFitnessMobile\NutritionalFitness.Mobile\ViewModels\ProgramPhaseViewModel.cs:90 }


Aaron
Top achievements
Rank 1
commented on 28 Sep 2021, 09:57 PM

I'm still seeing this bug with Telerik.UI.for.Xamarin.Lite version 2021.2.615.1 -- was there a fix for it?

It seems to be related to the LabelBinding of LineSeries. IF a LabelFormat is not set for the LineSeries, then a NullReferenceException occurs (within ManagedChartDataSource.AddPoints). However, as a workaround, if a LabelFormat is specified (even if ShowLabels=false), then the null values produce gaps in the chart data points, as one would expect. 
Yana
Telerik team
commented on 03 Oct 2021, 08:09 AM

Hi Aaron,

I checked the discussed here bug report and I am not able to reproduce the issue with our latest release. Would it be possible top open a support ticket and send us some code snippets showing the exact setup you have.  Thank you in advance.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 27 Jan 2020, 07:10 AM

Hello,

We've come across such an issue with the upgrade of Visual Studio to 16.3.1.  The exception is resolved with one of the R3 2019 minor releases (2019.3.1004) and is also included in our latest R1 2020 release. Here is the feedback item on the matter:

https://feedback.telerik.com/xamarin/1431067-chart-ios-invalidcastexception-is-thrown-when-the-chart-is-loaded

You need to update to at least 2019.3.1004 to get the exception resolved.

Let me know if you have any additional questions on this.

Regards,
Yana
Progress Telerik

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
Tags
Chart
Asked by
XamDev
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or