Пример #1
0
        // copy data from a data source to the chart
        // c1c          chart
        // series       index of the series to bind (0-based, will add if necessary)
        // datasource   datasource object (cannot be DataTable, DataView is OK)
        // field        name of the field that contains the y values
        // labels       name of the field that contains the x labels
        private void BindSeries(C1Chart c1c, int series, object dataSource, string field, string labels)
        {
            // check data source object
            ITypedList il   = (ITypedList)dataSource;
            IList      list = (IList)dataSource;

            if (list == null || il == null)
            {
                throw new ApplicationException("Invalid DataSource object.");
            }

            // add series if necessary
            ChartDataSeriesCollection coll = c1c.ChartGroups[0].ChartData.SeriesList;

            while (series >= coll.Count)
            {
                coll.AddNewSeries();
            }

            // copy series data
            if (list.Count == 0)
            {
                return;
            }
            PointF[] data = (PointF[])Array.CreateInstance(typeof(PointF), list.Count);
            PropertyDescriptorCollection pdc = il.GetItemProperties(null);
            PropertyDescriptor           pd  = pdc[field];

            if (pd == null)
            {
                throw new ApplicationException(string.Format("Invalid field name used for Y values ({0}).", field));
            }

            int i;

            for (i = 0; i < list.Count; i++)
            {
                data[i].X = i;
                try
                {
                    data[i].Y = float.Parse(pd.GetValue(list[i]).ToString());
                }
                catch
                {
                    data[i].Y = float.NaN;
                }
                coll[series].PointData.CopyDataIn(data);
                coll[series].Label = field;
            }

            // copy series labels
            if (labels != null && labels.Length > 0)
            {
                pd = pdc[labels];
                if (pd == null)
                {
                    throw new ApplicationException(string.Format("Invalid field name used for X values ({0}).", labels));
                }
                Axis ax = c1c.ChartArea.AxisX;
                ax.ValueLabels.Clear();
                for (i = 0; i < list.Count; i++)
                {
                    string label = pd.GetValue(list[i]).ToString();
                    ax.ValueLabels.Add(i, label);
                }
                ax.AnnoMethod = AnnotationMethodEnum.ValueLabels;
            }
        }
Пример #2
0
        private void SetChart()
        {
            IList <Service.Model.CENTER_SERVER> servers = DataClass.servers;


            // 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.;
            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)
            {
                vals.Add(item.RegisterTime);
                names.Add(item.ProjectName);
            }
            cds.Y.CopyDataIn(vals.ToArray());
            cds.X.CopyDataIn(names.ToArray());
            cds.Tag = names;
        }
