Questions about zooming and panning

Thread is closed for posting
2 posts, 0 answers
  1. Franz
    Franz avatar
    4 posts
    Member since:
    Oct 2011

    Posted 17 Dec 2011 Link to this post


    I'm using a line series on a DateTimeCategoricalAxis and have two questions about zooming and panning.
    1. how can I get the maxium offset value so i can start out on a zoom level and scroll to the last value in the chart?
    2. how can I get the the first and the last visible value (datapoint) of a chart so I can display a the date range on a label?

  2. Georgi
    Georgi avatar
    296 posts

    Posted 20 Dec 2011 Link to this post

    Hi Franz,

    Thank you for contacting us and for your questions.

    1. The maximum PanOffset along the horizontal axis may be calculated like this:

    double plotAreaWidth = this.radChart1.PlotAreaClip.Width;
    double zoomWidth = this.radChart1.Zoom.Width * plotAreaWidth;
    double maxOffsetX = plotAreaWidth - zoomWidth;

    Please note that the initial layout pass should be finished so that the chart model is properly laid-out. So, you will need to hook-up the LayoutUpdated method of the chart and update the PanOffset in the handler.

    2. The chart tracks that information but it is currently internal. We will consider exposing it publicly. A possible solution would be to manually find the points, using the PlotAreaClip property:

    private DataPoint[] FindFirstLastVisiblePoints(CategoricalSeries series)
        DataPoint firstPoint = null;
        DataPoint lastPoint = null;
        RadRect plotArea = this.radChart1.PlotAreaClip;
        foreach (DataPoint point in series.DataPoints)
            if (point.LayoutSlot.IntersectsWith(plotArea))
                if (firstPoint == null)
                    firstPoint = point;
                lastPoint = point;
        return new DataPoint[] { firstPoint, lastPoint };

    The IntersectsWith method has a bug in it (will be fixed in the upcoming Service Pack 1) and will not work properly if a vertical zoom is applied.

    I hope this information is useful. Let me know if I can assist you further.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top