Hello Kyle,
Thank you for writing.
RadChartView does not provide means for directly attaching a click event to the label elements. You can achieve your task by handling the MouseClick event of the control and after checking for the mouse and the labels locations:
public
partial
class
RadForm1 : Telerik.WinControls.UI.RadForm
{
public
RadForm1()
{
InitializeComponent();
BarSeries barSeries =
new
BarSeries(
"Performance"
,
"RepresentativeName"
);
barSeries.Name =
"Series1"
;
barSeries.LegendTitle =
"Series1"
;
barSeries.ShowLabels =
true
;
barSeries.DataPoints.Add(
new
CategoricalDataPoint(177,
"Harley"
));
this
.radChartView1.Series.Add(barSeries);
BarSeries barSeries2 =
new
BarSeries(
"Performance"
,
"RepresentativeName"
);
barSeries2.Name =
"Series2"
;
barSeries2.LegendTitle =
"Series2"
;
barSeries2.ShowLabels =
true
;
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(141,
"White"
));
this
.radChartView1.Series.Add(barSeries2);
this
.radChartView1.ShowLegend =
true
;
this
.radChartView1.MouseClick += RadChartView1_MouseClick;
}
private
void
RadChartView1_MouseClick(
object
sender, MouseEventArgs e)
{
foreach
(ChartSeries series
in
this
.radChartView1.Series)
{
foreach
(BarPointElement pointElement
in
series.Children)
{
BarLabelElement labelElement = pointElement.Children[0]
as
BarLabelElement;
Rectangle rect = CartesianRenderer.ToRectangle(labelElement.GetLayoutSlot());
rect.Offset(
this
.radChartView1.ChartElement.View.Margin.Left,
this
.radChartView1.ChartElement.View.Margin.Top);
if
(rect.Contains(
this
.radChartView1.ChartElement.Wrapper.PointFromControl(e.Location)))
{
RadMessageBox.Show(series.Name);
}
}
}
}
}
I am also attaching a short video showing the result on my end.
I hope this helps. Let me know if you need further assistance.
Regards,
Hristo
Progress Telerik