Пример #3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (r1.RadioChecked && (sjEnd.Value < sjBegin.Value))
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }
            int gaolu = 0;

            switch (this.toolStrip_gaolu.Text)
            {
            case "1高炉":
                gaolu = 1;
                break;

            case "2高炉":
                gaolu = 2;
                break;

            case "3高炉":
                gaolu = 3;
                break;

            case "4高炉":
                gaolu = 4;
                break;

            case "5高炉":
                gaolu = 5;
                break;

            case "6高炉":
                gaolu = 6;
                break;
            }

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();

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



            double[] dy1;
            //double[] dy2;
            double max;
            double min;


            LegendEnviroment.loadCanShuSetting(gaolu, "Ni", out dy1, out max, out min);
            c1Chart1.ChartArea.AxisY.Max = max;
            c1Chart1.ChartArea.AxisY.Min = min;



            Color[]  dyColor = new Color[] { Color.FromArgb(255, 192, 192), Color.FromArgb(255, 255, 192), Color.FromArgb(192, 255, 192) };
            string[] dyName  = new string[] { "过大", "正常", "过小" };


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

            StuSeries.Label             = "Ni(炉温)趋势";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.DarkBlue;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.Star;
            StuSeries.SymbolStyle.Color = Color.DarkRed;



            if (r1.RadioChecked)
            {
                c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
                c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd HH:mm";
                c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

                DateTime[] sT;
                double[]   s;

                LegendEnviroment.loadTiO2(gaolu, "FENI", sjBegin.Value, sjEnd.Value, out sT, out s);
                StuSeries.X.CopyDataIn(sT);
                StuSeries.Y.CopyDataIn(s);
                StuSeries = null;


                DateTime[] ax = new DateTime[] { sjBegin.Value, sjEnd.Value };

                for (int i = 0; i < 2; i++)
                {
                    double[] ay1 = new double[] { dy1[i], dy1[i] };
                    StuSeries                   = series.AddNewSeries();
                    StuSeries.Label             = i.ToString();
                    StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
                    StuSeries.LineStyle.Color   = Color.Black;
                    StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
                    StuSeries.SymbolStyle.Color = Color.DarkRed;
                    StuSeries.X.CopyDataIn(ax);
                    StuSeries.Y.CopyDataIn(ay1);
                    StuSeries = null;
                }
            }
            else
            {
                c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.NumericGeneral;
                c1Chart1.ChartArea.AxisX.AnnotationRotation = 90;

                long[]   sLuci;
                double[] s;
                LegendEnviroment.loadTiO2(gaolu, "FENI", toolStrip_Luci1.Text, toolStrip_Luci2.Text, out sLuci, out s);
                StuSeries.X.CopyDataIn(sLuci);
                StuSeries.Y.CopyDataIn(s);
                StuSeries = null;


                long[] ax = new long[] { Convert.ToInt64(toolStrip_Luci1.Text), Convert.ToInt64(toolStrip_Luci2.Text) };

                for (int i = 0; i < 2; i++)
                {
                    double[] ay1 = new double[] { dy1[i], dy1[i] };
                    StuSeries                   = series.AddNewSeries();
                    StuSeries.Label             = i.ToString();
                    StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
                    StuSeries.LineStyle.Color   = Color.Black;
                    StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
                    StuSeries.SymbolStyle.Color = Color.DarkRed;
                    StuSeries.X.CopyDataIn(ax);
                    StuSeries.Y.CopyDataIn(ay1);
                    StuSeries = null;
                }
            }

            double[] zoney = new double[] { dy1[0], dy1[1] };
            // Add and show the alarm zones
            AlarmZonesCollection zones = c1Chart1.ChartArea.PlotArea.AlarmZones;

            zones.Clear();
            for (int i = 0; i < 3; i++)
            {
                AlarmZone zone = zones.AddNewZone();

                zone.Name      = dyName[i];
                zone.BackColor = dyColor[i];

                if (i == 0)
                {
                    zone.UpperExtent = c1Chart1.ChartArea.AxisY.Max;
                }
                else
                {
                    zone.UpperExtent = zones[i - 1].LowerExtent;
                }

                if (i == 2)
                {
                    zone.LowerExtent = c1Chart1.ChartArea.AxisY.Min;
                }
                else
                {
                    zone.LowerExtent = zoney[i];
                }

                zone.Visible = true;
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // Populate the Logarithmic Base combo box.	 Note that the base value
            // is the base of the log used for both axes.  It can be any double value
            // greater than zero.  "e" is interpreted as the "natural" algorithm.
            string [] strItems = new string[] { "e", "2", "3", "5", "7.5", "10", "16" };
            comboBoxLogBase.Items.AddRange(strItems);
            comboBoxLogBase.SelectedIndex = comboBoxLogBase.FindStringExact("10");

            // Populate the chart with some Power Series values as these
            // readily show logarithmic behavior.
            const int pointCount = 10;

            int[] baseValues = new int[] { 2, 4, 5, 10 };

            ChartDataSeriesCollection cdsc = c1Chart1.ChartGroups.Group0.ChartData.SeriesList;

            cdsc.RemoveAll();

            for (int bi = 0; bi < baseValues.Length; bi++)
            {
                int baseValue = baseValues[bi];

                // create the Power Series data array
                PointF[] points = new PointF[pointCount];
                for (int i = 1; i < pointCount; i++)
                {
                    points[i].X = i;
                    points[i].Y = (float)Math.Pow(baseValue, i);
                }

                // Create and add a new ChartDataSeries and copy in the data array.
                ChartDataSeries cds = cdsc.AddNewSeries();
                cds.PointData.CopyDataIn(points);
                cds.Label = "y = Math.Pow(" + baseValue.ToString() + ",x)";

                // Create a Chart Label to indicate the equation used to generate the data
                // and attach it to the series appropriately.
                C1.Win.C1Chart.ChartLabels clabs = c1Chart1.ChartLabels;
                clabs.AutoArrangement.Method = AutoLabelArrangementMethodEnum.FindingOptimum;

                C1.Win.C1Chart.Label lab = clabs.LabelsCollection.AddNewLabel();
                lab.Text         = cds.Label;
                lab.AttachMethod = AttachMethodEnum.DataIndex;
                lab.AttachMethodData.GroupIndex  = 0;
                lab.AttachMethodData.PointIndex  = pointCount / 2 + bi;
                lab.AttachMethodData.SeriesIndex = bi;
                lab.Connected = true;
                lab.Compass   = LabelCompassEnum.Auto;
                lab.Style.Border.BorderStyle = BorderStyleEnum.Solid;
                lab.Visible = true;
            }

            // set the initial Logarithmic base values for the X and Y axes.
            Area area = c1Chart1.ChartArea;

            area.AxisX.LogarithmicBase = 10;
            area.AxisX.Thickness       = 1;
            area.AxisY.LogarithmicBase = 10;
            area.AxisY.Thickness       = 1;

            // call the check box handler to set axes values appropriate for
            // log or non-log axes.
            checkLOG_CheckedChanged(checkXLOG, null);
            checkLOG_CheckedChanged(checkYLOG, null);

            // Add some cosmetic attributes
            Style style = c1Chart1.Style;

            style.BackColor           = Color.DarkRed;
            style.BackColor2          = Color.OrangeRed;
            style.GradientStyle       = GradientStyleEnum.DiagonalCenter;
            style.Border.Rounding.All = 20;

            style               = c1Chart1.ChartArea.Style;
            style.BackColor     = Color.White;
            style.GradientStyle = GradientStyleEnum.None;
        }
