你如何使用缩放UI中的MSChart对于.NET [英] How do you use the Zooming UI in MSChart for .Net

查看:768
本文介绍了你如何使用缩放UI中的MSChart对于.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始看可能使用MSChart控件用于.NET 3.5,这将在短期内启动项目。其中一个项目的要求是,用户能够放大到图表看小数据点更清晰,必要时。

I have just started looking at potentially using the MSChart control for .Net 3.5 for a project that will be starting shortly. One of the requirements of the project is that the users be able to zoom into the charts to see small data points more clearly when necessary.

我已经看过了一些教程和要么不提变焦,或只给了有关如何启用它,似乎认为使用它是如此明显,它不需要解释简短一点。

I have looked at a number of tutorials and the either do not mention zooming, or just give a brief bit of information about how to enable it and seem to assume that using it is so obvious that it requires no explanation.

我创建了一个快速测试项目,添加控件到窗体,然后增加了一些指向默认系列。然后,我走进ChartAreas收集,并确保在默认ChartArea中,可缩放的属性设置为True在所有轴心国成员的ScaleView属性。

I created a quick test project, added the control to the form, and then added a few Points to the default Series. I then went into the ChartAreas collection and made sure that in the default ChartArea, the Zoomable property was set to True in the ScaleView property of all of the Axis members.

当我运行应用程序我的图表显示了所有正确的,但我无法捉摸任何方式放大到它。我曾尝试点击它,双击,滚动滚轮,按住Ctrl键滚轮,CTRL- +,和许多其他的事情。

When I run the application my chart shows all correctly, but I cannot fathom any way to zoom into it. I have tried clicking on it, double clicking, the scroll wheel, ctrl-scroll wheel, ctrl-+, and many other things.

我显然失去了一些东西。可能有人请告诉我,我做错了,我怎么能缩放用户界面,以及如何实际使用缩放UI?

I am obviously missing something. Could someone please tell me what I am doing wrong, how I enable the zooming UI, and how I actually use the zooming UI?

我在Windows 7中,使用VS2012。

I am on Windows 7, using VS2012.

感谢你。

推荐答案

做类似下面应该让你使用鼠标左键并拖动缩放:

Doing something like the following should allow you to Zoom using the Mouse Left Click and Drag:

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

其中, this.cwSubplot 对象,你想缩放上班。

Where this.cwSubplot is the Chart object you want zooming to work on.

这篇关于你如何使用缩放UI中的MSChart对于.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