GraphPane myPaneT = new GraphPane(new Rectangle(40, 40, 500, 250),
                    "Case #" + (j+1).ToString(),
                    "时间",
                    "电压");
Rectangle 矩形框设置的够么?更改下看看。

解决方案 »

  1.   

    好久没写,给以前的代码参考下        /// <summary>
            /// 画出图片
            /// </summary>
            /// <param name="arrvalues"></param>
            /// <param name="titles"></param>
            private void bindStat(double[] arrvalues, string[] titles, Color[] colors)
            {
                this.zedGraphControl1.GraphPane.Title.Text = "";
                this.zedGraphControl1.GraphPane.XAxis.Title.Text = "班级";
                this.zedGraphControl1.GraphPane.YAxis.Title.Text = "数量";
                this.zedGraphControl1.GraphPane.CurveList.Clear();
                this.zedGraphControl1.GraphPane.GraphObjList.Clear();
                this.zedGraphControl1.GraphPane.Fill = new Fill(Color.White, Color.LightSkyBlue, 45.0f);
                this.zedGraphControl1.GraphPane.Chart.Fill = new Fill(Color.White, Color.LightSeaGreen, 45.0f);
                double[] arrValues = new double[titles.Length];
                string[] xtitles = titles;
                this.zedGraphControl1.GraphPane.YAxis.Scale.Min = 0;
                GraphPane myPane = this.zedGraphControl1.GraphPane;
                for (int i = 0; i < titles.Length; i++)
                {
                    for (int m = 0; m < titles.Length; m++)
                    {
                        if (i == m)
                        {
                            arrValues[m] = arrvalues[m];
                        }
                        else
                        {
                            arrValues[m] = 0;
                        }
                    }
                    BarItem myBar = this.zedGraphControl1.GraphPane.AddBar(titles[i], null, arrValues, colors[i]);
                    myBar.Bar.Fill = new Fill(colors[i], Color.White, colors[i]);
                    myBar.Bar.Border.Color = Color.Transparent;
                    if (!arrValues[i].ToString().Equals("0"))
                    {
                        TextObj va = new TextObj(arrValues[i].ToString(), i + 1, arrValues[i]+0.6, CoordType.AxisXYScale, AlignH.Center, AlignV.Center);
                        va.FontSpec = new FontSpec("宋体", 11, Color.Black, false, false, true);
                        va.FontSpec.Border.IsVisible = false;     // 是否有边框
                        va.FontSpec.Fill.Color = Color.Transparent;
                        va.FontSpec.IsUnderline = false;                    myPane.GraphObjList.Add(va);              // 填充
                                        }            }
                this.zedGraphControl1.GraphPane.YAxis.MinSpace = 0;
                List<string> list = new List<string>();
                for (int i = 0; i < xtitles.Length; i++)
                {
                    string value = "";
                    for (int j = 0; j < xtitles[i].Length; j++)
                    {
                        value += xtitles[i][j] + "\r\n";
                    }
                    list.Add(value);
                }            string[] listvalue = new string[list.Count];
                for (int k = 0; k < list.Count; k++)
                {
                    listvalue[k] = list[k];
                }            //this.zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.Angle= float.Parse("90");
                this.zedGraphControl1.GraphPane.XAxis.Scale.TextLabels = listvalue;
                this.zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.Size = 8;
                this.zedGraphControl1.GraphPane.XAxis.Type = AxisType.Text;
                this.zedGraphControl1.GraphPane.BarSettings.Type = BarType.Overlay;
                this.zedGraphControl1.GraphPane.YAxis.Scale.MajorStep = 5;
                this.zedGraphControl1.GraphPane.XAxis.MajorTic.IsBetweenLabels = true;
                this.zedGraphControl1.AxisChange();
                this.zedGraphControl1.Refresh();
            }
            #endregion
                //动态创建视图
                operation.CreateViwPro(dtpStartTime.Value.ToString(), dtpEndTime.Value.ToString());            string strWhere = "";            if (ltvDeptInfo.CheckedItems.Count > 0)
                {
                    strWhere = " Where ";
                }
                string[] names = new string[ltvDeptInfo.CheckedItems.Count];
                for (int i = 0; i < ltvDeptInfo.CheckedItems.Count; i++)
                {
                    strWhere += " c.deptid = '" + ltvDeptInfo.CheckedItems[i].Tag.ToString() + "'";                if (i < ltvDeptInfo.CheckedItems.Count - 1)
                    {
                        strWhere += " or";
                    }            }
                DataTable dt = operation.GetOutTimeDocInfo(strWhere, dtpStartTime.Value.ToShortDateString(), dtpEndTime.Value.ToShortDateString());
                SetStatisticalTable(dt);            double[] arrvalues = new double[dt.Rows.Count];
                Color[] colors = new Color[dt.Rows.Count];
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    names[j] = dt.Rows[j]["deptname"].ToString();
                    string count = "0";                if (dt.Rows[j]["doccount"].ToString() != "")
                    {
                        count = dt.Rows[j]["doccount"].ToString();
                    }
                    arrvalues[j] = double.Parse(count);
                    colors[j] = GetColor();
                }            bindStat(arrvalues, names, colors);
            }