Пример #5
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);
        }
Пример #6
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;
            }
        }
Пример #7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (r1.RadioChecked && (sjEnd.Value < sjBegin.Value))
            {
                MessageBox.Show("结束时间应该比开始时间大!");
                return;
            }

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();
            int gaolu = 0;

            switch (this.toolStrip_gaolu.Text)
            {
            case "1高炉":
                gaolu = 1;
                break;

            case "2高炉":
                gaolu = 2;
                break;

            case "3高炉":
                gaolu = 3;
                break;

            case "4高炉":
                gaolu = 4;
                break;

            case "5高炉":
                gaolu = 5;
                break;

            case "6高炉":
                gaolu = 6;
                break;
            }

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

            double[] dy;
            double   max;
            double   min;

            LegendEnviroment.newloadRSetting(gaolu, out dy, out max, out min);
            c1Chart1.ChartArea.AxisY.Max = max;
            c1Chart1.ChartArea.AxisY.Min = min;

            Color[]  dyColor = new Color[] { Color.FromArgb(255, 192, 192), Color.FromArgb(255, 255, 192), Color.FromArgb(192, 255, 192), Color.FromArgb(255, 255, 192), Color.FromArgb(255, 192, 192) };
            string[] dyName  = new string[] { "过大", "有点大", "正常", "有点小", "过小" };


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

            StuSeries.Label             = "碱度趋势";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.DarkBlue;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.Star;
            StuSeries.SymbolStyle.Color = Color.DarkRed;

            if (r1.RadioChecked)
            {
                c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
                c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd HH:mm";
                c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;
                DateTime[] siT;
                double[]   si;
                string     canshu = "ZHAR2";
                LegendEnviroment.loadTiO2(gaolu, canshu, sjBegin.Value, sjEnd.Value, out siT, out si);
                label1.Text = "标准方差:" + LegendEnviroment.stddev(si).ToString("###0.000");
                StuSeries.X.CopyDataIn(siT);
                StuSeries.Y.CopyDataIn(si);
                StuSeries = null;

                c1Chart1.Footer.Text = this.toolStrip_gaolu.Text + "  " + this.sjBegin.Text + "  ----  " + this.sjEnd.Text;

                DateTime[] ax = new DateTime[] { sjBegin.Value, sjEnd.Value };

                for (int i = 0; i < 4; i++)
                {
                    double[] ay1 = new double[] { dy[i], dy[i] };
                    StuSeries                   = series.AddNewSeries();
                    StuSeries.Label             = "最大值";
                    StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
                    StuSeries.LineStyle.Color   = Color.Black;
                    StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
                    StuSeries.SymbolStyle.Color = Color.DarkRed;
                    StuSeries.X.CopyDataIn(ax);
                    StuSeries.Y.CopyDataIn(ay1);
                    StuSeries = null;
                }
            }
            else
            {
                c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.NumericGeneral;
                c1Chart1.ChartArea.AxisX.AnnotationRotation = 90;
                long[]   siLuci;
                double[] si;
                string   wulire = "ZHAR2";
                LegendEnviroment.loadTiO2(gaolu, wulire, toolStrip_Luci1.Text, toolStrip_Luci2.Text, out siLuci, out si);
                label1.Text = "标准方差:" + LegendEnviroment.stddev(si).ToString("###0.000");
                StuSeries.X.CopyDataIn(siLuci);
                StuSeries.Y.CopyDataIn(si);
                StuSeries = null;

                c1Chart1.Footer.Text = this.toolStrip_gaolu.Text + "  " + this.toolStrip_Luci1.Text + "  ----  " + this.toolStrip_Luci2.Text;

                long[] ax = new long[] { Convert.ToInt64(toolStrip_Luci1.Text), Convert.ToInt64(toolStrip_Luci2.Text) };

                for (int i = 0; i < 4; i++)
                {
                    double[] ay1 = new double[] { dy[i], dy[i] };
                    StuSeries                   = series.AddNewSeries();
                    StuSeries.Label             = "最大值";
                    StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
                    StuSeries.LineStyle.Color   = Color.Black;
                    StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
                    StuSeries.SymbolStyle.Color = Color.DarkRed;
                    StuSeries.X.CopyDataIn(ax);
                    StuSeries.Y.CopyDataIn(ay1);
                    StuSeries = null;
                }
            }

            // Add and show the alarm zones
            AlarmZonesCollection zones = c1Chart1.ChartArea.PlotArea.AlarmZones;

            zones.Clear();
            for (int i = 0; i < 5; i++)
            {
                AlarmZone zone = zones.AddNewZone();

                zone.Name      = dyName[i];
                zone.BackColor = dyColor[i];

                if (i == 0)
                {
                    zone.UpperExtent = c1Chart1.ChartArea.AxisY.Max;
                }
                else
                {
                    zone.UpperExtent = zones[i - 1].LowerExtent;
                }

                if (i == 4)
                {
                    zone.LowerExtent = c1Chart1.ChartArea.AxisY.Min;
                }
                else
                {
                    zone.LowerExtent = dy[i];
                }

                zone.Visible = true;
            }
        }
