Ejemplo n.º 1
0
 public Frm_RunInfo()
 {
     InitializeComponent();
     fRunInfo = this;
 }
Ejemplo n.º 2
0
        public static void Chart_Curve(Chart ChartName, string TitleName, string XAxisName, string YAxisName, string SelectMode, string[] XAxisData, double[] YAxisData, double XAxisLabAgle, double MaxValue, double MinValue, bool IsDisplayLine)
        {
            Frm_RunInfo FrmRunInfo = new Frm_RunInfo();
            long        i          = 0;
            long        Temp       = 0;
            DataTable   dt         = new DataTable();

            dt.Columns.Add("X轴");
            dt.Columns.Add("Y轴");
            DataRow dr = default(DataRow);

            if (ChartName.Name == "Chart_HOUSING")
            {
                if (IniGetNValue(PVar.UIChartCurveName, "CurveData", "TotalNum", 0) == 49)
                {
                    Temp = 49;
                }
                else
                {
                    Temp = (long)(IniGetNValue(PVar.UIChartCurveName, "CurveData", "CurrentNum", 0));
                }
                if (Temp > 0)
                {
                    for (i = 0; i <= Temp; i++)
                    {
                        dr    = dt.NewRow();
                        dr[0] = (i + 1).ToString();                   //X轴
                        dr[1] = YAxisData[i];                         //Y轴
                        dt.Rows.Add(dr);
                    }
                    dr = null;
                }
            }
            else
            {
                if (ChartName.Name == "Chart_YieldOverview")
                {
                    Temp = FrmRunInfo.TrackBar_yeild.Value;
                }
                if (ChartName.Name == "Chart_Tossing")
                {
                    Temp = FrmRunInfo.TrackBar_tossing.Value;
                }
                if (ChartName.Name == "Chart_UPH")
                {
                    Temp = FrmRunInfo.TrackBar_uph.Value;
                }
                for (i = 0; i <= Temp - 1; i++)
                {
                    dr    = dt.NewRow();
                    dr[0] = XAxisData[i];                     //X轴
                    dr[1] = YAxisData[i];                     //Y轴
                    dt.Rows.Add(dr);
                }
                dr = null;
            }
            Chart with_1 = ChartName;

            ChartName.DataSource = dt;             //dt作为chart的数据源
            ChartName.Series.Clear();
            ChartName.Legends.Clear();
            ChartName.ChartAreas.Clear();
            ChartName.Titles.Clear();
            ChartName.Titles.Add(TitleName);
            ChartName.ChartAreas.Add("Y轴");
            ChartName.Series.Add("Y轴");
            ChartName.Series.Add("X轴");
            ChartName.Series["Y轴"].LegendToolTip   = "Y轴图例";
            ChartName.ChartAreas["Y轴"].AxisX.Title = XAxisName;             //添加AxisX Titles
            ChartName.ChartAreas["Y轴"].AxisY.Title = YAxisName;             //添加AxisY Titles
            if (ChartName.Name != "Chart_HOUSING")
            {
                ChartName.Series["Y轴"].IsValueShownAsLabel = true;                                 //标签显示数据值
            }
            ChartName.ChartAreas["Y轴"].Area3DStyle.Enable3D = false;                               //启用3D样式
            ChartName.BackSecondaryColor = System.Drawing.Color.Yellow;                            //设置背景的辅助颜色
            ChartName.BorderlineColor    = System.Drawing.Color.Yellow;                            //设置图像边框的颜色
            ChartName.BorderlineWidth    = 1;                                                      //设置图像的边框宽度
            ChartName.ChartAreas["Y轴"].AxisX.LineColor           = System.Drawing.Color.LightGray; //设置轴的线条颜色
            ChartName.ChartAreas["Y轴"].AxisY.LineColor           = System.Drawing.Color.LightGray; //设置轴的线条颜色
            ChartName.ChartAreas["Y轴"].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray; //设置网格线颜色
            ChartName.ChartAreas["Y轴"].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray; //设置网格线颜色
            ChartName.ChartAreas["Y轴"].AxisY.IsLabelAutoFit      = true;                           //设置是否自动调整轴标签
            ChartName.ChartAreas["Y轴"].BackColor = Color.FromArgb(255, 255, 255);
            ChartName.BackColor = Color.FromArgb(238, 238, 238);
            if (ChartName.Name == "Chart_HOUSING")
            {
                ChartName.ChartAreas["Y轴"].AxisX.MajorGrid.Interval = 1;                 //设置X轴间隔距离
                ChartName.ChartAreas["Y轴"].AxisY.IsStartedFromZero  = false;             //设置是否自动将数据值均为正值时轴的最小值设置为0,存在负数据值时,将使用数据轴最小值
            }
            else
            {
                ChartName.ChartAreas["Y轴"].AxisX.MajorGrid.Interval = 1;                                                                               //设置X轴间隔距离
            }
            ChartName.ChartAreas["Y轴"].AxisX.MajorTickMark.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number; ////设置刻度线的间隔的度量单位
            ChartName.ChartAreas["Y轴"].AxisY.MajorTickMark.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number; ////设置刻度线的间隔的度量单位
            ChartName.ChartAreas["Y轴"].AxisY.MajorGrid.LineDashStyle    = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
            ChartName.ChartAreas["Y轴"].AxisX.MajorGrid.LineDashStyle    = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
            ChartName.ChartAreas["Y轴"].AxisX.MajorTickMark.Interval     = 1;
            if (ChartName.Name == "Chart_HOUSING")
            {
                ChartName.ChartAreas["Y轴"].AxisY.MajorTickMark.Interval = 0.01;                 //设置刻度线的间隔
                ChartName.ChartAreas["Y轴"].AxisY.Maximum = double.Parse(Strings.Format(MaxValue, "0.00")) + 0.1;
                ChartName.ChartAreas["Y轴"].AxisY.Minimum = double.Parse(Strings.Format(MinValue, "0.00")) - 0.1;
            }
            else
            {
                ChartName.ChartAreas["Y轴"].AxisY.MajorTickMark.Interval = 1;       //设置刻度线的间隔
            }
            ChartName.ChartAreas["Y轴"].AxisX.LabelStyle.Angle = (int)XAxisLabAgle; //X轴标题倾斜角度

            ChartName.Series[0].YValueMembers = "Y轴";
            ChartName.Series[0].XValueMember  = "X轴";
            if (ChartName.Name == "Chart_HOUSING")
            {
                ChartName.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            }
            else if (ChartName.Name == "Chart_UPH")
            {
                ChartName.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
            }
            else
            {
                ChartName.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            }
            ChartName.Series[0].Color = Color.Blue;
            if (ChartName.Name != "Chart_UPH")
            {
                ChartName.Series[1].YValueMembers = "Y轴";
                ChartName.Series[1].XValueMember  = "X轴";
                ChartName.Series[1].ChartType     = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
                ChartName.Series[1].Color         = Color.Gold;
            }
            if (IsDisplayLine)
            {
                System.Windows.Forms.DataVisualization.Charting.StripLine S1 = default(System.Windows.Forms.DataVisualization.Charting.StripLine);
                System.Windows.Forms.DataVisualization.Charting.StripLine S2 = default(System.Windows.Forms.DataVisualization.Charting.StripLine);
                System.Windows.Forms.DataVisualization.Charting.StripLine S3 = new System.Windows.Forms.DataVisualization.Charting.StripLine();
                S1.BorderColor    = Color.Red;
                S1.IntervalOffset = double.Parse(Strings.Format(MinValue, "0.00"));
                S2.BorderColor    = Color.Red;
                S2.IntervalOffset = double.Parse(Strings.Format(MaxValue, "0.00"));
                S3.BorderColor    = Color.Green;
                S3.IntervalOffset = double.Parse(Strings.Format((MaxValue + MinValue) / 2, "0.00"));
                ChartName.ChartAreas["Y轴"].AxisY.StripLines.Add(S1);
                ChartName.ChartAreas["Y轴"].AxisY.StripLines.Add(S2);
                ChartName.ChartAreas["Y轴"].AxisY.StripLines.Add(S3);
            }
            ChartName.DataBind();
        }