I just need to implement it as a PrePaint. As my program is resizeble, I had to do a similar function to implement at Resize Event. Othe requisite is the required redraw of charts. For that, I must have a stoper, I suggest to use a if condition (
Foo.Zoom_
). I removed my project info of this publication, but I will be glad to answer personal questions.
public void Square_PrePaint()
{
double deltaY = Chart.ChartAreas[0].AxisY.Maximum - Chart.ChartAreas[0].AxisY.Minimum;
double deltaX = Chart.ChartAreas[0].AxisX.Maximum - Chart.ChartAreas[0].AxisX.Minimum;
double Lenght_Y = Chart.ClientSize.Height;
double Lenght_X = Chart.ClientSize.Width;
double ratioX = deltaX / Lenght_X;
double ratioY = deltaY / Lenght_Y;
double diference = Math.Abs(ratioX - ratioY) / Math.Max(ratioX, ratioY);
if (diference > 0.02)
{
deltaX = ((int)(deltaY / Lenght_Y * Lenght_X)) + 1;
Chart.ChartAreas[0].AxisX.Minimum = Chart.ChartAreas[0].AxisX.Maximum - deltaX;
Foo.Zoom_.X_max = Chart.ChartAreas[0].AxisX.Maximum;
Foo.Zoom_.Y_max = Chart.ChartAreas[0].AxisY.Maximum;
Foo.Zoom_.X_min = Chart.ChartAreas[0].AxisX.Minimum;
Foo.Zoom_.Y_min = Chart.ChartAreas[0].AxisY.Minimum;
Foo.Zoom_.Activeted = true;
chart.Update();
}
}