ZedGraphControl轴值范围

时间:2011-05-27 19:07:30

标签: c# graph

我添加ZedGraphControl并在我的C#.net项目中显示一个折线图

在此图中,x值变为0-320范围

运行时我想只显示该区域。为此我禁用滚动,也缩放

使用ZedGraphControl.AxisChange();功能它还显示额外的x范围

如何仅查看该兴趣区域

非常感谢你

1 个答案:

答案 0 :(得分:0)

下面的示例代码应该回答您的问题。

public virtual void UpdateGraph(double[] xvals, double[] yvals, double minX, double maxX)
    {
        zedGraphControl1.GraphPane.XAxis.Scale.MaxAuto = false;
        zedGraphControl1.GraphPane.XAxis.Scale.MinAuto = false;
        zedGraphControl1.GraphPane.XAxis.Scale.Min = minX;
        zedGraphControl1.GraphPane.XAxis.Scale.Max = maxX;

        zedGraphControl1.GraphPane.YAxis.Scale.Min = 0;
        zedGraphControl1.GraphPane.YAxis.Scale.Max = getMax(yvals, xvals, minX, maxX);   //get y-value max within the X-value range

        updateZedgraphControl(xvals, yvals);

    }

protected virtual void updateZedgraphControl(double[] xvals, double[] yvals)
    {
        zedGraphControl1.GraphPane.CurveList.Clear();
        zedGraphControl1.GraphPane.AddCurve(this.curveTitle, xvals, yvals, Color.Black, SymbolType.None);
        this.zedGraphControl1.AxisChange();
        this.zedGraphControl1.Refresh();
    }