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

Detect clicking on a chart data item

9 Answers 636 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
johns
Top achievements
Rank 1
johns asked on 13 Jul 2007, 07:16 PM
How do you detect what data item a user clicks on with the mouse.
For example a user clicks on a certain piece of a pie chart or a specific bar on a barchart.  Another possible feature would be to detect the X position in a line chart while the mouse hovers over it so you could display the Y value.

John Schneider

9 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 16 Jul 2007, 04:36 PM
Hello johns,

You should be able to do this using the RadChart Click event which will give you reference to the Series and Series items being clicked. About the second question - RadChart does not currently support a hover event.

We apologize for the inconvenience.

Sincerely yours,
Vladimir Milev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
johns
Top achievements
Rank 1
answered on 20 Jul 2007, 02:42 AM
I can't quite see how to do this.  The RadChart ClickEvent returns a MouseEventArgs object.  Is there another event I should use.

Can you show me some quick sample code.

Many Thanks,

John Schneider
0
Vladimir Milev
Telerik team
answered on 23 Jul 2007, 10:22 AM
Hello johns,

Please, try something like this.

namespace WindowsApplication1 
    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
            foreach(ChartSeries series in radChart1.Series){ 
                foreach(ChartSeriesItem item in series.Items){ 
                    item.ActiveRegion.Click+=new RegionClick(ActiveRegion_Click); 
                } 
            } 
        } 
 
    void  ActiveRegion_Click(object sender) 
    { 
         ChartSeriesItem item = (ChartSeriesItem) sender; 
        MessageBox.Show(item.Parent.Name); 
    } 
    } 
 

Hope this helps!

Greetings,
Vladimir Milev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
johns
Top achievements
Rank 1
answered on 27 Jul 2007, 04:05 AM
I copied this code into a very simple test program, and it did not work.
I click on the bars in a bar chart and the event handler never gets called.

In addition to this I want to be able to click on the plotarea of a line chart (not necessarily right on the line) to retrieve that actual or closest Y data point value.

Another feature I wish to implement is draging a box in a line chart to zoom into it.

Can these features be implemented using the existing API?

Sorry to throw 3 things at you in one post, but I need to deliver a demo soon.
0
Vladimir Milev
Telerik team
answered on 30 Jul 2007, 04:15 PM
Hi johns,

We have prepared a small sample application demonstrating how to use click detection. I hope that it helps. Please, note that clicking Line series is not supported.

We are intrigued by the your suggestions about the line chart click and zooming features.  Those have popped up in the past and have been discussed, but unfortunately there are no concrete plans for their implementation. This does not mean we will not include them at some point in RadChart, rather that they will not be present in the immediate release and will remain on the watch list of potential features.

I hope I have been helpful. Your points have been updated.

Kind regards,
Vladimir Milev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
johns
Top achievements
Rank 1
answered on 02 Aug 2007, 06:40 PM
Well,  I cannot get your sample to comple. 

RegionClickEventHandler is not defined.  Am I missing an assembly reference?  By default the IDE adds a RegionClick when adding a delegate to Click.  I don't even see a referece to RegionClickEventHandler in your documentation.


Also regarding the line clicking.  What I need is not at all uncommon funtionality.  I have used multiple charts for both Stock Market and device measurement applications.  And almost all of them allow for a feature in which the user clicks somewhere on the chart  (Usually line charts with lots of data)  and the application will determine What the X-Axis point is and then display 1 or more corressponding Y values for that X point. 

Go to bigcharts.com and run their interactive Java chart and click on the plot area.  You will see what some people call a data cursor that when moved populates the current value under the cursor in a text box.

Or go to: http://www.smartmoney.com/eqsnaps/index.cfm?story=charting&symbol=IBM


This type of interactivity is critical for data analysis.

0
Dwight
Telerik team
answered on 03 Aug 2007, 12:09 PM
Hi johns,

Please open a support ticket for this issue and we will try to help you with this issue.

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Leonardo
Top achievements
Rank 1
answered on 08 Nov 2010, 05:47 PM
Hello guys,

have you reached some solution about this problem?
I'm loking for exactly the same thing. 

Thank you, 
0
Ales
Top achievements
Rank 1
answered on 17 Dec 2011, 09:33 AM
Hi,
is possible to post the small sample for demonstrating cick even ?

thlt
Tags
Chart (obsolete as of Q1 2013)
Asked by
johns
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
johns
Top achievements
Rank 1
Dwight
Telerik team
Leonardo
Top achievements
Rank 1
Ales
Top achievements
Rank 1
Share this question
or