Пример #8
0
        private void SetupRawTempChart(C1Chart chart)
        {
            // show the average mean temperature data and resize
            // the chart with the form.
            chart.Reset();
            chart.Width  = this.ClientSize.Width - chart.Left;
            chart.Height = this.ClientSize.Height / 2;

            // setup the chart appearance
            chart.Style.BackColor          = Color.White;
            chart.Style.Border.BorderStyle = BorderStyleEnum.Inset;
            chart.Style.Border.Thickness   = 2;
            chart.Style.Border.Color       = Color.Black;

            // setup the axis limits and titles
            Axis ax = chart.ChartArea.AxisX;

            ax.Min = 1880;
            ax.Max = 2020;

            ax      = chart.ChartArea.AxisY;
            ax.Text = "Temperature F";
            ax.Min  = 0;
            ax.Max  = 100;

            ax      = chart.ChartArea.AxisY2;
            ax.Text = "Temperature C";
            ax.Min  = (0.0 - 32.0) * 5.0 / 9.0;
            ax.Max  = (100.0 - 32.0) * 5.0 / 9.0;

            // Legend and header
            chart.Legend.Visible    = true;
            chart.Header.Text       = "Yearly Average Kansas City Mean Temperatures by Season";
            chart.Header.Style.Font = new Font("Arial Narrow", 12, FontStyle.Bold);

            // get and add the data
            double [] years = KansasCityTempData(SeasonEnum.Years);
            ChartDataSeriesCollection cdsc = chart.ChartGroups[0].ChartData.SeriesList;

            // use a thicker line for the plots so the lines are very visible.
            const int lineThickness = 2;

            // Winter
            ChartDataSeries cds = cdsc.AddNewSeries();

            cds.X.CopyDataIn(years);
            cds.Y.CopyDataIn(KansasCityTempData(SeasonEnum.Winter));
            cds.SymbolStyle.Shape   = SymbolShapeEnum.None;
            cds.Label               = "Winter";
            cds.LineStyle.Color     = Color.Blue;
            cds.LineStyle.Thickness = lineThickness;

            // Spring
            cds = cdsc.AddNewSeries();
            cds.X.CopyDataIn(years);
            cds.Y.CopyDataIn(KansasCityTempData(SeasonEnum.Spring));
            cds.SymbolStyle.Shape   = SymbolShapeEnum.None;
            cds.Label               = "Spring";
            cds.LineStyle.Color     = Color.Green;
            cds.LineStyle.Thickness = lineThickness;

            // Summer
            cds = cdsc.AddNewSeries();
            cds.X.CopyDataIn(years);
            cds.Y.CopyDataIn(KansasCityTempData(SeasonEnum.Summer));
            cds.SymbolStyle.Shape   = SymbolShapeEnum.None;
            cds.Label               = "Summer";
            cds.LineStyle.Color     = Color.Red;
            cds.LineStyle.Thickness = lineThickness;

            // Fall
            cds = cdsc.AddNewSeries();
            cds.X.CopyDataIn(years);
            cds.Y.CopyDataIn(KansasCityTempData(SeasonEnum.Fall));
            cds.SymbolStyle.Shape   = SymbolShapeEnum.None;
            cds.Label               = "Fall";
            cds.LineStyle.Color     = Color.Brown;
            cds.LineStyle.Thickness = lineThickness;

            // add a series to Group1 so the Y2 axis is shown.  At the same time
            // hide the series in the legend, since it is a dummy series.
            chart.ChartGroups[1].ChartData.SeriesList.AddNewSeries().LegendEntry = false;
        }
