在 ZedGraph 中的所有图中重新缩放 X

发布于 2024-12-18 20:15:47 字数 392 浏览 1 评论 0原文

我可以使用以下代码成功地仅在所有绘图中缩放 x 轴:

zg1.IsEnableHZoom = true;  
zg1.IsEnableVZoom = false;  
zg1.IsSynchronizeXAxes = true;  

foreach (GraphPane gp in zg1.MasterPane.paneList)  
{  
   > //What code can I put here?  
}  

我的问题是,使用此代码,Y 轴根据数据的原始视图保持在最大值和最小值。我希望 Y 轴自动缩放,以便最大值和最小值仅基于由于 x 轴缩放而可见的数据(当然,每个图形窗格)。是否有一些命令或强力方法可以在上面显示的 for 循环中的每个图形窗格上使用?提前感谢任何人的帮助。

I can successfully zoom x-only across all plots using the following code:

zg1.IsEnableHZoom = true;  
zg1.IsEnableVZoom = false;  
zg1.IsSynchronizeXAxes = true;  

foreach (GraphPane gp in zg1.MasterPane.paneList)  
{  
   > //What code can I put here?  
}  

My problem is that using this code, the Y-axis remains at a max and min based on the original view of the data. I want the Y-axis to autoscale so that the max and min is ONLY based on the data visible due to the x-axis zoom (per graph pane, of course). Is there some command, or brute force method, that I can use on each of the graph panes in the for loop shown above? Thanks ahead of time for anyone's help.

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

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

发布评论

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

评论(2

明月夜 2024-12-25 20:15:47

您可以在循环中使用它(假设 X 轴缩放 MinAuto 和 MaxAuto 为 false)

foreach (GraphPane gp in zg1.MasterPane.paneList)  
{
    gp.YAxis.Scale.MinAuto = true;
    gp.YAxis.Scale.MaxAuto = true;

    // This will force ZedGraph to calculate the Min and the Max of the Y axis
    // based on the X axis visible range
    gp.IsBoundedRanges = true;
}

zg1.MasterPane.AxisChange();

You can use this in the loop (assuming X Axis scale MinAuto and MaxAuto are false)

foreach (GraphPane gp in zg1.MasterPane.paneList)  
{
    gp.YAxis.Scale.MinAuto = true;
    gp.YAxis.Scale.MaxAuto = true;

    // This will force ZedGraph to calculate the Min and the Max of the Y axis
    // based on the X axis visible range
    gp.IsBoundedRanges = true;
}

zg1.MasterPane.AxisChange();
书信已泛黄 2024-12-25 20:15:47

我以前也遇到过同样的问题,除了检查所有曲线点之外找不到其他方法。

我向 Paint 事件添加了一个事件处理程序来执行此操作,我确信有一些方法可以对此进行优化。

像这样的东西:

  private void graph_Paint(object sender, PaintEventArgs e)
  {
    double min = Double.MaxValue;
    double max = Double.MinValue;

    CurveItem curve = graph.GraphPane.CurveList[0];
    for (int i = 0; i < curve.Points.Count; i++)
    {
      if (curve.Points[i].X > graph.GraphPane.XAxis.Scale.Min &&
          curve.Points[i].X < graph.GraphPane.XAxis.Scale.Max)
      {
        min = Math.Min(curve.Points[i].Y, min);
        max = Math.Max(curve.Points[i].Y, max);
      }
    }

    if (min != Double.MaxValue)
    {
      graph.GraphPane.XAxis.Scale.Min = min;
      graph.GraphPane.XAxis.Scale.Max = max;
    }
  }

I had the same problem before and could not find a way other than to inspect all the curve points.

I added an event handler to the Paint event to do this, I'm sure there are ways this can be optimized.

Something like this:

  private void graph_Paint(object sender, PaintEventArgs e)
  {
    double min = Double.MaxValue;
    double max = Double.MinValue;

    CurveItem curve = graph.GraphPane.CurveList[0];
    for (int i = 0; i < curve.Points.Count; i++)
    {
      if (curve.Points[i].X > graph.GraphPane.XAxis.Scale.Min &&
          curve.Points[i].X < graph.GraphPane.XAxis.Scale.Max)
      {
        min = Math.Min(curve.Points[i].Y, min);
        max = Math.Max(curve.Points[i].Y, max);
      }
    }

    if (min != Double.MaxValue)
    {
      graph.GraphPane.XAxis.Scale.Min = min;
      graph.GraphPane.XAxis.Scale.Max = max;
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文