Example #1
0
        /// <summary>
        /// 年度月订单对比曲线
        /// </summary>
        private void CreateChart8()
        {
            try
            {
                DataTable[] dtSCur = new DataTable[SysConvert.ToInt32(drpCheckYearNum.Text.Trim())];
                int[]       yearA  = new int[SysConvert.ToInt32(drpCheckYearNum.Text.Trim())];
                int         ti     = 0;
                for (int i = SysConvert.ToInt32(drpCheckYearNum.Text.Trim()) - 1; i >= 0; i--)
                {
                    dtSCur[ti] = this.GetDataSource(SysConvert.ToInt32(drpCheckYear.Text.Trim()) - i);
                    yearA[ti]  = SysConvert.ToInt32(drpCheckYear.Text.Trim()) - i;
                    ti++;
                }

                DataTable dt = DBDate(dtSCur, yearA);
                if (dt.Rows.Count > 0)
                {
                    //设置Titles
                    Chart8.Titles["Title1"].Text = (SysConvert.ToInt32(drpCheckYear.Text) - SysConvert.ToInt32(drpCheckYearNum.Text)).ToString() + "--" + drpCheckYear.Text + "年 月订单对比曲线图";

                    //设置Legend
                    Chart8.Legends["Default"].Docking         = LegendDocking.Right;
                    Chart8.Legends["Default"].LegendStyle     = LegendStyle.Column;
                    Chart8.Legends["Default"].TableStyle      = LegendTableStyle.Auto;
                    Chart8.Legends["Default"].Alignment       = StringAlignment.Center;
                    Chart8.Legends["Default"].InsideChartArea = "";
                    //Chart8.Legends["Default"].Title = "对比曲线";
                    Chart8.Legends["Default"].TitleColor          = Color.Black;
                    Chart8.Legends["Default"].TitleAlignment      = StringAlignment.Center;
                    Chart8.Legends["Default"].TitleSeparator      = LegendSeparatorType.Line;
                    Chart8.Legends["Default"].TitleSeparatorColor = Color.Black;
                    Chart8.Legends["Default"].AutoFitText         = true;
                    //设置X轴
                    Chart8.ChartAreas["Default"].Area3DStyle.Enable3D           = false;               //2D效果
                    Chart8.ChartAreas["Default"].AxisX.Title                    = "月份";
                    Chart8.ChartAreas["Default"].AxisX.TitleAlignment           = StringAlignment.Far; //设置X轴标题的名称所在位置位远
                    Chart8.ChartAreas["Default"].AxisX.Interval                 = 0;                   //设置X轴显示间隔为2,对于X轴数据比较多的时候比较有用
                    Chart8.ChartAreas["Default"].AxisX.View.Zoomable            = true;
                    Chart8.ChartAreas["Default"].AxisY.View.Zoomable            = true;
                    Chart8.ChartAreas["Default"].CursorX.AutoScroll             = false;
                    Chart8.ChartAreas["Default"].CursorY.AutoScroll             = false;
                    Chart8.ChartAreas["Default"].AxisX.LabelStyle.ShowEndLabels = true;//去掉X轴首尾标签
                    Chart8.ChartAreas["Default"].AxisX.ScrollBar.PositionInside = true;
                    Chart8.ChartAreas["Default"].AxisX.Margin                   = true;
                    //设置Y轴
                    Chart8.ChartAreas["Default"].AxisY.Title          = "订单数";
                    Chart8.ChartAreas["Default"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
                    //设置ChartAreas
                    Chart8.ChartAreas["Default"].AxisX.LabelStyle.Interval    = 1;
                    Chart8.ChartAreas["Default"].AxisX.MajorGrid.Interval     = 1;
                    Chart8.ChartAreas["Default"].AxisX.MajorTickMark.Interval = 1;
                    //清除原有Series
                    Chart8.Series.Clear();
                    //曲线
                    for (int j = 0; j < yearA.Length; j++)
                    {
                        Series series = new Series();
                        series.LegendText       = yearA[j].ToString();
                        series.Type             = SeriesChartType.Spline;
                        series.BorderStyle      = ChartDashStyle.Solid;
                        series.BorderWidth      = 1;
                        series.BorderColor      = Color.FromArgb(180, 26, 59, 105);
                        series.BackGradientType = GradientType.None;
                        series.ShowLabelAsValue = true;
                        series.BorderWidth      = 3;
                        series.MarkerSize       = 8;
                        series.MarkerStyle      = MarkerStyle.Circle;
                        series.Color            = SericsColorProc.GetColor(j + 1);
                        Chart8.Series.Add(series);
                    }
                    //绑定Series值
                    for (int i = 0; i < Chart8.Series.Count; i++)
                    {
                        double[][] Arrays1 = new double[dtSCur[i].Rows.Count][];

                        for (int j = 0; j < 12; j++)
                        {
                            Arrays1[i]    = new double[1];
                            Arrays1[i][0] = SysConvert.ToDouble(dtSCur[i].Rows[j]["SQty"]);

                            Chart8.Series["Series" + SysConvert.ToString(i + 1)].Points.Add(j + 1);
                            Chart8.Series["Series" + SysConvert.ToString(i + 1)].Points[j].YValues   = Arrays1[i];
                            Chart8.Series["Series" + SysConvert.ToString(i + 1)].Points[j].AxisLabel = SysConvert.ToString(dtSCur[i].Rows[j]["MonthInt"].ToString()) + "月";
                        }
                    }
                }
            }
            catch (Exception E)
            {
                this.ShowMessage(E.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 月订单量分析
        /// </summary>
        private void CreateChart5()
        {
            try
            {
                string sql = "SELECT A.MonthInt, Amount FROM Rpt_Month A";
                sql += " LEFT OUTER JOIN ";
                sql += "(SELECT sum(TotalQty) Amount,Mon FROM ";
                sql += "(select TotalQty ,DATEPART (M,MakeDate ) Mon, MakeDate from Sale_SaleOrder where 1=1";
                sql += HTDataConditionStr;
                sql += " AND SubmitFlag=1";
                sql += ") AS A ";
                sql += "group by Mon) AS B";
                sql += " ON A.MonthInt=B.Mon ORDER BY A.MonthInt";
                DataTable dt = SysUtils.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    //设置Titles
                    Chart5.Titles["Title1"].Text = "月订单量柱形图";
                    //设置X轴
                    Chart5.ChartAreas["Chart Area 1"].Area3DStyle.Enable3D           = false;               //2D效果
                    Chart5.ChartAreas["Chart Area 1"].AxisX.Title                    = "月份";
                    Chart5.ChartAreas["Chart Area 1"].AxisX.TitleAlignment           = StringAlignment.Far; //设置X轴标题的名称所在位置位远
                    Chart5.ChartAreas["Chart Area 1"].AxisX.Interval                 = 0;                   //设置X轴显示间隔为2,对于X轴数据比较多的时候比较有用
                    Chart5.ChartAreas["Chart Area 1"].AxisX.View.Zoomable            = true;
                    Chart5.ChartAreas["Chart Area 1"].AxisY.View.Zoomable            = true;
                    Chart5.ChartAreas["Chart Area 1"].CursorX.AutoScroll             = false;
                    Chart5.ChartAreas["Chart Area 1"].CursorY.AutoScroll             = false;
                    Chart5.ChartAreas["Chart Area 1"].AxisX.LabelStyle.ShowEndLabels = true;//去掉X轴首尾标签
                    Chart5.ChartAreas["Chart Area 1"].AxisX.ScrollBar.PositionInside = true;
                    Chart5.ChartAreas["Chart Area 1"].AxisX.Margin                   = true;
                    //设置Y轴
                    Chart5.ChartAreas["Chart Area 1"].AxisY.Title          = "月订单量";
                    Chart5.ChartAreas["Chart Area 1"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远

                    //清除原有Series
                    Chart5.Series.Clear();
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        Series series = new Series();

                        series.Type             = SeriesChartType.Column;
                        series.BorderStyle      = ChartDashStyle.Solid;
                        series.BorderWidth      = 1;
                        series.BorderColor      = Color.FromArgb(180, 26, 59, 105);
                        series.BackGradientType = GradientType.None;
                        series.ShowLabelAsValue = true;
                        //series.Color = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(140)))), ((int)(((byte)(240)))));
                        series.Color            = SericsColorProc.GetColor(1);
                        series.CustomAttributes = "DrawingStyle=Cylinder";
                        Chart5.Series.Add(series);
                    }

                    double[][] Arrays1 = new double[dt.Rows.Count][];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Arrays1[i]    = new double[1];
                        Arrays1[i][0] = SysConvert.ToDouble(dt.Rows[i]["amount"]);

                        Series series = new Series();
                        series.ShowLabelAsValue = true;
                        Chart5.Series.Add(series);
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Chart5.Series["Series2"].Points.Add(i + 1);
                        Chart5.Series["Series2"].Points[i].YValues = Arrays1[i];
                        //Chart5.Series["Series2"].Points[i].AxisLabel = SysConvert.ToString(dt.Rows[i]["MonthInt"].ToString()).Substring(SysConvert.ToString(dt.Rows[i]["MonthInt"].ToString()).Length) + "月";
                        Chart5.Series["Series2"].Points[i].AxisLabel = SysConvert.ToString(dt.Rows[i]["MonthInt"].ToString()) + "月";
                    }
                }
            }
            catch (Exception E)
            {
                this.ShowMessage(E.Message);
            }
        }