简体   繁体   中英

ZedGraphControl axis value range

I add ZedGraphControl and display a line graph to my C#.net project

In this graph x values goes to 0-320 range

When run I want to display only that area.For that i disabled scrolling, zooming also

when use ZedGraphControl.AxisChange(); function it display additional x range also

How to view only that interest area

thank you so much

The sample code below should answer your question.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM