Unplanned
Last Updated: 12 Nov 2019 12:55 by ADMIN
Service
Created on: 17 Oct 2019 21:45
Category: Chart
Type: Bug Report
1
RadPieChart: [iOS] with series labels and any null pie slice throws System.Reflection.TargetException

As of the latest release (10/04/2019) RadPieChart with a PieSeries having LabelBinding set to a property name, and ShowLabels set to True, with the list of data bound to ItemsSource containing one or more empty pie slices (a null in the list), causes a System.Reflection.TargetException to be thrown on load of the page containing the chart in iOS (this scenario works fine in UWP).

I am using the latest available Visual Studio 2019 (16.3.5) and the latest available Xamarin.Forms package (4.2.0.848062) and testing on an iPad with iOS 13.1.  The reason I need to have a null value in the list is so that the custom color palette I'm applying will always apply the same colors to the same data points (pie slices), even though in some cases, zero or one or two of the three pie slices will have no data value (and so should not appear in the chart, but still "use up" the corresponding color in the 3 colors of the palette).

In the 08/02/2019 release, this scenario worked fine in iOS (the 09/13/2019 release had the https://feedback.telerik.com/xamarin/1431067-chart-ios-invalidcastexception-is-thrown-when-the-chart-is-loaded issue, which is now resolved in the 10/04/2019 release, but which prevented my testing in iOS since in my app I had RadCartesianCharts on the same pages as the RadPieCharts).

The newly broken functionality in iOS could possibly be related to two other items that are marked completed:
https://feedback.telerik.com/xamarin/1366403-piechart-tooltip-behavior-is-not-working-properly (in 10/04/2019 release)
https://feedback.telerik.com/xamarin/1365842-chart-null-value-support (in R3 2018 SP release)

4 comments
ADMIN
Pavel R. Pavlov
Posted on: 12 Nov 2019 12:45

Hello,

Thank you for providing additional information about your setup. I was able to reproduce the initially reported System.Reflection.TargetException: 'Non-static method requires a target.'. I would like to turn your attention to the 1st step to reproduce of the provided list of steps "remove the "<telerikChart:PieSeries.ValueBinding><telerikChart:PropertyNameDataPointBinding PropertyName="Value"/></telerikChart:PieSeries.ValueBinding>" specification". Please keep in mind that setting the PieSeries.ValueBinding property is mandatory for the PieSeries to work properly. It is expected the series to throw exception when this property is not set. However, the exception in this case is a NullRefferenceException and it is different from the initially reported one.

In the provided project when I correctly set the PieSeries.ValueBinding property and follow the rest of the steps from the provided list, the System.Reflection.TargetException is consistently  thrown. This successfully reproduces the initially reported issue. The exception actually is inconsistency in the behavior of the RadPieChart for Android and iOS. This is why we consider this bug report as valid.

Please follow this feedback item as this is the best way to stay tuned for any further updates regarding this issue. We will update this item with additional information when we fix the issue.

As a small sign of appreciation of your feedback I updated your Telerik account accordingly.

Regards,
Pavel R. Pavlov
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
Service
Posted on: 08 Nov 2019 22:24
From your example project, I took these steps and reproduced my issue.

-MainPage.xaml:
-remove the "<telerikChart:PieSeries.ValueBinding><telerikChart:PropertyNameDataPointBinding PropertyName="Value"/></telerikChart:PieSeries.ValueBinding>" specification
-PieDataPoint.cs:
-change "double?" to "double"
-PieViewModel.cs:
-change "new PieDataPoint { Value = null }," to "null," in the two places that code exists
-Run application on emulator "iPad Pro (11-inch) iOS 13.2":
-$exception {System.NullReferenceException: Object reference not set to an instance of an object
  at Telerik.XamarinForms.ChartRenderer.iOS.IOSPropertyNameDataBinding.GetValue (System.Object obj) [0x00022] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetDataPoint (TelerikUI.TKChartSeries series, System.nuint dataIndex) [0x0006e] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x0002b] in <2788fa795ab94a7c95843c2265616931>:0 
  at (wrapper managed-to-native) ApiDefinition.Messaging.void_objc_msgSendSuper(intptr,intptr)
  at TelerikUI.TKChart.ReloadData () [0x0002e] in <4df50663b6ee4f319d528612491db1cf>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.TKExtendedChart.<EnqueueReloadData>b__7_0 () [0x00000] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.Common.Dispatcher+<>c__DisplayClass6_0.<ProcessItemsInQueue>b__0 () [0x00036] in <b3d6af25b9654b5881f5a9721531628b>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:152 
  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 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at App8.iOS.Application.Main (System.String[] args) [0x00001] in C:\source\repos\App8\App8\App8.iOS\Main.cs:17 } System.NullReferenceException
