Unplanned
Last Updated: 01 Jul 2021 13:17 by ADMIN
Kristen
Created on: 10 Jun 2021 20:58
Category: UI for Xamarin
Type: Bug Report
1
chart's plot band annotation for date time axis on iOS throws an exception

We are attempting to use the chart's CartesianPlotBandAnnotation to highlight a section of a graph on a DateTimeContinuousAxis.  This works well on Android, but in our code it produces an exception on iOS (stack trace below).

I attempted to reproduce the problem with the SDKBrowser solution.  I converted the PlotBandAnnotationsCSharp to use a DateTimeContinuousAxis on the horizontal axis, and TemporalData for the ViewModel. When I try to run this on an iOS simulator, it doesn't even navigate to the page; maybe an exception is being thrown and caught that I can't see.

I'm attaching the revised SDKBrowser solution, and including the stack trace from our app (below).

 

System.ArgumentNullException: Value cannot be null.
Parameter name: minimum
  at TelerikUI.TKRange..ctor (Foundation.NSObject minimum, Foundation.NSObject maximum) [0x0000e] in <20898b345e0a4b08b39b1ef59a6e7021>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.PlotBandAnnotationAdapter.UpdateCore (Telerik.XamarinForms.Chart.CartesianPlotBandAnnotation sourceOwner, TelerikUI.TKChartBandAnnotation targetOwner, System.String propertyName, Telerik.XamarinForms.Common.IParentElement sourceOwnerRoot, System.Object targetOwnerRoot) [0x0006d] in <510bffb3000f45598b357d8e04d38717>:0
  at Telerik.XamarinForms.Chart.ChartElementFacadeAdapter`2[S,T].Update (System.Object sourceOwner, System.Object targetOwner, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00000] in <510bffb3000f45598b357d8e04d38717>: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 <a803b4fb350e421cab61e2cee294d08a>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartAdapter.UpdateAnnotations (Telerik.XamarinForms.Chart.RadCartesianChart sourceOwner, TelerikUI.TKChart targetOwner) [0x0002f] in <510bffb3000f45598b357d8e04d38717>: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) [0x0004d] in <510bffb3000f45598b357d8e04d38717>: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 <510bffb3000f45598b357d8e04d38717>: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 <a803b4fb350e421cab61e2cee294d08a>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartRenderer`1[T].OnElementAttached (T newElement) [0x00069] in <510bffb3000f45598b357d8e04d38717>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartRenderer.OnElementAttached (Telerik.XamarinForms.Chart.RadCartesianChart newElement) [0x00000] in <510bffb3000f45598b357d8e04d38717>:0
  at Telerik.XamarinForms.Common.iOS.IosRendererBase`2[S,T].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x0003f] in <a803b4fb350e421cab61e2cee294d08a>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0017a] in <1d764fcfefe54199aacfcb4c6acaaa69>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <1d764fcfefe54199aacfcb4c6acaaa69>:0
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Platform.iOS/Platform.cs:227
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs:115
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs:171
  at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x0000f] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/Element.cs:318
  at Xamarin.Forms.VisualElement.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/VisualElement.cs:774
  at Xamarin.Forms.Layout`1[T].OnChildAdded (Xamarin.Forms.Element child) [0x00000] in <363bc782c0c446ce85b9858aaa9fe112>:0
  at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x0001d] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/Layout.cs:432
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00080] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/Layout.cs:422
  at 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) [0x00018] in <89680362e8f5413398b8929f86f087a0>:0
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <89680362e8f5413398b8929f86f087a0>:0
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in <89680362e8f5413398b8929f86f087a0>:0
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in <da8885cdf78b449d96de00cdb9d47225>:0
  at Xamarin.Forms.ObservableWrapper`2[TTrack,TRestrict].Add (TRestrict item) [0x0004b] in <363bc782c0c446ce85b9858aaa9fe112>:0
  at VuSitu.LiveReadingsGraphingPage.FullScreenGraph (VuSitu.LiveReadingsGraphingPage+ParameterAdapter+ParameterData parameter) [0x007a2] in /Users/kbyers/mobile-apps/JohnnyFive/VuSitu/LiveReadings/LiveReadingsGraphingPage.cs:1111
  at VuSitu.LiveReadingsGraphingPage+ParameterGraph+<>c__DisplayClass0_0.<.ctor>b__2 () [0x00000] in /Users/kbyers/mobile-apps/JohnnyFive/VuSitu/LiveReadings/LiveReadingsGraphingPage.cs:1580
  at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/Command.cs:74
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/Command.cs:112
  at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View sender) [0x00018] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Core/TapGestureRecognizer.cs:44
  at Xamarin.Forms.Platform.iOS.EventTracker+<>c__DisplayClass15_0.<CreateRecognizerHandler>b__0 (UIKit.UITapGestureRecognizer sender) [0x0008f] in /Users/admin/workspace/Xamarin.Forms/Xamarin.Forms/src/Xamarin.Forms.Platform.iOS/EventTracker.cs:208
  at UIKit.UITapGestureRecognizer+Callback.Activated (UIKit.UITapGestureRecognizer sender) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIGestureRecognizer.cs:220
  at 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/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
  at VuSitu.iOS.Application.Main (System.String[] args) [0x0005e] in /Users/kbyers/mobile-apps/JohnnyFive/VuSitu.iOS/Main.cs:27
Attached Files:
5 comments
ADMIN
Didi
Posted on: 01 Jul 2021 13:17

Hello Kristen,

I have researched the case further and found the root of the problem why the annotations are reset when chart data is updated. This is an issue in the native iOS chart control. We have this behavior logged as a bug report in our feedback portal: https://feedback.telerik.com/xamarin/1454595-chart-ios-any-customizations-made-in-the-custom-renderer-are-reset-when-chart-series-are-updated 

Solution:

Basically, create a custom chart class that inherits from RadCartesianChart for example MyCustomChart and implement an event inside the MyCustomChart class. Raise the event when there is a data update. In the renderer, you can subscribe to that event in order to be notified on the data change and update the annotation accordingly.

I have attached a sample solution how this could be achieved. I hope it will be of help in your case.

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
ADMIN
Didi
Posted on: 29 Jun 2021 09:33

Hi Kristen, 

Thank you for the provided project. I will need some time to test the exact scenario and will check whether I can find a solution for it. I will write back with more details today or tomorrow. In the meantime, your patience is highly appreciated.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Kristen
Posted on: 28 Jun 2021 15:24

Hello Didi,

Any update on this?

Thanks!

-Kristen

Kristen
Posted on: 22 Jun 2021 23:18

Hello Didi,

Thank you very much for your response and the custom renderer workaround.  I was able to play around with it and see that it works - as long as the chart's item source remains static.  As soon as I add a new data point, the annotation disappears. I don't know why that would happen.  Can you please help me debug this next problem?

I've attached the xamarin sdk browser example again.  I added the custom renderer and also an asynchronous update to the chart's item source every 5 seconds. Please see PlotBandAnnotationsCSharp.

Thank you!

-Kristen

 

Attached Files:
ADMIN
Didi
Posted on: 15 Jun 2021 14:59

Hello Kristen,

I have easily reproduced the exception. I have changed the item status to "Unplanned". The issue is escalated to the dev team. I am sorry for the inconvenience. 

Workaround: I have managed to find a solution for this annotation using a custom renderer. Here are the listed annotations for the ios chart: 

https://docs.telerik.com/devtools/xamarin/nativecontrols/ios/chart/annotations#plot-band 

I have applied the plotband annotation using renderer. I have attached my project. Please download and test on your side. Check the CustomChartRenderer.cs file inside the iOS project. You may need to extend it further to match the requirements you have. I hope this solution will be of help. 

 

For native Android Chart - Annotations are described here https://docs.telerik.com/devtools/xamarin/nativecontrols/android/chart/chart-annotations#plot-band-annotations 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Attached Files: