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

RadCartesianChart and nullable values on iOS

1 Answer 62 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Cleanwatts
Top achievements
Rank 1
Cleanwatts asked on 19 Jan 2018, 04:31 PM

I was trying to create a chart where some of the values might be missing, using the following class for the chart data:

public class DashboardData
{
    public string Category { get; set; }
    public double? Value { get; set; }
}

 

When running on iOS I get the following exception when showing the chart (it works on Android and UWP):

 

System.NullReferenceException: Object reference not set to an instance of an object
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x000c0] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at (wrapper managed-to-native) ApiDefinition.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
  at TelerikUI.TKChart.set_XAxis (TelerikUI.TKChartAxis value) [0x00047] in <5bae2bad360b4d5da328902516ddda38>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartAdapter.UpdateXAxis (Telerik.XamarinForms.Chart.RadCartesianChart sourceOwner, TelerikUI.TKChart targetOwner) [0x0002e] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartAdapter.UpdateCore (Telerik.XamarinForms.Chart.RadCartesianChart sourceOwner, Telerik.XamarinForms.ChartRenderer.iOS.TKExtendedChart targetOwner, System.String propertyName, Telerik.XamarinForms.Common.IParentElement sourceOwnerRoot, System.Object targetOwnerRoot) [0x0003f] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartAdapter`1[S].Update (System.Object sourceOwner, System.Object targetOwner, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00000] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at Telerik.XamarinForms.Common.XamarinToNativeControlExtensions.Update[T,K] (T nativeElement, K xfЕlement, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00031] in <be10754fe83d4f30b3bf0368f5628901>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartRenderer`1[T].OnElementAttached (T newElement) [0x00068] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartRenderer.OnElementAttached (Telerik.XamarinForms.Chart.RadCartesianChart newElement) [0x00000] in <7703bf205c0d44fb9c68eb78a97e22de>:0
  at Telerik.XamarinForms.Common.iOS.IosRendererBase`2[S,T].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x00037] in <be10754fe83d4f30b3bf0368f5628901>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00110] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:189
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:140
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000cc] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:176
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:140
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:129
  at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x00029] in D:\agent\_work\1\s\Xamarin.Forms.Core\Element.cs:375
  at Xamarin.Forms.VisualElement.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\VisualElement.cs:578
  at Xamarin.Forms.Layout`1[T].OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\Layout.cs:32
  at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x0001d] in D:\agent\_work\1\s\Xamarin.Forms.Core\Layout.cs:416
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00089] in D:\agent\_work\1\s\Xamarin.Forms.Core\Layout.cs:406
  at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
  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/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:219
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:67
  at Xamarin.Forms.ObservableWrapper`2[TTrack,TRestrict].Add (TRestrict item) [0x0004b] in D:\agent\_work\1\s\Xamarin.Forms.Core\ObservableWrapper.cs:35
  at Telerik.XamarinForms.Primitives.RadBusyIndicator.set_VisibleContent (Xamarin.Forms.View value) [0x00042] in <af0c70c9531f45dda8deaaa076f7473e>:0
  at Telerik.XamarinForms.Primitives.RadBusyIndicator.DisplayActualContent () [0x00017] in <af0c70c9531f45dda8deaaa076f7473e>:0
  at Telerik.XamarinForms.Primitives.RadBusyIndicator.OnIsBusyPropertyChanged (Telerik.XamarinForms.Primitives.RadBusyIndicator indicator, System.Boolean oldValue, System.Boolean newValue) [0x00000] in <af0c70c9531f45dda8deaaa076f7473e>:0
  at Telerik.XamarinForms.Common.BindablePropertyExtensions+<>c__DisplayClass6_0`2[TDeclarer,TPropertyType].<Create>b__0 (Xamarin.Forms.BindableObject b, System.Object o, System.Object n) [0x00000] in <be10754fe83d4f30b3bf0368f5628901>:0
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x0011b] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindableObject.cs:597
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindableObject.cs:391
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:174
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:547
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/Foundation/NSAction.cs:163
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-

 

If I alter double? to double in the data class and adjust the code accordingly then the chart shows as it should and there is no exception.

 

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 24 Jan 2018, 08:38 AM
Hi,

At the moment null values are not supported in our chart. This is logged in our feedback portal where you can track the feature request and vote for it. Please, accept our apologies for not being able to meet your requirements.

Best regards,
Ves
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
Cleanwatts
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or