1

我的图表的输出非常小,我看不到 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();
4

1 回答 1

0

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

 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;
于 2014-10-30T17:54:54.890 回答