using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace QualityAnalisy
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private AxOWC.AxChartSpace axChartSpace1;
  private System.Windows.Forms.Button button1;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
   this.axChartSpace1 = new AxOWC.AxChartSpace();
   this.button1 = new System.Windows.Forms.Button();
   ((System.ComponentModel.ISupportInitialize)(this.axChartSpace1)).BeginInit();
   this.SuspendLayout();
   //
   // axChartSpace1
   //
   this.axChartSpace1.DataSource = null;
   this.axChartSpace1.Enabled = true;
   this.axChartSpace1.Location = new System.Drawing.Point(32, 16);
   this.axChartSpace1.Name = "axChartSpace1";
   this.axChartSpace1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axChartSpace1.OcxState")));
   this.axChartSpace1.Size = new System.Drawing.Size(576, 384);
   this.axChartSpace1.TabIndex = 0;
   this.axChartSpace1.Enter += new System.EventHandler(this.axChartSpace1_Enter);
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(184, 416);
   this.button1.Name = "button1";
   this.button1.TabIndex = 1;
   this.button1.Text = "button1";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(656, 446);
   this.Controls.Add(this.axChartSpace1);
   this.Controls.Add(this.button1);
   this.Name = "Form1";
   this.Text = "Form1";
   ((System.ComponentModel.ISupportInitialize)(this.axChartSpace1)).EndInit();
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  private void axChartSpace1_Enter(object sender, System.EventArgs e)
  {
  
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
   
     #region 将数据绑定到owc上
     //初始化owc

     if(axChartSpace1.Charts.Count>=1)
     {
      axChartSpace1.Charts.Delete(0);
     }

     OWC.WCChart objChart = this.axChartSpace1.Charts.Add(0);
     //    objChart.Axes[0].Font.set_Size(10);
     objChart.Axes[1].Font.set_Size(10);
     objChart.HasTitle = true;
     objChart.Title.Caption = "检验点分析图";

     objChart.Axes[0].HasTitle = true;
     objChart.Axes[0].Title.Caption = "Y: 检验值";
     objChart.Axes[0].HasMajorGridlines=false;
     //    objChart.Axes[1].HasTitle = true;
     //    objChart.Axes[1].Title.Caption = "X: 时间";
     objChart.Axes[1].HasTickLabels=false;
     //    objChart.Axes[1].HasAutoMajorUnit=true;
     //    objChart.Axes[1].Title.Caption = "X: 时间";

 
     axChartSpace1.Visible = true;
     //    objChart.Type = OWC.ChartChartTypeEnum.chChartTypeColumnClustered;
     //    objChart.Type = OWC.ChartChartTypeEnum.chChartTypeLineMarkers;
     //objChart.Type = OWC.ChartChartTypeEnum.chChartTypeLine;
           objChart.Type = OWC.ChartChartTypeEnum.chChartTypeLine;


     //要显示的x轴的信息,累加起来


     //统计用的dataset
     string Value = "";
     string upvalue="";
     string setvalue="";
     string lowvalue="";

           Value="0\t7\t9\t8\t10\t6\t3\t-1\t-2\t-5\t-9\t-10\t6\t-2\t5.4\t";
     upvalue+="10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t10\t";
     setvalue+="0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t";
     lowvalue+="-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t-10\t";


     if(Value.Length>=1)
     {
      Value=Value.Trim().Substring(0,Value.Length-1);
     }
     if(upvalue.Length>=1)
     {
      upvalue=upvalue.Trim().Substring(0,upvalue.Length-1);
     }
     if(setvalue.Length>=1)
     {
      setvalue=setvalue.Trim().Substring(0,setvalue.Length-1);
     }
     if(lowvalue.Length>=1)
     {
      lowvalue=lowvalue.Trim().Substring(0,lowvalue.Length-1);
     }
     objChart.SeriesCollection.Add(0);
     objChart.SeriesCollection[0].SetData
      (OWC.ChartDimensionsEnum.chDimValues,
      (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,Value);

     objChart.SeriesCollection.Add(1);

    
    
     objChart.SeriesCollection[1].SetData
      (OWC.ChartDimensionsEnum.chDimValues,
      (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,upvalue);
     objChart.SeriesCollection.Add(2);
     objChart.SeriesCollection[2].SetData
      (OWC.ChartDimensionsEnum.chDimValues,
      (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,setvalue);
     objChart.SeriesCollection.Add(3);
     objChart.SeriesCollection[3].SetData
      (OWC.ChartDimensionsEnum.chDimValues,
      (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,lowvalue);
     #endregion
    }
   }
   


  }
 

 

posted on 2006-08-09 17:15  Yang-S  阅读(2904)  评论(1编辑  收藏  举报