简体   繁体   中英

How to control Zoom In and Zoom Out in Windows form Chart by adding Zoom buttons

如何通过添加ZoomIn和ZoomOut按钮控制Windows窗体图表中的放大和缩小

chart1.ChartAreas["draw"].AxisY.ScaleView.ZoomReset();

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM