Muse event when clicking on line?

4 posts, 0 answers
  1. Iñigo
    Iñigo avatar
    14 posts
    Member since:
    Oct 2010

    Posted 08 Oct 2010 Link to this post

    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
  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 13 Oct 2010 Link to this post

    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
  3. Manish Kumar
    Manish  Kumar avatar
    62 posts
    Member since:
    Feb 2010

    Posted 06 Dec 2010 Link to this post

    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
  4. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 09 Dec 2010 Link to this post

    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
Back to Top