Reputation: 43
How to control Zoom In and Zoom Out in Windows Forms Chart by adding ZoomIn and ZoomOut button
chart1.ChartAreas["draw"].AxisY.ScaleView.ZoomReset();
Upvotes: 1
Views: 2610
Reputation: 54433
Zoom-in button:
Axis ax = chart1.ChartAreas[0].AxisX;
ax.ScaleView.Size = double.IsNaN(ax.ScaleView.Size)?
(ax.Maximum - ax.Minimum) / 2 : ax.ScaleView.Size /= 2;
Zoom-out:
Axis ax = chart1.ChartAreas[0].AxisX;
ax.ScaleView.Size = double.IsNaN(ax.ScaleView.Size)?
ax.Maximum : ax.ScaleView.Size *= 2;
if (ax.ScaleView.Size > ax.Maximum - ax.Minimum)
{
ax.ScaleView.Size = ax.Maximum;
ax.ScaleView.Position = 0;
}
Upvotes: 3