How to read selectedPoint.DataItem in RadCartesianChartView

0 Answers 58 Views
Chart Chart - Xamarin.Android
HV
Top achievements
Rank 1
HV asked on 13 Jun 2023, 01:56 PM | edited on 13 Jun 2023, 01:58 PM


Hi,

I'm trying to read the value of selectedPoint.DataItem in RadCartesianChartView when selecting the bar. 

DataPoint selectedPoint = e.P0.SelectedDataPoint();
var dataItem = selectedPoint.DataItem;
Casting the dataItem to C# object like
public class CastJavaObject
    {
        public static T Cast<T>(Java.Lang.Object? obj) where T : class
        {
            var propInfo = obj.GetType().GetProperty("Instance");
            return propInfo == null ? null : propInfo.GetValue(obj, null) as T;
        }
    }
and using the CastJavaObject like
var poco = CastJavaObject.Cast<Result>(dataItem);
The problem is Casting the dataItem always null. Any help on reading the dataItem values.

Thanks.
HV
Top achievements
Rank 1
commented on 14 Jun 2023, 04:21 AM

@Didi any help?

 

Didi
Telerik team
commented on 16 Jun 2023, 01:50 PM

Hi, 
I am researching this case and will send an update next week. 
Didi
Telerik team
commented on 22 Jun 2023, 01:35 PM

Hi, 

You have the information for the selected point in this way:

ChartSelectionBehavior selectionBehavior = new ChartSelectionBehavior();
            selectionBehavior.SeriesSelectionMode = ChartSelectionMode.None;
			selectionBehavior.DataPointsSelectionMode = ChartSelectionMode.Single;	
            chart.Behaviors.Add(selectionBehavior);
            selectionBehavior.SelectionChange += SelectionBehavior_SelectionChange;

        private void SelectionBehavior_SelectionChange(object sender, ChartSelectionChangeEventArgs e)
        {
            DataPoint selectedPoint = e.P0.SelectedDataPoint();
        }

How to display the data is up to you. This requires custom development from your side. 

 

No answers yet. Maybe you can help?

Tags
Chart Chart - Xamarin.Android
Asked by
HV
Top achievements
Rank 1
Share this question
or