How to select a series

2 posts, 0 answers
    OPTCOM avatar
    2 posts
    Member since:
    Apr 2014

    Posted 30 May 2014 Link to this post

    Hello everyone ,

    I am trying to select a line series (NOT A POINT) using the mouse .In fact I want to create two cursor to show the distance of two points by using two line series .  These  cursors should be dragged and moved by the mouse , something like select the line first , and the drag it to other position. I don't know how to select the line. 
    I have found something like that but it's for Rad Chart not for ChartView.

    Can some one tell me how to do that ?

    Thanks a  lot.

  2. George
    George avatar
    500 posts

    Posted 02 Jun 2014 Link to this post

    Hello Noah,

    Thank you for writing.

    You can however create a custom renderer and custom draw parts by following the article Custom rendering. In your custom renderer you will need to expose the DrawParts property as it is currently protected, in order to be able to access the custom draw part. Your custom draw part must inherit from LineSeriesDrawPart, for the sake of this example. In it you can implement the following method, which will return the clicked series:
    public ChartSeries HitTestSeries(Point location)
        List<PointF[]> allPoints = GetPointsPositionsArrays();
        foreach (PointF[] points in allPoints)
            GraphicsPath path = GetLinePaths(points);
            if (path == null)
            if (path.IsVisible(location))
                return this.Element;
        return null;

    And here is how you can use it:
    void chart_MouseClick(object sender, MouseEventArgs e)
        var renderer = yourCustomRenderer;
        var drawParts = renderer.DrawParts;
        foreach (var part in drawParts)
            if (part is YourCustomDrawPart)
                var hitSeries = ((YourCustomDrawPart)part).HitTestSeries(e.Location);

    I hope this information will be of help.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top