How to read clicked bar AxisLabelElement

1 Answer 31 Views
ChartView
Omar
Top achievements
Rank 3
Iron
Iron
Iron
Omar asked on 22 Sep 2023, 08:46 PM | edited on 23 Sep 2023, 11:44 AM

Hi,

I would like to know how we get the clicked bar AxisLabelElement?

What I mean, is when I click on the chart View certain bar I would like to read its Axis label.

Many thanks in advance

Omar

1 Answer, 1 is accepted

Sort by
1
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 25 Sep 2023, 08:27 AM

Hi Omar,

You could use the Selectionbehavior of the control. By setting the SelectionMode to SingleDataPoint, clicking on a bar data point will trigger the SelectedPointChanged event. In the event handler, you can get the selected data point value and category label.

this.radChartView1.SelectionMode = ChartSelectionMode.SingleDataPoint;
this.radChartView1.SelectedPointChanged += RadChartView1_SelectedPointChanged;

private void RadChartView1_SelectedPointChanged(object sender, ChartViewSelectedPointChangedEventArgs e)
{
    if (e.NewSelectedPoint != null)
    {
        var point = e.NewSelectedPoint as CategoricalDataPoint;
        string columnCaller = "";
        columnCaller = "Category: " + point.Category + "//  Value: " + point.Value;
        MessageBox.Show(columnCaller);
    }
}

I hope that this approach will work for you.

Regards,
Dinko | Tech Support Engineer
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.

Omar
Top achievements
Rank 3
Iron
Iron
Iron
commented on 25 Sep 2023, 04:45 PM

It worked perfectly.

Many thanks,

Omar

 

 

Tags
ChartView
Asked by
Omar
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or