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

Panning chart to far right on initial load

2 Answers 25 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott
Top achievements
Rank 1
Scott asked on 29 Apr 2013, 06:40 PM
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 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 01 May 2013, 05:02 PM
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
0
Victor
Telerik team
answered on 02 May 2013, 08:23 AM
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.
Tags
Chart
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Victor
Telerik team
Share this question
or