如何在MSChart中使用Zooming UI for .Net

Pan*_*lon 2 .net c# mschart visual-studio-2012

我刚刚开始考虑将.Net 3.5的MSChart控件用于即将启动的项目.该项目的要求之一是用户能够放大图表,以便在必要时更清楚地查看小数据点.

我已经看了很多教程,要么不提及缩放,要么只提供一些关于如何启用它的信息,并且似乎假设使用它是如此明显,它不需要任何解释.

我创建了一个快速测试项目,将控件添加到表单中,然后向默认系列添加了几个Points.然后我进入ChartAreas集合并确保在默认的ChartArea中,Zoomable属性在所有Axis成员的ScaleView属性中设置为True.

当我运行应用程序时,我的图表显示正确,但我无法理解任何放大它的方法.我试过点击它,双击,滚轮,旋转滚轮,ctrl- +等等.

我显然缺少一些东西.有人可以告诉我我做错了什么,如何启用缩放UI,以及我如何实际使用缩放UI?

我在Windows 7上使用VS2012.

谢谢.

[编辑:修正标题中的愚蠢拼写错误]

Chr*_*Zeh 9

执行以下操作应该允许您使用鼠标单击并拖动进行缩放:

private void ZoomToggle(bool Enabled)
{
    // Enable range selection and zooming end user interface
    this.cwSubplot.ChartAreas(0).CursorX.IsUserEnabled = Enabled;
    this.cwSubplot.ChartAreas(0).CursorX.IsUserSelectionEnabled = Enabled;
    this.cwSubplot.ChartAreas(0).CursorX.Interval = 0;
    this.cwSubplot.ChartAreas(0).AxisX.ScaleView.Zoomable = Enabled;
    this.cwSubplot.ChartAreas(0).AxisX.ScrollBar.IsPositionedInside = true;
    this.cwSubplot.ChartAreas(0).AxisX.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll;
    this.cwSubplot.ChartAreas(0).AxisX.ScaleView.SmallScrollMinSize = 0;

    this.cwSubplot.ChartAreas(0).CursorY.IsUserEnabled = Enabled;
    this.cwSubplot.ChartAreas(0).CursorY.IsUserSelectionEnabled = Enabled;
    this.cwSubplot.ChartAreas(0).CursorY.Interval = 0;
    this.cwSubplot.ChartAreas(0).AxisY.ScaleView.Zoomable = Enabled;
    this.cwSubplot.ChartAreas(0).AxisY.ScrollBar.IsPositionedInside = true;
    this.cwSubplot.ChartAreas(0).AxisY.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll;
    this.cwSubplot.ChartAreas(0).AxisY.ScaleView.SmallScrollMinSize = 0;
    if (Enabled == false) {
        //Remove the cursor lines
        this.cwSubplot.ChartAreas(0).CursorX.SetCursorPosition(double.NaN);
        this.cwSubplot.ChartAreas(0).CursorY.SetCursorPosition(double.NaN);
    }
}
Run Code Online (Sandbox Code Playgroud)

您想要缩放this.cwSubplotChart对象在哪里工作.