Пример #1
0
        private void LoadData()
        {
            //clear the existing data and add new Series data.
            ChartGroup cg = c1Chart1.ChartGroups.Group0;
            ChartDataSeriesCollection cdsc = cg.ChartData.SeriesList;

            cdsc.Clear();

            //create a new series for each "row" of the Gantt chart.
            //TASK ONE
            AddGanttSeriesData(cdsc, "Idea Generation",
                               new DateTime[] { new DateTime(2009, 01, 01) },
                               new DateTime[] { new DateTime(2009, 01, 25) });

            //TASK TWO
            AddGanttSeriesData(cdsc, "Concept Development",
                               new DateTime[] { new DateTime(2009, 01, 10) },
                               new DateTime[] { new DateTime(2009, 02, 14) });

            //TASK THREE
            AddGanttSeriesData(cdsc, "Business Analysis",
                               new DateTime[] { new DateTime(2009, 01, 21) },
                               new DateTime[] { new DateTime(2009, 02, 28) });

            //TASK FOUR
            AddGanttSeriesData(cdsc, "Market Analysis",
                               new DateTime[] { new DateTime(2009, 01, 21), new DateTime(2009, 02, 20) },
                               new DateTime[] { new DateTime(2009, 02, 12), new DateTime(2009, 03, 15) });

            //TASK FIVE
            AddGanttSeriesData(cdsc, "Implementation",
                               new DateTime[] { new DateTime(2009, 02, 10) },
                               new DateTime[] { new DateTime(2009, 04, 15) });

            //TASK SIX
            AddGanttSeriesData(cdsc, "Testing & Bug Fixes",
                               new DateTime[] { new DateTime(2009, 02, 15), new DateTime(2009, 03, 20) },
                               new DateTime[] { new DateTime(2009, 03, 15), new DateTime(2009, 04, 10) });


            //TASK SEVEN
            AddGanttSeriesData(cdsc, "Commercialize",
                               new DateTime[] { new DateTime(2009, 04, 5) },
                               new DateTime[] { new DateTime(2009, 05, 05) });

            //add task labels.
            AddGanttTaskLabels(c1Chart1, cdsc);
        }
Пример #2
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // get chart data
            string           path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string           conn = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\ComponentOne Samples\Common\C1NWind.mdb;", path);
            string           sql  = "select * from products";
            OleDbDataAdapter da   = new OleDbDataAdapter(sql, conn);
            DataTable        dt   = new DataTable();

            da.Fill(dt);

            // sort and filter data
            DataView data = dt.DefaultView;

            data.Sort      = "UnitPrice";
            data.RowFilter = "CategoryID = 1";             // beverages

            // configure chart
            _c1c.Reset();
            _c1c.Font      = new Font("Tahoma", 8);
            _c1c.BackColor = Color.White;
            _c1c.ChartGroups[0].ChartType = Chart2DTypeEnum.Pie;

            // get series collection (pies have one series per slice)
            ChartDataSeriesCollection
                dscoll = _c1c.ChartGroups[0].ChartData.SeriesList;

            dscoll.Clear();

            // populate the series
            for (int i = 0; i < data.Count; i++)
            {
                ChartDataSeries series = dscoll.AddNewSeries();
                series.PointData.Length = 1;
                series.Y[0]             = data[i]["UnitPrice"];
                series.Label            = string.Format("{0} ({1:c})",
                                                        data[i]["ProductName"], data[i]["UnitPrice"]);
            }

            // show pie legend
            _c1c.Legend.Visible = true;
            _c1c.Legend.Text    = "Product Unit Prices";
        }
Пример #3
0
        private void SetChart()
        {
            IList <Service.Model.CENTER_RTUCHANGE> rtuchange = DataClass.rtuchange;
            IList <Service.Model.CENTER_SERVER>    servers   = DataClass.servers;

            // simplify the chart reference.
            C1Chart chart = c1Chart2;

            chart.ToolTip.Enabled = true;
            chart.ShowTooltip    -= new ShowTooltipEventHandler(chart_ShowTooltip);//避免重复注册
            chart.ShowTooltip    += new ShowTooltipEventHandler(chart_ShowTooltip);

            #region Chart Style
            chart.Style.Border.Color        = sm.MetroColorParameters.BaseColor;
            chart.Style.BackColor           = sm.MetroColorParameters.CanvasColor;
            chart.ChartArea.Style.BackColor = sm.MetroColorParameters.CanvasColor;
            chart.Style.BackColor2          = Color.Azure;
            chart.Style.GradientStyle       = GradientStyleEnum.FromCenter;
            #endregion

            #region Chart Area style
            Area area = chart.ChartArea;
            area.Style.BackColor     = Color.Transparent;
            area.Style.GradientStyle = GradientStyleEnum.None;
            area.Inverted            = true; // X axis is vertical
            #endregion

            #region   Plot Area style
            area.PlotArea.BackColor = Color.Azure;
            area.PlotArea.Boxed     = true;
            #endregion

            #region Axis
            //   Set up the style and format of the Horizontal (Y) axis.
            Axis ax = area.AxisY;
            //ax.AnnoFormat = FormatEnum.;
            ax.AnnotationRotation = 30;
            //ax.Min = 0;
            //ax.Max = 300;
            //ax.Origin = ax.Min;
            ax.Font = new Font("ArialBlack", 8, FontStyle.Bold);
            //ax.UnitMajor = 14; //x轴间隔
            ax.TickMinor         = TickMarksEnum.None;
            ax.GridMajor.Pattern = LinePatternEnum.Dash;
            ax.GridMajor.Color   = Color.LightGray;
            ax.GridMajor.Visible = true;

            //   Set up the style and format of the Vertical (X) axis.
            ax                   = area.AxisX;
            ax.TickMinor         = TickMarksEnum.None;
            ax.Reversed          = true; // top to bottom
            ax.UnitMajor         = 1;
            ax.GridMinor.Pattern = LinePatternEnum.Dash;
            ax.GridMinor.Color   = Color.LightGray;
            //ax.GridMinor.Visible = true;
            ax.GridMajor.Pattern = LinePatternEnum.Solid;
            ax.GridMajor.Color   = area.PlotArea.BackColor;
            //ax.GridMajor.Visible = true;
            ax.Font = new Font("ArialBlack", 8, FontStyle.Bold);
            #endregion

            //   Specify the chart type as Gantt in the ChartGroup
            ChartGroup cg = chart.ChartGroups.Group0;
            cg.ChartType = Chart2DTypeEnum.Bar;


            //   Clear the existing data and add new Series data.
            ChartDataSeriesCollection cdsc = cg.ChartData.SeriesList;
            cdsc.Clear();

            // create a new series for each "row" of the Gantt chart.
            ChartDataSeries cds = cdsc.AddNewSeries();

            List <int>    vals  = new List <int>();
            List <string> names = new List <string>();


            foreach (var item in servers)
            {
                var rtuchangs = from r in rtuchange where item.ProjectName == r.ProjectName && item.PublicIP == r.PublicIP orderby r.RTUCount descending select r;
                if (rtuchangs.Count() > 0)
                {
                    vals.Add(rtuchangs.First().RTUCount);
                    names.Add(rtuchangs.First().ProjectName);
                }
            }
            cds.Y.CopyDataIn(vals.ToArray());
            cds.X.CopyDataIn(names.ToArray());
            cds.Tag = names;
        }
