X轴为 时间 精确到秒 Y轴为数值,
 
 现在发现 X轴 间距有问题  比如  12:30   12:40       13:00  13:50 这两个时间段,一个事 10分钟间距,一个事 50分钟间距, 但是在X轴上显示的时候, 间距间距几乎相等  

解决方案 »

  1.   

    IsScaled 设置 X 轴标题字体显示大小是否根据图的比例放大缩小 
      

  2.   

    MajorGrid  大跨度的 X 轴表格虚线线显示信息 
      

  3.   

    IsFontsScaled 图比例变化时候图表上的文字是否跟着自动缩放
      

  4.   

    IsScaled 设置 X 轴标题字体显示大小是否根据图的比例放大缩小 
    --------------------------------------------
     是组件的那个对象的属性呀 public static void zedG_FMT(ZedGraph.ZedGraphControl zdg,
               System.Data.DataTable tabtmp_d,
               string strtitle, string stry)
            {            double dx = 0.00;
                double dy = 0.00;            Application.DoEvents();            zdg.Refresh();            zdg.GraphPane.CurveList.Clear();            // 坐标列表
                PointPairList list = new PointPairList();            // 坐标对象项目
                LineItem myCurve;            zdg.GraphPane.Title.FontSpec.Size = 10;            zdg.GraphPane.Title.Text = strtitle;            zdg.GraphPane.XAxis.Title.Text = " 时间: ( 从 " +
                    tabtmp_d.Rows[tabtmp_d.Rows.Count - 1]["时间"].ToString() +
                    " 到 " +
                    tabtmp_d.Rows[0]["时间"].ToString() + " ) ";
                //this.zdG_ll.GraphPane.XAxis.Title.FontSpec.Fill = new Fill(Color.Red);            
                //IsScaled
                zdg.GraphPane.YAxis.Title.Text = stry;
                zdg.GraphPane.YAxis.Title.FontSpec.Angle = 0;
                //this.zdG_ll.GraphPane.YAxis.Title.FontSpec.Fill = new Fill(Color.Red);            zdg.GraphPane.XAxis.Type = ZedGraph.AxisType.Date;
                zdg.GraphPane.XAxis.Color = Color.Red;            double ddd = (double)new XDate(Convert.ToDateTime(tabtmp_d.Rows[0]["时间"]));
                double ddx = (double)new XDate(Convert.ToDateTime(tabtmp_d.Rows[tabtmp_d.Rows.Count - 1]["时间"]));            zdg.GraphPane.XAxis.Scale.MinorStep = 0.0500;
                zdg.GraphPane.XAxis.Scale.Max = ddd + 1.5000;
                zdg.GraphPane.XAxis.Scale.Min = ddx - 0.5000;
                //zdg.GraphPane.XAxis.Scale.MaxAuto = false;
                //zdg.GraphPane.XAxis.Scale.MinAuto = false;                       // X 轴标题字符 角度
                //this.zdG_ll.GraphPane.XAxis.Title.FontSpec.Angle = 90;            // X 轴 大值划线
                zdg.GraphPane.XAxis.MajorGrid.IsVisible = true;
                zdg.GraphPane.XAxis.MajorGrid.Color = Color.Red;                        // Y 轴 大值划线
                zdg.GraphPane.YAxis.MajorGrid.IsVisible = true;
                zdg.GraphPane.YAxis.MajorGrid.Color = Color.Red;            zdg.GraphPane.YAxis.Color = Color.Red;            zdg.GraphPane.XAxis.Type = AxisType.DateAsOrdinal;            zdg.GraphPane.XAxis.Scale.Format = "yyyy-MM-dd HH:mm";          
                zdg.GraphPane.XAxis.Title.FontSpec.Size = 10;
                zdg.GraphPane.YAxis.Title.FontSpec.Size = 10;
                zdg.GraphPane.YAxis.Scale.IsUseTenPower = false;
                zdg.GraphPane.YAxis.Title.IsOmitMag = true;
                zdg.GraphPane.YAxis.Type = AxisType.Log;
                for (int i = tabtmp_d.Rows.Count - 1; i >= 0; i--)
                {
                    Application.DoEvents();                dx = (double)new XDate(Convert.ToDateTime(tabtmp_d.Rows[i]["时间"]));
                    dy = Convert.ToDouble(tabtmp_d.Rows[i][stry]);                list.Add(dx, dy);
                }            zdg.GraphPane.XAxis.Scale.FontSpec.Size = 16;
                zdg.GraphPane.YAxis.Scale.FontSpec.Size = 16;            string[] labs=new string[tabtmp_d.Rows.Count];
                for (int y = 0; y <= tabtmp_d.Rows.Count -1; y++) 
                {
                    labs[y] = tabtmp_d.Rows[y]["时间"].ToString();
                }
                zdg.GraphPane.XAxis.Scale.TextLabels = labs;             Application.DoEvents();
                myCurve = zdg.GraphPane.AddCurve("My Curve",
                      list, Color.Lime, SymbolType.Circle);            Application.DoEvents();            // 图例标题
                //myCurve.Label.Text = " 图例 ";
                myCurve.Label.IsVisible = false;
                //zdG_ll.GraphPane.Fill = new Fill(Color.Black);
                zdg.GraphPane.Chart.Fill = new Fill(Color.Black);            Application.DoEvents();            myCurve.Line.IsAntiAlias = true; //抗锯齿效果
                // 在数据变化时绘制图形
                zdg.AxisChange();            zdg.Invalidate();  // 修改图标                        Application.DoEvents();            zdg.Refresh();            Application.DoEvents();        }--------------
     主要代码
      

  5.   

    IsPreventLabelOverlap
    坐标值显示是否允许重叠,如果False的话,控件会根据坐标值长度自动消除部分坐标值的显示状态
      

  6.   

    给你个例子:ZedGraph控件的使用
    http://tsunzhang.javaeye.com/blog/429601
      

  7.   

    IsPreventLabelOverlap 
    坐标值显示是否允许重叠,如果False的话,控件会根据坐标值长度自动消除部分坐标值的显示状态
    -------------------------
     没有找到这个属性
      

  8.   


    private void button2_Click(object sender, EventArgs e)
    {
        this.zedGraphControl1.GraphPane.Title.Text = "动态折线图";
        this.zedGraphControl1.GraphPane.XAxis.Title.Text = "时间";
        this.zedGraphControl1.GraphPane.YAxis.Title.Text = "数量";    GraphPane myPane = new GraphPane(new Rectangle(40, 40, 600, 400),
            "My Test Graphn(For CodeProject Sample)",
            "My X Axis",
            "My Y Axis");
        myPane.XAxis.Scale.IsPreventLabelOverlap = true; //坐标值显示是否允许重叠,如果False的话,控件会根据坐标值长度自动消除部分坐标值的显示状态 
    }
      

  9.   

    MinorGrid  小跨度的X轴表格虚线显示信息
    MinorTic 小跨度的x轴刻度信息
    MinSpace 刻度和轴之间的距离
    IsScaled  设置X轴标题字体显示大小是否根据图的比例放大缩小
    IsPreventLabelOverlap   坐标值显示是否允许重叠,如果False的话,控件会根据坐标值长度自动消除部分坐标值的显示状态
    myPane.XAxis.Scale.Min = 1;//最小值 
    myPane.XAxis.Scale.Max = 100;//最大值 
    myPane.XAxis.Scale.MinorStep = 1;//步长 
      

  10.   

    感谢大家,
    问题解决了。两个方案:zdg.GraphPane.XAxis.Type = AxisType.Date;            // 这样就不行,变成等分了 zdg.GraphPane.XAxis.Type = AxisType.DateAsOrdinal;            zdg.GraphPane.XAxis.Scale.Format = "yyyy-MM-dd HH:mm";
    ---------------------------------------------------------------------- VS2008 + MSChart DateTime d1,d2,d3,d4;
                d1 = DateTime.Now.Date  ;                     d2 = d1.AddMinutes(5);
                d3 = d1.AddMinutes(10);            d4 = d1.AddMinutes(25);            string str1, str2, str3, str4, str5;            str1 = "2009-09-22 14:30:00";            str2 = "2009-09-22 14:35:00";            str3 = "2009-09-22 14:40:00";            str4 = "2009-09-22 15:30:00";
                            chart1.Series[0].Points.AddXY(d1 ,200000000);
                chart1.Series[0].Points.AddXY(d2, 300000000);            chart1.Series[0].Points.AddXY(d3, 400000000);            chart1.Series[0].Points.AddXY(d4, 500000000);            chart1.Series[0].XValueType = ChartValueType.DateTime;            chart1.Series[0].Points[0].AxisLabel = "2009-09-22 14:30:00";
                // 等分时间点
                //chart1.Series[0].IsXValueIndexed = true;           // chart1.Series[0].IsValueShownAsLabel = true;                        // Set series chart type
                chart1.Series["Series1"].ChartType = SeriesChartType.Line;
                //chart1.Series["Series2"].ChartType = SeriesChartType.Spline;            // Set point labels
                chart1.Series["Series1"].IsValueShownAsLabel = true;
                //chart1.Series["Series2"].IsValueShownAsLabel = true;            // Enable X axis margin
                chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;            // Show as 3D
               chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;             chart1.Invalidate();