This is a migrated thread and some comments may be shown as answers.
How to get Value label in chart
1 Answer 13 Views
This is a migrated thread and some comments may be shown as answers.
Dwiyan
Top achievements
Rank 1
Dwiyan asked on 11 Jul 2018, 09:18 AM

Is there an event for clicking a chart label Item

 

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Sr.
Telerik team
answered on 11 Jul 2018, 11:55 AM
Hello, Dwiyan,    

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 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(labelElement.Text);
            }
        }
    }
}

I hope this information helps. If you have any additional questions, please let me know.  
 
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Dwiyan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Sr.
Telerik team
Share this question
or