This is a migrated thread and some comments may be shown as answers.

How to Implement item click event in Chart view

1 Answer 678 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Shanti 😎
Top achievements
Rank 2
Veteran
Shanti 😎 asked on 02 Dec 2020, 06:07 AM

Hi,

How to Implement item click event in Chartview Pie and Bar. (not ledger Click)

If it possible to store and retrieve item Id also ?.

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Dec 2020, 01:02 PM

Hello, Tovino,    

In order to detect which data point is clicked you can use the following approach:
        public RadForm1()
        {
            InitializeComponent();

            BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
            barSeries.ShowLabels = true;
            barSeries.DataPoints.Add(new CategoricalDataPoint(177, "Harley"));
            barSeries.DataPoints.Add(new CategoricalDataPoint(128, "White"));
            barSeries.DataPoints.Add(new CategoricalDataPoint(143, "Smith"));
            barSeries.DataPoints.Add(new CategoricalDataPoint(111, "Jones"));
            barSeries.DataPoints.Add(new CategoricalDataPoint(118, "Marshall")); 
            this.radChartView1.Series.Add(barSeries);
           
            this.radChartView1.MouseDown += radChartView1_MouseDown;
        }

        private void radChartView1_MouseDown(object sender, MouseEventArgs e)
        {
            foreach (var s in this.radChartView1.Series)
            {
                BarSeries ls = s as BarSeries;
                DataPoint dp = ls.HitTest(e.Location.X, e.Location.Y);
                if (ls != null && dp != null)
                {
                    Console.WriteLine(dp.Label); 
                }
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ChartView
Asked by
Shanti 😎
Top achievements
Rank 2
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or