Пример #9
0
        private void SetupHistogramChart(C1Chart chartRaw, C1Chart chartHisto)
        {
            chartHisto.Reset();
            chartHisto.Left = 0;
            Form1_Resize(null, null);

            // Setup the Histogram chart appearance
            chartHisto.Style.BackColor          = Color.AliceBlue;
            chartHisto.Style.Border.BorderStyle = BorderStyleEnum.Solid;
            chartHisto.Style.Border.Thickness   = 2;
            chartHisto.Style.Border.Color       = Color.Black;
            chartHisto.Legend.Visible           = true;

            // Create a histogram type chart using a bar chart type rather an actual
            // histogram type.  Histograms reflect single series of data well, but do
            // not show multiple series as well as a bar chart.
            //
            // Use the chart static method to generate histogram data from the raw data.
            ChartGroup cgHisto = chartHisto.ChartGroups[0];
            ChartDataSeriesCollection cdscHisto = cgHisto.ChartData.SeriesList;

            cgHisto.ChartType = Chart2DTypeEnum.Bar;

            // obtain the data from chartRaw.
            ChartData cdRaw = chartRaw.ChartGroups[0].ChartData;
            ChartDataSeriesCollection cdscRaw = cdRaw.SeriesList;
            double dataMax = 0, dataMin = 0;

            // determine the extremes from the series means
            foreach (ChartDataSeries cdsRaw0 in cdscRaw)
            {
                double mean = cdsRaw0.Y.Statistics.Mean;
                double mn   = cdsRaw0.MinY - mean;
                double mx   = cdsRaw0.MaxY - mean;

                if (dataMax < mx)
                {
                    dataMax = mx;
                }
                if (dataMin > mn)
                {
                    dataMin = mn;
                }
            }

            dataMax = Math.Ceiling(dataMax);
            dataMin = Math.Floor(dataMin);

            // Assume that the interval width is one degree.
            int intervalCount = (int)(dataMax - dataMin) + 1;

            foreach (ChartDataSeries cdsRaw in cdscRaw)
            {
                double [] rawData = (double[])cdsRaw.Y.CopyDataOut(typeof(double));

                // determine the difference of each point from the mean.
                double mean = cdsRaw.Y.Statistics.Mean;

                double [] differencesFromMean = (double[])rawData.Clone();
                for (int d = 0; d < differencesFromMean.Length; d++)
                {
                    differencesFromMean[d] -= mean;
                }

                double [] xbounds = null;
                double [] ycounts = null;
                double [] bis     = null;

                // generate histogram data of the difference from the means.  Start
                // using a half-width less than the dataMin.  This will provide
                // intervals that center on each integral temperature difference.
                C1Chart.GenerateHistogramData(differencesFromMean, dataMin - 0.5, 1.0,
                                              intervalCount, -1.0, ref xbounds, ref ycounts, ref bis);

                // add a series of histogramdata
                ChartDataSeries cdsHisto = cdscHisto.AddNewSeries();
                cdsHisto.Label           = cdsRaw.Label;
                cdsHisto.LineStyle.Color = Color.FromArgb(128, cdsRaw.LineStyle.Color);

                bis = (double[])Array.CreateInstance(typeof(double), intervalCount);
                for (int p = 0; p < intervalCount; p++)
                {
                    bis[p] = (xbounds[p] + xbounds[p + 1]) / 2;
                }

                cdsHisto.X.CopyDataIn(bis);
                cdsHisto.Y.CopyDataIn(ycounts);
            }

            // Add description and instructions to the header, footer and axes.
            chartHisto.Header.Text          = "Bar Chart Histogram of Differences from Seasonal Mean Kansas City Temperatures";
            chartHisto.Header.Style.Font    = chartRaw.Header.Style.Font;
            chartHisto.Footer.Text          = "Double-Click to Toggle Bar Stacking";
            chartHisto.ChartArea.AxisX.Text = "Difference From Mean Seasonal Mean Temperature (F)";
            chartHisto.ChartArea.AxisY.Text = "Count of Seasonal Mean Temperatures";
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Size the form to fit any screen
            this.ClientSize = new Size(600, 400);

            // Center the form
            this.CenterToParent();

            // Fill the form client area with the chart
            c1Chart1.Dock = DockStyle.Fill;

            // Get the data arrays and data.
            int[] StudentScores  = this.GetStudentPointTotals();
            int[] StudentNumbers = (int[])Array.CreateInstance(typeof(int), StudentScores.Length);
            int   nStudents      = StudentScores.Length;
            int   i;

            for (i = 0; i < nStudents; i++)
            {
                StudentNumbers[i] = i;
            }

            // Get the statistics
            double mean   = FindMean(StudentScores);
            double stddev = FindStdDev(StudentScores, mean);

            // Set up the header
            c1Chart1.Header.Text       = "Student Scores and Grades";
            c1Chart1.Header.Style.Font = new Font("Tahoma", 18, FontStyle.Bold);

            // Set the background color
            c1Chart1.Style.BackColor = Color.FromArgb(128, 192, 150);

            // Clear the existing data
            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();

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

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

            StuSeries.Label             = "raw scores";
            StuSeries.LineStyle.Pattern = LinePatternEnum.None;
            StuSeries.LineStyle.Color   = c1Chart1.Style.BackColor;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.Star;
            StuSeries.SymbolStyle.Color = Color.DarkRed;
            StuSeries.X.CopyDataIn(StudentNumbers);
            StuSeries.Y.CopyDataIn(StudentScores);
            StuSeries = null;

            // mean + 2 s
            LinePatternEnum [] LinePatterns = new LinePatternEnum[]
            {
                LinePatternEnum.Dash, LinePatternEnum.DashDot,
                LinePatternEnum.Solid,
                LinePatternEnum.DashDotDot, LinePatternEnum.Dot
            };
            for (i = 2; i >= -2; i--)
            {
                ChartDataSeries StatSeries = series.AddNewSeries();
                double []       xd         = new double [] { 0, nStudents };
                double []       yd         = new double [] { mean + i * stddev, mean + i * stddev };

                StatSeries.X.CopyDataIn(xd);
                StatSeries.Y.CopyDataIn(yd);
                StatSeries.SymbolStyle.Shape   = SymbolShapeEnum.None;
                StatSeries.LineStyle.Pattern   = LinePatterns[i + 2];
                StatSeries.LineStyle.Color     = Color.Black;
                StatSeries.LineStyle.Thickness = 1;

                if (i > 0)
                {
                    StatSeries.Label = "m+" + i.ToString() + "s";
                }
                else if (i < 0)
                {
                    StatSeries.Label = "m" + i.ToString() + "s";
                }
                else
                {
                    StatSeries.Label = "mean";
                    StatSeries.LineStyle.Thickness = 2;
                    StatSeries.LineStyle.Pattern   = LinePatternEnum.Solid;
                }
            }

            // box the plot area
            c1Chart1.ChartArea.PlotArea.Boxed = true;

            // Show the legend
            c1Chart1.Legend.Visible = true;

            // Set the Axis titles
            c1Chart1.ChartArea.AxisX.Text = "Student Number";
            c1Chart1.ChartArea.AxisY.Text = "Student Accumulated Points";

            // sort the student scores so they can be analyzed
            Array.Sort(StudentScores);

            // Define each of the letter grades
            string [] GradeLetter = new String[] { "A", "B", "C", "D", "F" };

            // Get the bounds of each letter grade
            // At most 95% of the students will not get an A
            // At most 75% of the students will not get a B or higher
            // At most 25% of the students will not get a C or higher
            // At most 5% of the students will not get a D or higher
            int [] GradeBounds = new int[]
            {
                StudentScores[GetBoundingIndex(StudentScores, 0.95)],
                StudentScores[GetBoundingIndex(StudentScores, 0.75)],
                StudentScores[GetBoundingIndex(StudentScores, 0.25)],
                StudentScores[GetBoundingIndex(StudentScores, 0.05)]
            };

            // get the color codes for each grade
            Color [] GradeColor = new Color[]
            {
                Color.FromArgb(128, 128, 225), Color.FromArgb(128, 255, 128),
                Color.FromArgb(255, 228, 128), Color.FromArgb(55, 228, 228),
                Color.FromArgb(255, 192, 192)
            };

            // Add the chart labels.  They will be positioned later
            ChartLabels labels = c1Chart1.ChartLabels;

            labels.DefaultLabelStyle.BackColor = c1Chart1.Style.BackColor;
            labels.DefaultLabelStyle.Font      = new Font("Courier New", 16, FontStyle.Bold);

            C1.Win.C1Chart.Label lab = null;
            for (i = 0; i < 5; i++)
            {
                lab                 = labels.LabelsCollection.AddNewLabel();
                lab.Text            = GradeLetter[i];
                lab.Style.BackColor = GradeColor[i];
                lab.AttachMethod    = AttachMethodEnum.Coordinate;
                lab.Visible         = true;
            }

            // Below are calculations and settings that depend upon auto
            // positioning of the chart.  The auto positions are only
            // calculated during rendering of the chart.  Force the
            // chart to be rendered so the chart element positions are
            // calculated.

            // Force calculation of chart element positions
            c1Chart1.GetImage();

            // Add and show the alarm zones
            AlarmZonesCollection zones = c1Chart1.ChartArea.PlotArea.AlarmZones;

            for (i = 0; i < 5; i++)
            {
                AlarmZone zone = zones.AddNewZone();

                zone.Name      = GradeLetter[i];
                zone.BackColor = GradeColor[i];

                if (i == 0)
                {
                    zone.UpperExtent = c1Chart1.ChartArea.AxisY.Max;
                }
                else
                {
                    zone.UpperExtent = zones[i - 1].LowerExtent;
                }

                if (i == 4)
                {
                    zone.LowerExtent = c1Chart1.ChartArea.AxisY.Min;
                }
                else
                {
                    zone.LowerExtent = GradeBounds[i];
                }

                zone.Visible = true;
            }

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

            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();

            int gaolu = 0;

            switch (this.toolStrip_gaolu.Text)
            {
            case "1高炉":
                gaolu = 1;
                break;

            case "2高炉":
                gaolu = 2;
                break;

            case "3高炉":
                gaolu = 3;
                break;

            case "4高炉":
                gaolu = 4;
                break;

            case "5高炉":
                gaolu = 5;
                break;

            case "6高炉":
                gaolu = 6;
                break;
            }

            DateTime[] shengyureT;
            double[]   shengyuere;
            DateTime[] yurebiliT;
            double[]   yurebili;
            DateTime[] siT;
            double[]   si;

            LegendEnviroment.loadSYR(gaolu, sjBegin.Value, sjEnd.Value, out shengyureT, out shengyuere, out yurebiliT, out yurebili, out siT, out si);

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

            c1Chart1.ChartArea.AxisX.AnnoFormat         = FormatEnum.DateManual;
            c1Chart1.ChartArea.AxisX.AnnoFormatString   = "MM/dd HH:mm";
            c1Chart1.ChartArea.AxisX.AnnotationRotation = 0;

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

            StuSeries.Label             = "剩余热";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.DarkGoldenrod;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
            StuSeries.X.CopyDataIn(shengyureT);
            StuSeries.Y.CopyDataIn(shengyuere);
            StuSeries = null;

            //plot the student scores
            StuSeries                   = series.AddNewSeries();
            StuSeries.Label             = "余热比例";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.DarkGray;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
            StuSeries.X.CopyDataIn(yurebiliT);
            StuSeries.Y.CopyDataIn(yurebili);
            StuSeries = null;

            //plot the student scores
            StuSeries                   = series.AddNewSeries();
            StuSeries.Label             = "炉温(Si)";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.Red;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
            StuSeries.X.CopyDataIn(siT);
            StuSeries.Y.CopyDataIn(si);
            StuSeries = null;
        }