Пример #4
0
        private void GetLineChart(DataTable dt, string XDataName, string[] YCols, int Groupindex)
        {
            try
            {
                DataView dv           = dt.DefaultView;
                int      countColumns = YCols.Length;     //多少列 ;第一列未x坐标值 ;其他为数据
                int      countRows    = dt.Rows.Count;

                PointF[][] data = new PointF[countColumns][]; //视图的数据

                for (int i = 0; i < countColumns; i++)
                {
                    data[i] = new PointF[countRows];
                }
                //各列对应的数据
                for (int j = 0; j < countColumns; j++)
                {
                    for (int i = 0; i < countRows; i++)
                    {
                        string data1 = dv[i][YCols[j]].ToString().Replace("天", "").Trim();
                        float  y     = 0;
                        if (!string.IsNullOrEmpty(data1))
                        {
                            y = float.Parse(data1);
                        }
                        data[j][i] = new PointF(i, y);
                    }
                }
                //绑定数据
                ChartDataSeriesCollection collSeries = c1Chart1.ChartGroups[Groupindex].ChartData.SeriesList;

                collSeries.Clear();

                for (int i = 0; i < countColumns; i++) //如果是双条,则显示
                {
                    ChartDataSeries series = collSeries.AddNewSeries();
                    series.PointData.CopyDataIn(data[i]);
                    series.FitType           = C1.Win.C1Chart.FitTypeEnum.Line;
                    series.LineStyle.Pattern = LinePatternEnum.Solid;
                    //series.Label = dt.Columns[i].ColumnName;
                }
                for (int i = 0; i < countColumns; i++) //如果是双条,则显示
                {
                    //lend,对三种颜色Bar块的描述
                    c1Chart1.ChartGroups[Groupindex].ChartData.SeriesList[i].Label = YCols[i];
                }

                ChartDataSeriesCollection dscoll = c1Chart1.ChartGroups[Groupindex].ChartData.SeriesList;                //dscoll.Remove(c1Chart1.ChartGroups[0].ChartData.SeriesList[3]);
                if (Groupindex == 0)
                {
                    c1Chart1.ChartLabels.LabelsCollection.Clear();
                }
                for (int i = 0; i < dscoll.Count; i++)
                {
                    ChartDataSeries series = dscoll[i];
                    for (int j = 0; j < dv.Count; j++)
                    {
                        //加标签,在Bar块上面显示数据
                        C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();
                        string data1             = dv[j][YCols[i]].ToString().Replace("天", "").Trim();
                        if (!string.IsNullOrEmpty(data1))
                        {
                            lbl.Text = string.Format("{0}", float.Parse(data1));
                        }

                        lbl.Compass = LabelCompassEnum.North;
                        //lbl.Style.BackColor = Color.Brown;
                        lbl.Style.ForeColor = Color.Blue;
                        lbl.Offset          = 10;
                        lbl.Connected       = false;
                        lbl.Visible         = true;
                        lbl.AttachMethod    = AttachMethodEnum.DataIndex;
                        AttachMethodData am = lbl.AttachMethodData;
                        am.GroupIndex  = Groupindex; //0
                        am.SeriesIndex = i;          //i
                        am.PointIndex  = j;          //0
                    }
                }
                if (Groupindex == 0)
                {
                    //显示X轴标签
                    Axis ax = c1Chart1.ChartArea.AxisX;
                    //ax.Min = 10;
                    ax.TickMinor = TickMarksEnum.None;
                    ax.ValueLabels.Clear();
                    ax.AnnoMethod = AnnotationMethodEnum.ValueLabels;
                    for (int i = 0; i < dv.Count; i++)
                    {
                        ax.ValueLabels.Add(i, dv[i][XDataName].ToString());
                    }
                    //ax.TickLabels = TickLabelsEnum.High;
                    Axis ay = c1Chart1.ChartArea.AxisY;
                    //ay.TickMinor = TickMarksEnum.None;
                    ay.GridMajor.Visible = true;
                    ay.GridMajor.Color   = Color.White;
                    ay.Min = 0;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        private void GetPieChart(DataTable dt, string XDataName, string[] YCols)
        {
            try
            {
                DataView   dv           = dt.DefaultView;
                int        countColumns = YCols.Length;               //多少列
                int        allNum       = 0;
                PointF[][] data         = new PointF[countColumns][]; //视图的数据

                for (int i = 0; i < countColumns; i++)
                {
                    data[i] = new PointF[dv.Count];
                }
                for (int j = 0; j < countColumns; j++)
                {
                    //各列对应的数据
                    for (int i = 0; i < dv.Count; i++)
                    {
                        float y = float.Parse((dv[i][j]).ToString());
                        data[j][i] = new PointF(i, y);
                    }
                }
                //绑定数据
                ChartDataSeriesCollection collSeries = c1Chart1.ChartGroups[0].ChartData.SeriesList;

                collSeries.Clear();
                for (int i = 0; i < countColumns; i++) //如果是双条,则显示
                {
                    ChartDataSeries series = collSeries.AddNewSeries();
                    series.PointData.CopyDataIn(data[i]);
                    //collSeries[i].LineStyle.Pattern = LinePatternEnum.DashDot;
                    series.FitType = C1.Win.C1Chart.FitTypeEnum.Beziers;
                    //series.PointData.CopyDataIn(data[i]);// 这里的data是PointF类型
                    //series.FitType = C1.Win.C1Chart.FitTypeEnum.Spline;
                    series.Label = YCols[i];
                }
                for (int i = 0; i < countColumns; i++) //如果是双条,则显示
                {
                    //lend,对三种颜色Bar块的描述
                    c1Chart1.ChartGroups[0].ChartData.SeriesList[i].Label = YCols[i];
                }
                // c1Chart1.ChartGroups[0].ChartData.SeriesList[2].Label = "英语成绩";
                //c1Chart1.ChartGroups[0].ChartData[3].LineStyle.Color = Color.LightSteelBlue;
                //c1Chart1.ChartGroups[0].ChartData[3].LineStyle.Thickness = 0;
                //c1Chart1.ChartGroups[0].ChartData.SeriesList[3].Group.Visible = true;                  //坐标上的柱被隐藏
                //c1Chart1.ChartGroups[0].ChartData.SeriesList[3].Display = SeriesDisplayEnum.Hide;
                // c1Chart1.ChartGroups[0].ChartData.SeriesList[3].Display = SeriesDisplayEnum.Exclude;

                //c1Chart1.ChartGroups[0].ChartData[3].Display = SeriesDisplayEnum.Exclude;
                //c1Chart1.Legend
                //在Bar中显示值
                ChartDataSeriesCollection dscoll = c1Chart1.ChartGroups[0].ChartData.SeriesList;
                //dscoll.Remove(c1Chart1.ChartGroups[0].ChartData.SeriesList[3]);
                c1Chart1.ChartLabels.LabelsCollection.Clear();
                for (int i = 0; i < dscoll.Count; i++)
                {
                    ChartDataSeries series = dscoll[i];
                    for (int j = 0; j < dv.Count; j++)
                    {
                        allNum = 0;
                        for (int k = 0; k < YCols.Length; k++)
                        {
                            allNum += int.Parse(dv[j][YCols[k]].ToString());
                        }
                        //加标签,在Bar块上面显示数据
                        C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();

                        string c1Label  = string.Format("{0}", float.Parse(dv[j][series.Label].ToString()));
                        float  labelNum = float.Parse(dv[j][series.Label].ToString());//显示的实际数值
                        lbl.Text  = series.Label;
                        lbl.Text += ":" + labelNum.ToString();
                        if (allNum != 0)
                        {
                            float percent = labelNum * 100 / allNum;
                            lbl.Text += ", " + String.Format("{0:F2} ", percent) + "%";
                        }

                        //lbl.Text = string.Format("{0}", float.Parse(dv[j][series.Label].ToString()));

                        lbl.Compass = LabelCompassEnum.Radial;
                        //lbl.Style.BackColor = Color.Brown;
                        lbl.Style.ForeColor = Color.Blue;
                        lbl.Offset          = 10;
                        lbl.Connected       = false;
                        lbl.Visible         = true;
                        lbl.AttachMethod    = AttachMethodEnum.DataIndex;
                        AttachMethodData am = lbl.AttachMethodData;
                        am.GroupIndex  = 0; //0
                        am.SeriesIndex = i; //i
                        am.PointIndex  = j; //0
                    }
                }
                //显示X轴标签
                //Axis ax = c1Chart1.ChartArea.AxisX;
                //ax.ValueLabels.Clear();
                //ax.AnnoMethod = AnnotationMethodEnum.ValueLabels;

                //for (int i = 0; i < dv.Count; i++)
                //{
                //    //ax.ValueLabels.Add(i, dv[i]["path_code"].ToString());
                //}
                ////显示X轴标签
                //Axis ay = c1Chart1.ChartArea.AxisY;
                //ay.Text=""
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (sjEnd.Value < sjBegin.Value)
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }


            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            Color jthf = Color.FromArgb(25, 45, 86);

            // Add the data
            ChartData data = c1Chart1.ChartGroups[0].ChartData;
            ChartDataSeriesCollection series = data.SeriesList;

            ChartData data1 = c1Chart1.ChartGroups[1].ChartData;
            ChartDataSeriesCollection series1 = data1.SeriesList;

            series.Clear();
            series1.Clear();

            c1Chart1.ChartArea.AxisY.Max  = 16;
            c1Chart1.ChartArea.AxisY.Min  = 10;
            c1Chart1.ChartArea.AxisY.Text = "灰分";

            c1Chart1.ChartArea.AxisY2.Visible = true;
            c1Chart1.ChartArea.AxisY2.Text    = "水分";

            c1Chart1.ChartArea.AxisY2.Max = 8;
            c1Chart1.ChartArea.AxisY2.Min = 0;


            ChartDataSeries StuSeries = series.AddNewSeries();

            StuSeries.Label               = "自产焦炭灰分";
            StuSeries.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color     = Color.FromArgb(140, 200, 217);
            StuSeries.LineStyle.Thickness = 2;
            StuSeries.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries.SymbolStyle.Color   = Color.FromArgb(140, 200, 217);

            ////plot the student scores
            ChartDataSeries StuSeries2 = series.AddNewSeries();

            StuSeries2.Label               = "外购焦炭灰分";
            StuSeries2.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries2.LineStyle.Color     = Color.Blue;
            StuSeries2.LineStyle.Thickness = 2;
            StuSeries2.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries2.SymbolStyle.Color   = Color.Blue;

            ////plot the student scores
            ChartDataSeries StuSeries4 = series.AddNewSeries();

            StuSeries4.Label               = "喷吹煤粉灰分";
            StuSeries4.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries4.LineStyle.Color     = Color.FromArgb(41, 155, 155);
            StuSeries4.LineStyle.Thickness = 2;
            StuSeries4.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries4.SymbolStyle.Color   = Color.FromArgb(41, 155, 155);


            ////plot the student scores
            ChartDataSeries StuSeries3 = series1.AddNewSeries();

            StuSeries3.Label               = "外购焦炭水分";
            StuSeries3.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries3.LineStyle.Color     = Color.FromArgb(235, 200, 24);
            StuSeries3.LineStyle.Thickness = 2;
            StuSeries3.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries3.SymbolStyle.Color   = Color.FromArgb(235, 200, 24);

            ChartDataSeries StuSeries5 = series.AddNewSeries();

            StuSeries5.Label               = "喷吹煤粉挥发分";
            StuSeries5.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries5.LineStyle.Color     = Color.FromArgb(224, 169, 190);
            StuSeries5.LineStyle.Thickness = 2;
            StuSeries5.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries5.SymbolStyle.Color   = Color.FromArgb(224, 169, 190);

            ChartDataSeries StuSeries6 = series1.AddNewSeries();

            StuSeries6.Label               = "喷吹煤粉水分";
            StuSeries6.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries6.LineStyle.Color     = Color.FromArgb(218, 129, 55);
            StuSeries6.LineStyle.Thickness = 2;
            StuSeries6.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries6.SymbolStyle.Color   = Color.FromArgb(218, 129, 55);

            ChartDataSeries StuSeries7 = series1.AddNewSeries();

            StuSeries7.Label               = "自产焦炭水分";
            StuSeries7.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries7.LineStyle.Color     = Color.FromArgb(172, 67, 63);
            StuSeries7.LineStyle.Thickness = 2;
            StuSeries7.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries7.SymbolStyle.Color   = Color.FromArgb(172, 67, 63);

            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd";
            c1Chart1.ChartArea.AxisX.UnitMajor          = 1;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

            c1Chart1.Legend.Visible = true;

            DateTime[] sT;
            double[]   s;
            // 自产焦炭灰分
            LegendEnviroment.loadZichanj(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries.X.CopyDataIn(sT);
            StuSeries.Y.CopyDataIn(s);
            StuSeries = null;
            // 外购焦炭灰分
            LegendEnviroment.loadWaiGouj(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries2.X.CopyDataIn(sT);
            StuSeries2.Y.CopyDataIn(s);
            StuSeries = null;
            // 外购焦炭水分
            LegendEnviroment.loadWaiGoujtshuifen(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries3.X.CopyDataIn(sT);
            StuSeries3.Y.CopyDataIn(s);
            StuSeries = null;
            // 煤粉灰分
            LegendEnviroment.loadMeiFenh(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries4.X.CopyDataIn(sT);
            StuSeries4.Y.CopyDataIn(s);
            StuSeries = null;
            // 煤粉挥发分
            LegendEnviroment.loadMeiFenhuifa(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries5.X.CopyDataIn(sT);
            StuSeries5.Y.CopyDataIn(s);
            StuSeries = null;
            // 煤粉水分
            LegendEnviroment.loadMeiFenShuifen(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries6.X.CopyDataIn(sT);
            StuSeries6.Y.CopyDataIn(s);
            StuSeries = null;
            // 自产焦水分
            LegendEnviroment.loadZichanjShuiFen(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries7.X.CopyDataIn(sT);
            StuSeries7.Y.CopyDataIn(s);
            StuSeries = null;

            Area carea = c1Chart1.ChartArea;

            carea.AxisX.ValueLabels.Clear();
            double xMarker = AddChartAxisMarker(carea.AxisX);
        }
Пример #7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (sjEnd.Value < sjBegin.Value)
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            Color jthf = Color.FromArgb(25, 45, 86);

            // Add the data
            ChartData data = c1Chart1.ChartGroups[0].ChartData;
            ChartDataSeriesCollection series = data.SeriesList;

            ChartData data1 = c1Chart1.ChartGroups[1].ChartData;
            ChartDataSeriesCollection series1 = data1.SeriesList;

            series.Clear();
            series1.Clear();

            c1Chart1.ChartArea.AxisY.Max  = 100;
            c1Chart1.ChartArea.AxisY.Min  = 0;
            c1Chart1.ChartArea.AxisY.Text = "百分比";



            ChartDataSeries StuSeries = series.AddNewSeries();

            StuSeries.Label               = "综合品位";
            StuSeries.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color     = Color.FromArgb(140, 200, 217);
            StuSeries.LineStyle.Thickness = 2;
            StuSeries.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries.SymbolStyle.Color   = Color.FromArgb(140, 200, 217);

            ////plot the student scores
            ChartDataSeries StuSeries1 = series.AddNewSeries();

            StuSeries1.Label               = "实际回收率";
            StuSeries1.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries1.LineStyle.Color     = Color.Blue;
            StuSeries1.LineStyle.Thickness = 2;
            StuSeries1.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries1.SymbolStyle.Color   = Color.Blue;

            ChartDataSeries StuSeries2 = series.AddNewSeries();

            StuSeries2.Label               = "理论回收率";
            StuSeries2.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries2.LineStyle.Color     = Color.FromArgb(41, 155, 155);
            StuSeries2.LineStyle.Thickness = 2;
            StuSeries2.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries2.SymbolStyle.Color   = Color.FromArgb(41, 155, 155);


            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd";
            c1Chart1.ChartArea.AxisX.UnitMajor          = 1;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

            c1Chart1.Legend.Visible = true;

            DateTime[] sT;
            double[]   s;
            //综合品味
            LegendEnviroment.loadLlhsl(Convert.ToInt32(gaolu.Text), sjBegin.Value, sjEnd.Value, out sT, out s);


            StuSeries.X.CopyDataIn(sT);
            StuSeries.Y.CopyDataIn(s);

            //理论回收率

            double[] spw = s;
            if (s.Length > 0)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    spw[i] = Convert.ToDouble(s[i]) / 0.946 * 0.997;
                }
            }
            StuSeries2.X.CopyDataIn(sT);
            StuSeries2.Y.CopyDataIn(spw);


            //实际回收率

            LegendEnviroment.loadSJHSL(Convert.ToInt32(gaolu.Text), sjBegin.Value, sjEnd.Value, out sT, out s);


            StuSeries1.X.CopyDataIn(sT);
            StuSeries1.Y.CopyDataIn(s);


            Area carea = c1Chart1.ChartArea;

            carea.AxisX.ValueLabels.Clear();
            double xMarker = AddChartAxisMarker(carea.AxisX);
        }
Пример #8
0
        private void StepChart_Load(object sender, System.EventArgs e)
        {
            // position the controls
            hScrollBar1.Location = new Point(c1Chart1.Left, 0);
            vScrollBar1.Location = new Point(c1Chart1.Left - vScrollBar1.Width, hScrollBar1.Height);
            c1Chart1.Location    = new Point(hScrollBar1.Left, vScrollBar1.Top);

            // set 3D effects scrollbars visibility
            bool is3d = chkShow3D.Checked;

            vScrollBar1.Visible = is3d;
            hScrollBar1.Visible = is3d;

            // set up the charts
            ChartGroup cg = c1Chart1.ChartGroups.Group0;

            cg.Use3D = is3d;

            // ChartType is a Step chart.
            cg.ChartType = Chart2DTypeEnum.Step;

            ChartData cd = cg.ChartData;
            ChartDataSeriesCollection cdsc = cd.SeriesList;

            cdsc.Clear();                       // remove existing data.

            // create some data using this application GetData() routine
            PointF[] pfa = GetData();

            // add the data to the chart
            ChartDataSeries cds = cdsc.AddNewSeries();

            cds.PointData.CopyDataIn(pfa);
            cds.LineStyle.Thickness = 3;
            cds.TooltipText         = "Step0";
            cds.TooltipTextLegend   = "Step0 Legend";
            cds.SymbolStyle.Size    = 15;

            // add a second series using the application AdjustYValues
            // routine.  This data is similar to show behavior when
            // excluding the data holes found in the first data.
            cds = cdsc.AddNewSeries();
            cds.PointData.CopyDataIn(AdjustYValues(pfa, 1f, 2f));
            cds.LineStyle.Thickness = 3;
            cds.SymbolStyle.Size    = 15;
            cds.TooltipText         = "Step1";
            cds.TooltipTextLegend   = "Step1 Legend";
            cds.Display             = SeriesDisplayEnum.ExcludeHoles;

            // set up the 3D view object and scrollbars.  When
            // the 3D view is shown, the scrollbars can adjust
            // the angles.
            const int initialAngles = 30;
            View3D    v3d           = c1Chart1.ChartArea.PlotArea.View3D;

            v3d.Depth     = initialAngles;
            v3d.Elevation = initialAngles;
            v3d.Rotation  = initialAngles;

            hScrollBar1.Maximum = 45;
            hScrollBar1.Minimum = -45;
            hScrollBar1.Value   = -initialAngles;

            vScrollBar1.Maximum = 45;
            vScrollBar1.Minimum = -45;
            vScrollBar1.Value   = initialAngles;

            updnDepth.Value   = initialAngles;
            labDepth.Visible  = is3d;
            updnDepth.Visible = is3d;

            // in chart labels to label the scroll bars.
            C1.Win.C1Chart.LabelsCollection labs = c1Chart1.ChartLabels.LabelsCollection;
            C1.Win.C1Chart.Label            lab  = labs.AddNewLabel();
            lab.AttachMethod              = AttachMethodEnum.Coordinate;
            lab.AttachMethodData.X        = 1;
            lab.AttachMethodData.Y        = 1;
            lab.Compass                   = LabelCompassEnum.SouthEast;
            lab.SizeDefault               = new Size(c1Chart1.Size.Width, 12);
            lab.Style.HorizontalAlignment = AlignHorzEnum.Center;
            lab.Name    = "hbar";
            lab.Text    = "3D Rotation";
            lab.Visible = is3d;

            lab = labs.AddNewLabel();
            lab.AttachMethod              = AttachMethodEnum.Coordinate;
            lab.AttachMethodData.X        = 1;
            lab.AttachMethodData.Y        = 1;
            lab.Compass                   = LabelCompassEnum.SouthEast;
            lab.SizeDefault               = new Size(12, c1Chart1.Size.Height);
            lab.Style.Rotation            = RotationEnum.Rotate270;
            lab.Style.HorizontalAlignment = AlignHorzEnum.Center;
            lab.Name    = "vbar";
            lab.Text    = "3D Elevation";
            lab.Visible = is3d;

            // set up the Chart header
            Title header = c1Chart1.Header;

            header.Style.Font = new Font("Arial Black", 16);
            header.Style.Border.BorderStyle = BorderStyleEnum.Solid;
            if (is3d)
            {
                header.Text = "3D Step Chart";
            }
            else
            {
                header.Text = "2D Step Chart";
            }

            // clear the position CoordInfo label
            labCoordInfo.Text    = "";
            labCoordInfo.Visible = false;

            // force a resize to allow everything reposition.
            StepChart_Resize(null, null);
        }
Пример #9
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (sjEnd.Value < sjBegin.Value)
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            Color jthf = Color.FromArgb(25, 45, 86);

            // Add the data
            ChartData data = c1Chart1.ChartGroups[0].ChartData;
            ChartDataSeriesCollection series = data.SeriesList;

            ChartData data1 = c1Chart1.ChartGroups[1].ChartData;
            ChartDataSeriesCollection series1 = data1.SeriesList;

            series.Clear();
            series1.Clear();

            c1Chart1.ChartArea.AxisY.AutoMax = true;
            c1Chart1.ChartArea.AxisY.AutoMin = true;
            c1Chart1.ChartArea.AxisY.Text    = "热风温度℃";

            c1Chart1.ChartArea.AxisY2.AutoMax = true;
            c1Chart1.ChartArea.AxisY2.AutoMin = true;
            c1Chart1.ChartArea.AxisY2.Text    = "富氧率%";


            ChartDataSeries StuSeries = series.AddNewSeries();

            StuSeries.Label               = "热风温度℃";
            StuSeries.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color     = Color.FromArgb(140, 200, 217);
            StuSeries.LineStyle.Thickness = 2;
            StuSeries.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries.SymbolStyle.Color   = Color.FromArgb(140, 200, 217);

            ////plot the student scores
            ChartDataSeries StuSeries1 = series1.AddNewSeries();

            StuSeries1.Label               = "富氧率%";
            StuSeries1.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries1.LineStyle.Color     = Color.Blue;
            StuSeries1.LineStyle.Thickness = 2;
            StuSeries1.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries1.SymbolStyle.Color   = Color.Blue;



            ////plot the student scores



            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd";
            c1Chart1.ChartArea.AxisX.UnitMajor          = 1;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

            c1Chart1.Legend.Visible = true;

            DateTime[] sT;
            double[]   s;
            // 热风温度℃
            LegendEnviroment.loadRFWD(Convert.ToInt32(gaolu.Text), sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries.X.CopyDataIn(sT);
            StuSeries.Y.CopyDataIn(s);
            // 富氧率%
            LegendEnviroment.loadFYL(Convert.ToInt32(gaolu.Text), sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries1.X.CopyDataIn(sT);
            StuSeries1.Y.CopyDataIn(s);



            Area carea = c1Chart1.ChartArea;

            carea.AxisX.ValueLabels.Clear();
            double xMarker = AddChartAxisMarker(carea.AxisX);
        }
Пример #10
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // simplify the chart reference.
            C1Chart chart = c1Chart1;

            // Adjust the chart element styles
            //   Chart style.
            chart.Style.BackColor     = Color.Navy;
            chart.Style.BackColor2    = Color.Azure;
            chart.Style.GradientStyle = GradientStyleEnum.FromCenter;

            //   Chart Area style
            Area area = chart.ChartArea;

            area.Style.BackColor     = Color.Transparent;
            area.Style.GradientStyle = GradientStyleEnum.None;
            area.Inverted            = true;    // X axis is vertical

            //   Plot Area style
            area.PlotArea.BackColor = Color.Azure;
            area.PlotArea.Boxed     = true;

            //   Set up the style and format of the Horizontal (Y) axis.
            Axis ax = area.AxisY;

            ax.AnnoFormat         = FormatEnum.DateManual;
            ax.AnnoFormatString   = "MMM-dd";
            ax.AnnotationRotation = -30;
            ax.Min               = new DateTime(2004, 1, 1).ToOADate();
            ax.Max               = new DateTime(2004, 4, 30).ToOADate();
            ax.Origin            = ax.Min;
            ax.Font              = new Font("ArialBlack", 10, FontStyle.Bold);
            ax.UnitMajor         = 14;
            ax.TickMinor         = TickMarksEnum.None;
            ax.GridMajor.Pattern = LinePatternEnum.Dash;
            ax.GridMajor.Color   = Color.LightGray;
            ax.GridMajor.Visible = true;

            //   Set up the style and format of the Vertical (X) axis.
            ax                   = area.AxisX;
            ax.TickMinor         = TickMarksEnum.None;
            ax.Reversed          = true;                // top to bottom
            ax.UnitMajor         = 1;
            ax.GridMinor.Pattern = LinePatternEnum.Dash;
            ax.GridMinor.Color   = Color.LightGray;
            ax.GridMinor.Visible = true;
            ax.GridMajor.Pattern = LinePatternEnum.Solid;
            ax.GridMajor.Color   = area.PlotArea.BackColor;
            ax.GridMajor.Visible = true;
            ax.Font              = new Font("ArialBlack", 16, FontStyle.Bold);

            //   Specify the chart type as Gantt in the ChartGroup
            ChartGroup cg = chart.ChartGroups.Group0;

            cg.ChartType   = Chart2DTypeEnum.Gantt;
            cg.Gantt.Width = 40;

            //   Clear the existing data and add new Series data.
            ChartDataSeriesCollection cdsc = cg.ChartData.SeriesList;

            cdsc.Clear();

            // create a new series for each "row" of the Gantt chart.
            // TASK ONE
            AddGanttSeriesData(cdsc, "Task One",
                               new DateTime[] { new DateTime(2004, 01, 01) },
                               new DateTime[] { new DateTime(2004, 03, 09) });

            // TASK TWO
            AddGanttSeriesData(cdsc, "Task Two",
                               new DateTime[] { new DateTime(2004, 01, 23) },
                               new DateTime[] { new DateTime(2004, 02, 14) });

            // TASK THREE
            AddGanttSeriesData(cdsc, "Task Three",
                               new DateTime[] { new DateTime(2004, 01, 21) },
                               new DateTime[] { new DateTime(2004, 02, 24) });

            // TASK FOUR
            AddGanttSeriesData(cdsc, "Task Four",
                               new DateTime[] { new DateTime(2004, 01, 22), new DateTime(2004, 02, 28) },
                               new DateTime[] { new DateTime(2004, 02, 12), new DateTime(2004, 03, 24) });

            // TASK FIVE
            AddGanttSeriesData(cdsc, "Task Five",
                               new DateTime[] { new DateTime(2004, 02, 13), new DateTime(2004, 03, 08) },
                               new DateTime[] { new DateTime(2004, 03, 05), new DateTime(2004, 03, 31) });

            // TASK SIX
            AddGanttSeriesData(cdsc, "Task Six",
                               new DateTime[] { new DateTime(2004, 03, 15) },
                               new DateTime[] { new DateTime(2004, 04, 20) });

            // TASK SEVEN
            AddGanttSeriesData(cdsc, "Task Seven",
                               new DateTime[] { new DateTime(2004, 04, 06) },
                               new DateTime[] { new DateTime(2004, 04, 30) });

            // Add task labels.
            AddGanttTaskLabels(chart, cdsc);
        }
Пример #11
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (sjEnd.Value < sjBegin.Value)
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }


            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            Color jthf = Color.FromArgb(25, 45, 86);

            // Add the data
            ChartData data = c1Chart1.ChartGroups[0].ChartData;
            ChartDataSeriesCollection series = data.SeriesList;

            ChartData data1 = c1Chart1.ChartGroups[1].ChartData;
            ChartDataSeriesCollection series1 = data1.SeriesList;

            series.Clear();
            series1.Clear();

            c1Chart1.ChartArea.AxisY.Max  = 70;
            c1Chart1.ChartArea.AxisY.Min  = 50;
            c1Chart1.ChartArea.AxisY.Text = "品位";



            ChartDataSeries StuSeries = series.AddNewSeries();

            StuSeries.Label               = "烧结矿品位";
            StuSeries.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color     = Color.FromArgb(140, 200, 217);
            StuSeries.LineStyle.Thickness = 2;
            StuSeries.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries.SymbolStyle.Color   = Color.FromArgb(140, 200, 217);

            ////plot the student scores
            ChartDataSeries StuSeries2 = series.AddNewSeries();

            StuSeries2.Label               = "球团矿品位";
            StuSeries2.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries2.LineStyle.Color     = Color.Blue;
            StuSeries2.LineStyle.Thickness = 2;
            StuSeries2.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries2.SymbolStyle.Color   = Color.Blue;

            ChartDataSeries StuSeries3 = series.AddNewSeries();

            StuSeries3.Label               = "澳矿品位分析";
            StuSeries3.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries3.LineStyle.Color     = Color.FromArgb(218, 129, 55);
            StuSeries3.LineStyle.Thickness = 2;
            StuSeries3.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries3.SymbolStyle.Color   = Color.FromArgb(218, 129, 55);

            ChartDataSeries StuSeries4 = series.AddNewSeries();

            StuSeries4.Label               = "块矿";
            StuSeries4.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries4.LineStyle.Color     = Color.FromArgb(218, 129, 55);
            StuSeries4.LineStyle.Thickness = 2;
            StuSeries4.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries4.SymbolStyle.Color   = Color.FromArgb(218, 129, 55);


            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd";
            c1Chart1.ChartArea.AxisX.UnitMajor          = 1;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

            c1Chart1.Legend.Visible = true;

            DateTime[] sT;
            double[]   s;
            // 烧结矿
            LegendEnviroment.loadSJKPinWei(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries.X.CopyDataIn(sT);
            StuSeries.Y.CopyDataIn(s);
            StuSeries = null;
            // 球团品位
            LegendEnviroment.loadQTKPinWei(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries2.X.CopyDataIn(sT);
            StuSeries2.Y.CopyDataIn(s);
            StuSeries = null;
            // 澳矿品位
            LegendEnviroment.loadAOKPinWei(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries3.X.CopyDataIn(sT);
            StuSeries3.Y.CopyDataIn(s);
            StuSeries = null;
            // 块矿品位
            LegendEnviroment.loadkuaikuangPinWei(sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries4.X.CopyDataIn(sT);
            StuSeries4.Y.CopyDataIn(s);
            StuSeries = null;


            Area carea = c1Chart1.ChartArea;

            carea.AxisX.ValueLabels.Clear();
            double xMarker = AddChartAxisMarker(carea.AxisX);
        }
Пример #12
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (sjEnd.Value < sjBegin.Value)
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            Color jthf = Color.FromArgb(25, 45, 86);

            // Add the data
            ChartData data = c1Chart1.ChartGroups[0].ChartData;
            ChartDataSeriesCollection series = data.SeriesList;

            ChartData data1 = c1Chart1.ChartGroups[1].ChartData;
            ChartDataSeriesCollection series1 = data1.SeriesList;

            series.Clear();
            series1.Clear();
            ylmcysj.Clear();

            c1Chart1.ChartArea.AxisY.Max  = 100;
            c1Chart1.ChartArea.AxisY.Min  = 0;
            c1Chart1.ChartArea.AxisY.Text = "百分比";
            List <string> ylmc = new List <string>();

            LegendEnviroment.loadGLYL("含铁原料", out ylmc);
            int i = 0;

            foreach (String yl in ylmc)
            {
                LegendEnviroment.loadRlylPeiBi(Convert.ToInt32(gaolu.Text), yl, sjBegin.Value, sjEnd.Value, out sT, out s);

                if (s.Length > 1)
                {
                    ChartDataSeries StuSeries = series.AddNewSeries();
                    StuSeries.Label             = yl + "配比";
                    StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
                    Random r = new Random();
                    StuSeries.LineStyle.Color     = colors.getColor(i++);// Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
                    StuSeries.LineStyle.Thickness = 2;
                    StuSeries.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
                    StuSeries.SymbolStyle.Color   = StuSeries.LineStyle.Color;
                    StuSeries.X.CopyDataIn(sT);
                    StuSeries.Y.CopyDataIn(s);
                    ylmcysj.Add(yl);
                }
            }

            ////plot the student scores

            ChartDataSeries StuSeries2 = series.AddNewSeries();

            StuSeries2.Label               = "熔剂配比";
            StuSeries2.LineStyle.Pattern   = LinePatternEnum.Solid;
            StuSeries2.LineStyle.Color     = Color.FromArgb(218, 129, 55);
            StuSeries2.LineStyle.Thickness = 2;
            StuSeries2.SymbolStyle.Shape   = SymbolShapeEnum.Dot;
            StuSeries2.SymbolStyle.Color   = Color.FromArgb(218, 129, 55);
            ylmcysj.Add("熔剂");

            // 熔剂配比
            LegendEnviroment.loadRONGJIPeiBi(Convert.ToInt32(gaolu.Text), sjBegin.Value, sjEnd.Value, out sT, out s);
            StuSeries2.X.CopyDataIn(sT);
            StuSeries2.Y.CopyDataIn(s);

            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd";
            c1Chart1.ChartArea.AxisX.UnitMajor          = 1;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

            c1Chart1.Legend.Visible = true;
            Area carea = c1Chart1.ChartArea;

            carea.AxisX.ValueLabels.Clear();
            double xMarker = AddChartAxisMarker(carea.AxisX);
        }
Пример #13
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // center the form.
            this.CenterToParent();

            // setup the chart to fill the form, then set the appearance.
            c1Chart1.Dock = DockStyle.Fill;

            // set the chart itself
            c1Chart1.Style.BackColor          = Color.LightBlue;
            c1Chart1.Style.Border.BorderStyle = BorderStyleEnum.InsetBevel;
            c1Chart1.Style.Border.Thickness   = 4;

            // set up the area
            Area area = c1Chart1.ChartArea;

            area.Style.BackColor          = Color.LightYellow;
            area.Style.Border.BorderStyle = BorderStyleEnum.InsetBevel;
            area.Style.Border.Thickness   = 4;

            // set up the plot area
            PlotArea parea = area.PlotArea;

            parea.BackColor = Color.AntiqueWhite;

            // set up the header
            Title hdr = c1Chart1.Header;

            hdr.Text       = "Radar Chart for System Adaptability";
            hdr.Style.Font = new Font("Arial Black", 14);
            hdr.Style.Border.BorderStyle = BorderStyleEnum.Raised;
            hdr.Style.Border.Color       = Color.PaleTurquoise;

            // set up the Legend
            Legend leg = c1Chart1.Legend;

            leg.Style.Font               = new Font("Arial Narrow", 9);
            leg.Style.BackColor          = Color.AntiqueWhite;
            leg.Style.Border.BorderStyle = BorderStyleEnum.Raised;
            leg.Visible = true;

            // set up axes
            Axis ax = area.AxisX;

            ax.AnnoMethod        = AnnotationMethodEnum.ValueLabels;
            ax.Font              = new Font("Arial", 10);
            ax.Reversed          = true;
            ax.Thickness         = 0;
            ax.GridMajor.Color   = Color.Black;
            ax.GridMajor.Pattern = LinePatternEnum.Dot;
            ax.GridMajor.Visible = true;

            // set the chart type to radar and add the data
            ChartGroup grp = c1Chart1.ChartGroups[0];

            grp.ChartType = Chart2DTypeEnum.Radar;

            // set the axis information.  Not that the compass
            // information is limited by the chart type, so it is
            // necessary to set the chart type first.
            Axis ay = area.AxisY;

            ay.GridMajor.Color   = Color.Black;
            ay.GridMajor.Pattern = LinePatternEnum.Dot;
            ay.GridMajor.Visible = true;
            ay.Compass           = CompassEnum.North;

            ChartDataSeriesCollection series = grp.ChartData.SeriesList;

            series.Clear();

            // there will be 3 new series, all with the same 7 x values:
            int []   x  = new int[] { 1, 2, 3, 4, 5, 6, 7 };
            float [] y0 = new float[] { 2.8f, 3.5f, 3.3f, 2f, 4f, 3f, 2.9f };
            float [] y1 = new float[] { 3.2f, 3.3f, 3.5f, 2.4f, 3.8f, 3.4f, 4.2f };
            float [] y2 = new float[] { 3.6f, 5f, 3.3f, 5f, 3.6f, 4.3f, 3.8f };

            // series 0
            ChartDataSeries s = series.AddNewSeries();

            s.X.CopyDataIn(x);
            s.Y.CopyDataIn(y0);
            s.LineStyle.Color = Color.Orange;
            s.Label           = "New Transport";

            // series 1
            s = series.AddNewSeries();
            s.X.CopyDataIn(x);
            s.Y.CopyDataIn(y1);
            s.LineStyle.Color = Color.Blue;
            s.Label           = "OTIS";

            // series 2
            s = series.AddNewSeries();
            s.X.CopyDataIn(x);
            s.Y.CopyDataIn(y2);
            s.LineStyle.Color = Color.Green;
            s.Label           = "Mobile Walk";

            // add in the value labels for the x axis.
            ValueLabelsCollection vlabs = ax.ValueLabels;

            vlabs.Add(x[0], "Introduce");
            vlabs.Add(x[1], "Response");
            vlabs.Add(x[2], "Travel Time");
            vlabs.Add(x[3], "Get On/Off");
            vlabs.Add(x[4], "Comfort");
            vlabs.Add(x[5], "Social");
            vlabs.Add(x[6], "Operate");
        }
Пример #14
0
        /// <summary>
        /// Using the data structures created through the use of AddRoot, AddIntermediate and AddLeaf
        /// methods, populates the specified ChartDataSeriesCollection for a stacked Pie chart with
        /// segments.
        /// </summary>
        /// <param name="ascending"></param>
        /// <param name="cdsc"></param>
        /// <param name="dataLabelText"></param>
        public void AddToChartDataSeriesCollection(bool ascending, ChartDataSeriesCollection cdsc, string dataLabelText)
        {
            int pointCount = _syncPoint;

            List <PieGrouper>[] pointLists = new List <PieGrouper> [pointCount];
            syncNodes(pointLists);
            cdsc.Clear();

            float[] pointArray = new float[pointCount];
            pointArray.Initialize();

            if (dataLabelText == null)
            {
                dataLabelText = "{#TEXT}\r\n{#YVAL} ({%YVAL:0.00%})";
            }

            for (int i = 0; i < pointCount; i++)
            {
                int j = ascending ? i : pointCount - 1 - i;
                List <PieGrouper> pointList = pointLists[j];
                foreach (PieGrouper ps in pointList)
                {
                    ChartDataSeries cds = cdsc.AddNewSeries();

                    cds.Label = ps._name;
                    if (ps._syncColor != Color.Empty)
                    {
                        if (ps._syncColor == Color.Transparent)
                        {
                            PieGrouper ps1 = ps;
                            while (ps1 != null && ps1._syncColor == Color.Transparent)
                            {
                                ps1 = ps1._parent;
                            }
                            if (ps1 != null && ps1._syncColor != Color.Transparent)
                            {
                                if (ps1._syncColor == Color.Empty)
                                {
                                    ps1._syncColor = cds.FillStyle.Color1;
                                }
                                ps._syncColor = ps1._syncColor;
                                for (ps1 = ps; ps1 != null && ps1._syncColor == Color.Transparent; ps1 = ps1._parent)
                                {
                                    ps1._syncColor = ps._syncColor;
                                }
                            }
                        }
                        cds.FillStyle.Color1 = ps._syncColor;
                    }
                    else
                    {
                        ps._syncColor = cds.FillStyle.Color1;
                    }

                    pointArray[i] = ps._syncValue;
                    cds.Y.CopyDataIn(pointArray);

                    cds.DataLabel.Compass = LabelCompassEnum.RadialText;
                    cds.DataLabel.Offset  = -5;
                    cds.DataLabel.Text    = dataLabelText;
                    cds.DataLabel.Visible = true;

                    cds.TooltipText = cds.DataLabel.Text;
                }
                pointArray[i] = 0f;
            }
        }
Пример #15
0
        private void SetChart(DateTime?DT1, DateTime?DT2)
        {
            IList <Service.Model.CENTER_SERVER>     servers     = null;
            IList <Service.Model.CENTER_STARTSTATE> serverstate = null;
            string   Where    = "";
            DateTime dt_start = new DateTime();
            DateTime dt_end   = new DateTime();

            if (DT1 != null && DT2 != null)
            {
                //获得server的列表,和每个server的启停情况
                Where = " where Dtime>= '" + DT1.Value + "' and Dtime<='" + DT2.Value + "'";
                if (Service.PublicBD.DB == "ORACLE")
                {
                    Where = "where Dtime>=to_date('" + DT1.Value + "','yyyy-MM-dd HH24:MI:SS') and Dtime<=to_date('" + DT2.Value + "','yyyy-MM-dd HH24:MI:SS')";
                }
                DataClass.GetCenterInfo(Where);
                servers     = DataClass.servers;
                serverstate = DataClass.serverstate;
                //X轴的起止时间
                dt_start = DT1.Value;
                dt_end   = DT2.Value;
            }
            else
            {
                servers     = DataClass.servers;
                serverstate = DataClass.serverstate;
                //X轴的起止时间
                dt_start = (from s in serverstate orderby s.DTime ascending select s).First().DTime;
                dt_end   = DateTime.Now.AddHours(1);

                dateTimeInput1.Value = dt_start;
                dateTimeInput2.Value = dt_end;
            }
            // simplify the chart reference.
            C1Chart chart = c1Chart1;

            chart.ToolTip.Enabled = true;
            chart.ShowTooltip    -= new ShowTooltipEventHandler(chart_ShowTooltip);//避免重复注册
            chart.ShowTooltip    += new ShowTooltipEventHandler(chart_ShowTooltip);

            #region Chart Style
            chart.Style.Border.Color        = sm.MetroColorParameters.BaseColor;
            chart.Style.BackColor           = sm.MetroColorParameters.CanvasColor;
            chart.ChartArea.Style.BackColor = sm.MetroColorParameters.CanvasColor;
            chart.Style.BackColor2          = Color.Azure;
            chart.Style.GradientStyle       = GradientStyleEnum.FromCenter;
            #endregion

            #region Chart Area style
            Area area = chart.ChartArea;
            area.Style.BackColor     = Color.Transparent;
            area.Style.GradientStyle = GradientStyleEnum.None;
            area.Inverted            = true; // X axis is vertical
            #endregion

            #region   Plot Area style
            area.PlotArea.BackColor = Color.Azure;
            area.PlotArea.Boxed     = true;
            #endregion

            #region Axis
            //   Set up the style and format of the Horizontal (Y) axis.
            Axis ax = area.AxisY;

            ax.AnnoFormat         = FormatEnum.DateManual;
            ax.AnnoFormatString   = "MMM-dd";
            ax.AnnotationRotation = -30;
            //ax.Min = new DateTime(2016, 8, 10).ToOADate();
            //ax.Max = new DateTime(2016, 8, 30).ToOADate();
            ax.Min    = dt_start.ToOADate();
            ax.Max    = dt_end.ToOADate();
            ax.Origin = ax.Min;
            ax.Font   = new Font("ArialBlack", 8, FontStyle.Bold);
            //ax.UnitMajor = 14; //x轴间隔
            ax.TickMinor         = TickMarksEnum.None;
            ax.GridMajor.Pattern = LinePatternEnum.Dash;
            ax.GridMajor.Color   = Color.LightGray;
            ax.GridMajor.Visible = true;

            //   Set up the style and format of the Vertical (X) axis.
            ax                   = area.AxisX;
            ax.TickMinor         = TickMarksEnum.None;
            ax.Reversed          = true; // top to bottom
            ax.UnitMajor         = 1;
            ax.GridMinor.Pattern = LinePatternEnum.Dash;
            ax.GridMinor.Color   = Color.LightGray;
            ax.GridMinor.Visible = true;
            ax.GridMajor.Pattern = LinePatternEnum.Solid;
            ax.GridMajor.Color   = area.PlotArea.BackColor;
            ax.GridMajor.Visible = true;
            ax.Font              = new Font("ArialBlack", 8, FontStyle.Bold);
            #endregion

            //   Specify the chart type as Gantt in the ChartGroup
            ChartGroup cg = chart.ChartGroups.Group0;
            cg.ChartType   = Chart2DTypeEnum.Gantt;
            cg.Gantt.Width = 40;

            //   Clear the existing data and add new Series data.
            ChartDataSeriesCollection cdsc = cg.ChartData.SeriesList;
            cdsc.Clear();

            // create a new series for each "row" of the Gantt chart.

            foreach (var item in servers)
            {
                var STs = from st in serverstate where st.ProjectName + st.PublicIP == item.ProjectName + item.PublicIP select st;

                if (STs.Count() > 0)
                {
                    List <DateTime> dt1         = new List <DateTime>();
                    List <DateTime> dt2         = new List <DateTime>();
                    List <string>   runtimelist = new List <string>();
                    foreach (var sts in STs)
                    {
                        dt1.Add(sts.DTime);
                        string[] temp = sts.RunTime.Split(new char[] { 'd', 'h', 'm', 's' });
                        runtimelist.Add(sts.RunTime.Replace("d", "天").Replace("h", "小时").Replace("m", "分钟").Replace("s", "秒"));
                        dt2.Add(sts.DTime.AddDays(int.Parse(temp[0])).AddHours(int.Parse(temp[1])).AddMinutes(int.Parse(temp[2])).AddSeconds(int.Parse(temp[3])));
                    }
                    string ServerName = STs.First().ProjectName + "-" + item.RTUCount;
                    string IP         = item.PublicIP;
                    AddGanttSeriesData(cdsc, ServerName, IP, runtimelist.ToArray(), dt1.ToArray(), dt2.ToArray());
                }
            }
        }