-Manage Nuget Packages for solution:
-install Xamarin.Android.Support.Annotations 28.0.0.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Compat step)
-install Xamarin.Android.Support.Collections 28.0.0.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Compat step)
-install Xamarin.Android.Support.VersionedParcelable 28.0.0.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Compat step)
-install Xamarin.Android.Arch.Core.Common 1.1.1.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Compat step)
-install Xamarin.Android.Arch.Lifecycle.Common 1.1.1.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Compat step)
-install Xamarin.Android.Support.Compat 28.0.0.3 to the Android project (because otherwise the nuget dependencies fail to downgrade Xamarin.Forms for the Android project)
-install Xamarin.Android.Arch.Lifecycle.ViewModel 1.1.1.3 to the Android project (because otherwise the nuget dependencies fail on the Xamarin.Android.Support.Loader step)
-install Xamarin.Android.Support.Loader 28.0.0.3 to the Android project (because otherwise the nuget dependencies fail to downgrade Xamarin.Forms for the Android project)
-change the installation of Xamarin.Forms 4.3.0.778476-pre1 to Xamarin.Forms 4.2.0.848062 (as specified in my bug report) for all three projects
-install Xamarin.Android.Support.Core.Utils 28.0.0.3 to the Android project (because otherwise there is a build error like "All installed Android Support library Nuget Packages
 must be the exact same version.")
-Run application on emulator "iPad Pro (11-inch) iOS 13.2":
-$exception {System.NullReferenceException: Object reference not set to an instance of an object
  at Telerik.XamarinForms.ChartRenderer.iOS.IOSPropertyNameDataBinding.GetValue (System.Object obj) [0x00022] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetDataPoint (TelerikUI.TKChartSeries series, System.nuint dataIndex) [0x0006e] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x0002b] in <2788fa795ab94a7c95843c2265616931>:0 
  at (wrapper managed-to-native) ApiDefinition.Messaging.void_objc_msgSendSuper(intptr,intptr)
  at TelerikUI.TKChart.ReloadData () [0x0002e] in <4df50663b6ee4f319d528612491db1cf>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.TKExtendedChart.<EnqueueReloadData>b__7_0 () [0x00000] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.Common.Dispatcher+<>c__DisplayClass6_0.<ProcessItemsInQueue>b__0 () [0x00036] in <b3d6af25b9654b5881f5a9721531628b>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:152 
  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 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at App8.iOS.Application.Main (System.String[] args) [0x00001] in C:\source\repos\App8\App8\App8.iOS\Main.cs:17 } System.NullReferenceException
-PieDataPoint.cs:
-add property `public string PieLabelString
        {
            get => Value == 0.01d
                ? " " //this cannot be an empty string, because that causes a crash in iOS on load of that chart
                : string.Format("{0:C0}", Value);
        }`
-MainPage.xaml:
-change the `LabelBinding="Value"` to `LabelBinding="PieLabelString" ValueBinding="Value"`
-Run application on emulator "iPad Pro (11-inch) iOS 13.2":
-$exception {System.Reflection.TargetException: Non-static method requires a target.
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00019] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:374 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53 
  at Telerik.XamarinForms.ChartRenderer.iOS.IOSPropertyNameDataBinding.GetValue (System.Object obj) [0x0002c] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetDataPoint (TelerikUI.TKChartSeries series, System.nuint dataIndex) [0x0006e] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x0002b] in <2788fa795ab94a7c95843c2265616931>:0 
  at (wrapper managed-to-native) ApiDefinition.Messaging.void_objc_msgSendSuper(intptr,intptr)
  at TelerikUI.TKChart.ReloadData () [0x0002e] in <4df50663b6ee4f319d528612491db1cf>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.TKExtendedChart.<EnqueueReloadData>b__7_0 () [0x00000] in <2788fa795ab94a7c95843c2265616931>:0 
  at Telerik.XamarinForms.Common.Dispatcher+<>c__DisplayClass6_0.<ProcessItemsInQueue>b__0 () [0x00036] in <b3d6af25b9654b5881f5a9721531628b>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:152 
  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 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at App8.iOS.Application.Main (System.String[] args) [0x00001] in C:\source\repos\App8\App8\App8.iOS\Main.cs:17 } System.Reflection.TargetException
-Note that it runs fine in a UWP project (if you had one)
ADMIN
Pavel R. Pavlov
Posted on: 21 Oct 2019 13:31

Hi,

Thank you for bringing this to our attention. I have tried to reproduce the reported behavior on our side by creating a pie chart with labels, custom palette and null values for some of the slices, but the issue does not occur on my side. This is why I will kindly ask you to take a look at the attached project and inspect how I have set it up. I have tested it on both iOS 10 and iOS 13.1 emulators for iPad Pro and iPhone 8. The issue still does not occur. Please take your time to inspect the code of the project and let me know how should I change it in order to reproduce the issue. I am looking forward to hearing from you.

Regards,
Pavel R. Pavlov
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
Attached Files:
Service
Posted on: 18 Oct 2019 17:20
Partial workaround: Make all items not null in the list of data bound to ItemsSource (even though it will put series labels for the values you don't want them on), and possibly build in a case in your bound LabelBinding property that makes the label text for those non-existent values into empty strings.