Zedgraph创建的图像太小

时间:2013-09-24 19:22:35

标签: zedgraph

我的图表输出非常小,我无法真正看到x和y轴的值。有没有办法改变这个,所以图表更大? 我输出图表的代码是:

 ZedGraphControl zc = new ZedGraphControl();
        GraphPane pane = zc.GraphPane;

        PointPairList list1 = new PointPairList();
        LineItem curve1;            

        pane.Title.Text = title;
        pane.XAxis.Title.Text = xAxisTitle;
        pane.XAxis.Scale.Min = 0;
        pane.XAxis.Scale.Max = 11;
        pane.YAxis.Scale.Min = 1;
        pane.YAxis.Scale.Max = 12;
        pane.YAxis.Title.Text = yAXisTitle;

        Int32 totalCount = ds.Tables[objectName].Rows.Count;

        double[] xVals = new double[totalCount], yVals = new double[totalCount];

        for (int i = 0; i < totalCount; i++)
        {
            xVals[i] = Convert.ToDouble(ds.Tables[objectName].Rows[i]["ntotal"]);
            yVals[i] = Convert.ToDouble(ds.Tables[objectName].Rows[i]["isomonth"]);                                
        }

        list1.Add(xVals, yVals);

        curve1 = pane.AddCurve("Temp curve", list1, Color.Green, SymbolType.Circle);

        for (int i = 0; i < totalCount; i++)
        {
            TextObj t = new TextObj("Teest", curve1.Points[i].Y, curve1.Points[i].X);
            t.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add(t);
        }

        curve1.Line.Width = 1.0F;

        pane.GetImage().Save(outPutDestination, ImageFormat.Png);

        pane.AxisChange();

1 个答案:

答案 0 :(得分:0)

GetImage()函数获取窗格的当前大小,因此我们只需要增加整个窗格的大小(即:dock&amp;最大化窗口&amp;然后使用该方法获取图像)。

 DockStyle currentStyle = zedGraphControl1.Dock;
 var currentWindowState = this.WindowState;

 zedGraphControl1.Dock = DockStyle.Fill;
 this.WindowState = FormWindowState.Maximized;
 zedGraphControl1.GetImage ().Save ( @"c:\Image_1.png" );

 this.WindowState = currentWindowState;
 zedGraphControl1.Dock = currentStyle;