Panning chart to far right on initial load

3 posts, 0 answers
  1. Scott
    Scott avatar
    11 posts
    Member since:
    Oct 2012

    Posted 29 Apr 2013 Link to this post

    I'm trying to force a RadCartesianChart to automatically pan to the rightmost limit after the Loaded event is called.  I've read other threads in this forum and in the Windows Phone 7 Chart forum and understand that I need to get the width of the displayed viewport in order to do this.  I've tried getting that as follows (_chartLTD is a fully bound RadCartesionChart):

    double wid1 = _chartLTD.RenderSize.Width; // Always returns 0


    My problem is that the above value is never non-zero after the chart is loaded.  I've also tried getting the viewport width by casting the chart to IChartView, but that width is 0 also.  Is there a better way to get the width of the viewport?

    Thanks,
    Scott

     
  2. Scott
    Scott avatar
    11 posts
    Member since:
    Oct 2012

    Posted 01 May 2013 Link to this post

    I found a solution to my problem.  I handled the SizedChanged event in the chart and panned to the far right as follows:
    private void radChartSummaryLTD_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        RadCartesianChart chartLTD = (RadCartesianChart)sender;
        if (chartLTD.Zoom.Width > 1.0)
        {
            double chartWidth = chartLTD.PlotAreaClip.Width;
     
            if (chartWidth > 0)
            {
                double fullChartSize = chartWidth * chartLTD.Zoom.Width;
                chartLTD.PanOffset = new Point(-(fullChartSize - chartWidth), 1.0); // Pan to right
            }
        }
    }

    By the way, the SizedChanged event was the only place I could find where the PlotAreaClip.Width was
    not zero.

    Thanks,
    Scott
  3. DevCraft banner
  4. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 02 May 2013 Link to this post

    Hello Scott,

    Its great that you found the solution. This is the correct way to pan to the end of the chart at the moment. We are considering changing the PanOffset to accept values between 0 and 1 which will make panning a lot easier but it would be a breaking change and we're still not sure if it is worth it.

    If you need further assistance let us know.

    Greetings,
    Victor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top