gpt4 book ai didi

c# - 你如何使用 MSChart for .Net 中的 Zooming UI

转载 作者:行者123 更新时间:2023-11-30 19:27:21 25 4
gpt4 key购买 nike

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

我看了很多教程,要么没有提到缩放,要么只是提供了一些关于如何启用它的简短信息,并且似乎假设使用它是如此明显以至于不需要解释。

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

当我运行该应用程序时,我的图表显示全部正确,但我无法理解任何放大它的方法。我试过点击它、双击、滚轮、ctrl-滚轮、ctrl-+ 和许多其他东西。

我显然遗漏了一些东西。谁能告诉我我做错了什么,我如何启用缩放 UI,以及我实际如何使用缩放 UI?

我在 Windows 7 上,使用 VS2012。

谢谢。

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

最佳答案

执行类似下面的操作应该允许您使用鼠标左键单击并拖动来缩放:

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 是您希望缩放工作的 Chart 对象。

关于c# - 你如何使用 MSChart for .Net 中的 Zooming UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18892201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com