Пример #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 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);
        }
Пример #16
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);
        }
Пример #17
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear();

            List <DateTime>  dts  = new List <DateTime>();
            List <double>    vs   = new List <double>();
            DateTime         dt1  = DateTime.Now.AddDays(-1);
            DateTime         dt2  = DateTime.Now;
            OracleConnection conn = new OracleConnection(Properties.Settings.Default.ConnectionString);

            conn.Open();
            int gaolu = 0;

            switch (this.toolStrip_gaolu.Text)
            {
            case "1高炉":
                gaolu = 1;
                break;

            case "2高炉":
                gaolu = 2;
                break;

            case "3高炉":
                gaolu = 3;
                break;

            case "4高炉":
                gaolu = 4;
                break;

            case "5高炉":
                gaolu = 5;
                break;
            }
            string        sql   = "select zdsj,FESi from ddluci where zdsj>=:sjBegin and zdsj<=:sjEnd and gaolu=:gaolu";
            OracleCommand siCmd = new OracleCommand(sql, conn);

            siCmd.Parameters.Add(":sjBegin", OracleType.DateTime).Value = this.sjBegin.Value;
            siCmd.Parameters.Add(":sjEnd", OracleType.DateTime).Value   = this.sjEnd.Value;
            siCmd.Parameters.Add(":gaolu", OracleType.Int32).Value      = gaolu;
            OracleDataReader dr = siCmd.ExecuteReader();

            while (dr.Read())
            {
                dts.Add(dr.GetDateTime(0));
                vs.Add(dr.GetDouble(1));
            }
            dr.Close();
            conn.Close();

            c1Chart1.Header.Text = this.toolStrip_gaolu.Text + "  " + this.sjBegin.Text + "--" + this.sjEnd.Text + "Si(炉温)趋势";

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

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

            StuSeries.Label             = "Si(炉温)趋势";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.DarkBlue;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.Star;
            StuSeries.SymbolStyle.Color = Color.DarkRed;
            StuSeries.X.CopyDataIn(dts.ToArray());
            StuSeries.Y.CopyDataIn(vs.ToArray());
            StuSeries = null;


            DateTime[] ax  = new DateTime[] { dts[0], dts[dts.Count - 1] };
            double[]   ay1 = new double[] { 0.7, 0.7 };
            double[]   ay2 = new double[] { 0.4, 0.4 };

            StuSeries                   = series.AddNewSeries();
            StuSeries.Label             = "最大值";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.Black;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
            StuSeries.SymbolStyle.Color = Color.DarkRed;
            StuSeries.X.CopyDataIn(ax);
            StuSeries.Y.CopyDataIn(ay1);
            StuSeries = null;


            StuSeries                   = series.AddNewSeries();
            StuSeries.Label             = "最小值";
            StuSeries.LineStyle.Pattern = LinePatternEnum.Solid;
            StuSeries.LineStyle.Color   = Color.Black;
            StuSeries.SymbolStyle.Shape = SymbolShapeEnum.None;
            StuSeries.SymbolStyle.Color = Color.DarkRed;
            StuSeries.X.CopyDataIn(ax);
            StuSeries.Y.CopyDataIn(ay2);
            StuSeries = null;


            // Add and show the alarm zones
            AlarmZonesCollection zones = c1Chart1.ChartArea.PlotArea.AlarmZones;

            zones.Clear();

            AlarmZone zone1 = zones.AddNewZone();
            AlarmZone zone2 = zones.AddNewZone();
            AlarmZone zone3 = zones.AddNewZone();

            zone1.Name        = "大值区";
            zone1.BackColor   = Color.Aqua;
            zone1.UpperExtent = c1Chart1.ChartArea.AxisY.Max;
            zone1.LowerExtent = 0.7;
            zone1.Visible     = true;


            zone2.Name        = "正常";
            zone2.BackColor   = Color.Beige;
            zone2.UpperExtent = 0.7;
            zone2.LowerExtent = 0.4;
            zone2.Visible     = true;


            zone3.Name        = "小值区";
            zone3.BackColor   = Color.Aqua;
            zone3.UpperExtent = 0.4;
            zone3.LowerExtent = c1Chart1.ChartArea.AxisY.Min;
            zone3.Visible     = true;
        }
Пример #18
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;
            }
        }