RadCartesianChartView selection

1 Answer 71 Views
Chart Chart - Xamarin.Android
HV
Top achievements
Rank 1
HV asked on 06 Jun 2023, 10:15 AM | edited on 06 Jun 2023, 12:53 PM

Hi,

I've added 3 different bar series to RadCartesianChartView and added ChartSelectionBehavior like

 RadCartesianChartView chartView = new RadCartesianChartView(this);
 BarSeries barSeries = new BarSeries();
 BarSeries barSeries1 = new BarSeries();
 BarSeries barSeries2 = new BarSeries();

barSeries.CombineMode = ChartSeriesCombineMode.Stack;
barSeries.CategoryBinding = new MonthResultDataBinding("Month");
barSeries.ValueBinding = new MonthResultDataBinding("Result");
barSeries.SelectedFillColor = Color.Green;
barSeries.SelectedStrokeColor = Color.Red;
barSeries.SelectedStrokeWidth = 5;
barSeries.Data = (Java.Lang.IIterable)this.monthResults;
chartView.Series.Add(barSeries);

barSeries1.CombineMode = ChartSeriesCombineMode.Stack;
barSeries1.CategoryBinding = new MonthResultDataBinding("Month");
barSeries1.ValueBinding = new MonthResultDataBinding("Result1");
barSeries1.SelectedFillColor = Color.Blue;
barSeries1.SelectedStrokeColor = Color.Red;
barSeries1.SelectedStrokeWidth = 5;
barSeries1.Data = (Java.Lang.IIterable)this.monthResults;
chartView.Series.Add(barSeries1); barSeries2.CombineMode = ChartSeriesCombineMode.Stack; barSeries2.CategoryBinding = new MonthResultDataBinding("Month"); barSeries2.ValueBinding = new MonthResultDataBinding("Result2"); barSeries2.SelectedFillColor = Color.Orange; barSeries2.SelectedStrokeColor = Color.Red; barSeries2.SelectedStrokeWidth = 5; barSeries2.Data = (Java.Lang.IIterable)this.monthResults; chartView.Series.Add(barSeries2); ChartSelectionBehavior selectionBehavior = new ChartSelectionBehavior(); selectionBehavior.DataPointsSelectionMode = ChartSelectionMode.Single; chartView.Behaviors.Add(selectionBehavior);

While selecting the bar it selects only one barseries value. How can I select the 3 barseries values on single click.

 

HV
Top achievements
Rank 1
commented on 07 Jun 2023, 12:16 PM | edited

Also, my plan is to add info icon on top of the bar which is selected.
@Didi Any help on this?

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 07 Jun 2023, 12:19 PM

Hello Harman,

The behavior happens as you are using the selection mode to be single on a data point. The selection mode could be set to the series or to the data point. also you can set it to single or multiple. 

The important here is that the selection can be per series or per data point. So you cannot select all three bar series and their data points on a single click. Selection behavior is described here: https://docs.telerik.com/devtools/xamarin/nativecontrols/android/chart/behaviors/chart-behaviors-selection 

You can select all data points from a single bar series by using this code:

ChartSelectionBehavior selectionBehavior = new ChartSelectionBehavior();
            selectionBehavior.SeriesSelectionMode = ChartSelectionMode.Multiple;
            chart.Behaviors.Add(selectionBehavior);

 

I hope I was able to explain how selection works.  

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.

HV
Top achievements
Rank 1
commented on 07 Jun 2023, 12:34 PM | edited

@Didi thanks for your explanation, what about displaying icon on bar click? is that possible
Didi
Telerik team
commented on 07 Jun 2023, 04:24 PM

The scenario is not available out of the box. You can try to implement custom drawing when selection is made.
Tags
Chart Chart - Xamarin.Android
Asked by
HV
Top achievements
Rank 1
Answers by
Didi
Telerik team
Share this question
or