Hello,
I am trying to zoom and change the offset on the horizontal and vertical axis from code behind.
The code seems to work for the horizontal axis but not the vertical.
For example, I have a vertical axis displaying [0; 10]. I want to see [5,6], but the chart displays the [9,10] interval.
I have checked the virtualHeight (in this case 6850.0) and new value of the panoffset seems good => 3425.0
Why do I have this behaviour ? Is there a property that need to be set ?
I am trying to zoom and change the offset on the horizontal and vertical axis from code behind.
The code seems to work for the horizontal axis but not the vertical.
For example, I have a vertical axis displaying [0; 10]. I want to see [5,6], but the chart displays the [9,10] interval.
I have checked the virtualHeight (in this case 6850.0) and new value of the panoffset seems good => 3425.0
Why do I have this behaviour ? Is there a property that need to be set ?
01.public static void ZoomInChart(RadCartesianChart chart, double absmin, double absmax, double ordmin, double ordmax)02. {03. if (chart != null)04. {05. double absMaxValue = ((Telerik.Windows.Controls.ChartView.NumericalAxis)(chart.HorizontalAxis)).ActualRange.Maximum;06. double absMinValue = ((Telerik.Windows.Controls.ChartView.NumericalAxis)(chart.HorizontalAxis)).ActualRange.Minimum;07. double absMaxDelta = Math.Abs(absMaxValue - absMinValue);08. double absDelta = Math.Abs(absmax - absmin);09. 10. double abscoef = absDelta == 0 || double.IsNaN(absDelta) ? 1 : absMaxDelta / absDelta;11. 12. double ordMaxValue = ((Telerik.Windows.Controls.ChartView.NumericalAxis)(chart.VerticalAxis)).ActualRange.Maximum;13. double ordMinValue = ((Telerik.Windows.Controls.ChartView.NumericalAxis)(chart.VerticalAxis)).ActualRange.Minimum;14. double ordMaxDelta = Math.Abs(ordMaxValue - ordMinValue);15. double ordDelta = Math.Abs(ordmax - ordmin);16. 17. double ordcoef = ordDelta == 0 || double.IsNaN(ordDelta) ? 1 : ordMaxDelta / ordDelta;18. 19. chart.Zoom = new Size(abscoef, ordcoef);20. 21. double virtualWidth = chart.PlotAreaClip.Width * chart.Zoom.Width;22. 23. double virtualHeight = chart.PlotAreaClip.Height * chart.Zoom.Height;24. 25. // Produit en croix pour trouver la valeur du nouvel origine26. double absVal = (virtualWidth * (absmin - absMinValue)) / absMaxDelta;27. 28. double ordVal = (virtualHeight * (ordmin - ordMinValue)) / ordMaxDelta;29. 30. if (!double.IsNaN(absVal) && !double.IsNaN(ordVal))31. {32. chart.PanOffset = new Point(-absVal, -ordVal);33. }34. }35. }