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

Muse event when clicking on line?

3 Answers 63 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Iñigo
Top achievements
Rank 1
Iñigo asked on 08 Oct 2010, 11:54 AM
Hi, I want to assign a mouse event to a chart line series, I have been able to do it using "SeriesDefinition.PointMarkItemStyle" and a pointMark template, adding the MouseLeftButtonDown event to it. Is it possible to do the same to the line itself (not just the pointMark)?
Thanks

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 Oct 2010, 08:34 AM
Hi IƱigo,

You can do this by listening to the MouseUp event of the ChartArea and scanning the OriginalSource of the event. This should be done to insure the user has specifically clicked it instead of something else (a grid line for example). A recursive method can look like this:

private T GetParent<T>(DependencyObject obj)
    where T : DependencyObject
{
    if (obj == null)
    {
        return null;
    }
    else if (obj is T)
    {
        return (T)obj;
    }
 
    DependencyObject parent = VisualTreeHelper.GetParent(obj);
    return GetParent<T>(parent);
}

and the event handler for the ChartArea MouseUp event:
void ChartArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    Series clickedItem = GetParent<Series>(e.OriginalSource as DependencyObject);
    if (clickedItem != null)
    {
        SeriesItemLabel_Click(clickedItem, e);
    }
}

Series is the base class for all series that are drawn in the RadChart. This assures that the approach is compatible with all series types.

The solution above is demonstrated in a sample application that is attached.

Sincerely yours,
Yavor Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Manish Kumar
Top achievements
Rank 1
answered on 06 Dec 2010, 01:47 PM
Hi

I have a similar requirement but I need to trap the value of AxisY on mouse hover or LeftButtonClicked event.  Is this possible?
for reference i have attached image document

Thanks,
Manish
0
Yavor
Telerik team
answered on 09 Dec 2010, 10:31 AM
Hi Manish Kumar,

You can find a similar thread here.

Kind regards,
Yavor Ivanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Chart
Asked by
Iñigo
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Manish Kumar
Top achievements
Rank 1
Share this question
or