添加Y轴最小值/最大值时MSchart无法缩放

发布于 2024-12-17 03:11:20 字数 171 浏览 0 评论 0原文

每当我将最小值/最大值添加到 Yaxis (chart1.ChartAreas[0].AxisY.Minimum & \ Chart1.ChartAreas[0].AxisY.Maximum)我失去了缩放图表的能力。

有办法解决这个问题吗?

有人知道缩放与最小/最大值相结合是否有限制吗?

Whenever i'm adding the minimum / maximum to the Yaxis (chart1.ChartAreas[0].AxisY.Minimum & \
chart1.ChartAreas[0].AxisY.Maximum) i'm loosing the ability of zooming in the chart.

Is there a way resolve this issue?

Does some one know if there is a limitations about zooming combined with min/max values?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

居里长安 2024-12-24 03:11:20

由于这里没有答案,但是最近对该线程的评论,并且我在寻找同一问题的答案时发现了该线程,这就是我发现的问题所在。

检查图表区域光标的 Interval 和 IntervalType 值。可以启用缩放,但您的间隔足够大,以至于使用最小/最大值,您的图表的整个范围都小于您可以选择的间隔。

就我而言,我使用 DateTime 作为轴值类型,并且使用“自动”IntervalType,我无法放大小于一天的任何内容 - 而且我的图表仅覆盖 10 小时,因此缩放似乎被禁用。我将 IntervalType 从“自动”更改为“秒”(将间隔保留为 1),这样我就可以放大所需的细节级别。

Since there was no answer here, but a recent comment on the thread, and I found this thread while looking for an answer on this same question here's what I found was the problem in my case.

Check the chart area cursor's Interval and IntervalType values. Zooming may be enabled but your interval is large enough that with the min/max values you have the entire range of your chart is simply smaller than the interval you can select.

In my case I'm using DateTime for my axis value type and I with the 'Auto' IntervalType I couldn't zoom in on anything less than a day - and my chart only covered 10 hours and so zooming appeared to be disabled. I changed IntervalType from 'Auto' to 'Seconds' (leaving Interval at 1) and that lets me zoom into the detail level I need.

無處可尋 2024-12-24 03:11:20

以下内容应该启用缩放:

chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true;

在轴上设置最小/最大似乎确实阻止了用户选择的缩放。
我不确定您是否试图限制缩放或提供初始缩放设置。
对于后者,请执行此操作而不是在轴上使用 min/ax:

chart1.ChartArea[0].AxisY.ScaleView.Zoom(min, max);

The following should enable zooming:

chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true;

Setting min/max on the axis seem to indeed prevent user-selected zoom.
I'm not sure if you are trying to restrict the zooming or provide an initial zoom setting.
For the later, do this instead of using min/ax on the axis:

chart1.ChartArea[0].AxisY.ScaleView.Zoom(min, max);
夜唯美灬不弃 2024-12-24 03:11:20

我无法验证问题。
如果我设置最小/最大,我仍然可以缩放图表,例如:

private void FillChart()
{
    var dt = new DataTable();
    dt.Columns.Add("X", typeof(double));
    dt.Columns.Add("Y", typeof(double));

    dt.Rows.Add(1, 3);
    dt.Rows.Add(2, 7);
    dt.Rows.Add(3, 2);
    dt.Rows.Add(4, 1);
    dt.Rows.Add(5, 5);
    dt.Rows.Add(6, 9);
    dt.Rows.Add(7, 0);

    this.chart1.Series.Clear();

    this.chart1.DataSource = dt;
    var series = this.chart1.Series.Add("MYSERIES");
    series.XValueMember = "X";
    series.YValueMembers = "Y";

    // set a custom minimum and maximum
    chart1.ChartAreas[0].AxisY.Minimum = -10;
    chart1.ChartAreas[0].AxisY.Maximum = 10;

    chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
    chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
    chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true; 
}

这对我来说效果很好。

你做了一些不同的事情吗?

I can't verify the problem.
If I set the min/max I can still zoom the chart e.g.:

private void FillChart()
{
    var dt = new DataTable();
    dt.Columns.Add("X", typeof(double));
    dt.Columns.Add("Y", typeof(double));

    dt.Rows.Add(1, 3);
    dt.Rows.Add(2, 7);
    dt.Rows.Add(3, 2);
    dt.Rows.Add(4, 1);
    dt.Rows.Add(5, 5);
    dt.Rows.Add(6, 9);
    dt.Rows.Add(7, 0);

    this.chart1.Series.Clear();

    this.chart1.DataSource = dt;
    var series = this.chart1.Series.Add("MYSERIES");
    series.XValueMember = "X";
    series.YValueMembers = "Y";

    // set a custom minimum and maximum
    chart1.ChartAreas[0].AxisY.Minimum = -10;
    chart1.ChartAreas[0].AxisY.Maximum = 10;

    chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
    chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
    chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true; 
}

this works perfectly fine to me.

Did you do something different ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文