Пример #1
0
        private void AnnotateSlices(C1.Win.C1Chart.C1Chart chart)
        {
            Style s = chart.ChartLabels.DefaultLabelStyle;

            s.BackColor          = SystemColors.Info;
            s.Opaque             = true;
            s.Border.BorderStyle = BorderStyleEnum.Solid;

            ChartDataSeriesCollection series = chart.ChartGroups[0].ChartData.SeriesList;

            chart.ChartLabels.LabelsCollection.Clear();
            // Attach labels to each slice
            for (int i = 0; i < series.Count; i++)
            {
                C1.Win.C1Chart.Label label = chart.ChartLabels.LabelsCollection.AddNewLabel();
                label.Text         = String.Format("{0:C0}", series[i].Y[0]);
                label.Compass      = LabelCompassEnum.Radial;
                label.Offset       = 20;
                label.Connected    = true;
                label.Visible      = true;
                label.AttachMethod = AttachMethodEnum.DataIndex;
                AttachMethodData am = label.AttachMethodData;
                am.GroupIndex  = 0;
                am.SeriesIndex = i;
                am.PointIndex  = 0;

                series[i].Offset = 0;
            }
        }
Пример #2
0
        public void AnnotateSlicewithImage(C1.Win.C1Chart.C1Chart chart, int seriesIndex)
        {
            ChartDataSeriesCollection series = chart.ChartGroups[0].ChartData.SeriesList;
            LabelsCollection          labels = c1Chart1.ChartLabels.LabelsCollection;

            C1.Win.C1Chart.Label label;
            label                          = labels.AddNewLabel();
            label.Image                    = imageList1.Images[seriesIndex];
            label.Style.BackColor          = Color.Transparent;
            label.Style.Border.BorderStyle = BorderStyleEnum.None;
            label.Style.GradientStyle      = GradientStyleEnum.None;
            label.Style.ImageAlignment     = AlignImageEnum.Top;
            label.Size                     = label.Image.Size + new Size(0, 20);
            label.Compass                  = LabelCompassEnum.Radial;
            label.Offset                   = 30;
            label.Connected                = false;
            label.Visible                  = true;
            label.AttachMethod             = AttachMethodEnum.DataIndex;
            label.Text                     = String.Format("{0:C0}", series[seriesIndex].Y[0]);

            AttachMethodData am = label.AttachMethodData;

            am.GroupIndex  = 0;
            am.SeriesIndex = seriesIndex;
            am.PointIndex  = 0;
        }
Пример #3
0
        private void ConfigureSymbols(bool lines)
        {
            ChartGroup g = c1Chart1.ChartGroups.Group0;
            ChartDataSeriesCollection series = g.ChartData.SeriesList;
            int n = 0;

            SymbolShapeEnum[] shapes =
            {
                SymbolShapeEnum.Box,
                SymbolShapeEnum.Dot,
                SymbolShapeEnum.Diamond,
                SymbolShapeEnum.Tri
            };

            foreach (ChartDataSeries s in series)
            {
                s.SymbolStyle.Shape = shapes[n++];

                if (lines)
                {
                    s.LineStyle.Thickness = 1;
                }
                else
                {
                    s.LineStyle.Pattern = LinePatternEnum.None;
                }
            }
        }
Пример #4
0
        // Add Chart Labels with beginning and ending dates for each data point
        // in the Gantt chart.  Labels are placed inside on the western edge.
        private void AddGanttTaskLabels(C1Chart chart, ChartDataSeriesCollection cdsc)
        {
            ChartLabels cl = chart.ChartLabels;

            cl.DefaultLabelStyle.BackColor           = Color.Transparent;
            cl.DefaultLabelStyle.GradientStyle       = GradientStyleEnum.None;
            cl.DefaultLabelStyle.ForeColor           = Color.Azure;
            cl.DefaultLabelStyle.HorizontalAlignment = AlignHorzEnum.Far;

            C1.Win.C1Chart.LabelsCollection clc = cl.LabelsCollection;
            clc.Clear();

            int slen = cdsc.Count;

            for (int s = 0; s < cdsc.Count; s++)
            {
                ChartDataSeries cds = cdsc[s];
                for (int p = 0; p < cds.Length; p++)
                {
                    C1.Win.C1Chart.Label lab   = clc.AddNewLabel();
                    DateTime             start = (DateTime)cds.Y[p];
                    DateTime             end   = (DateTime)cds.Y1[p];
                    lab.Text         = start.ToString("ddMMM") + "-" + end.ToString("ddMMM");
                    lab.AttachMethod = AttachMethodEnum.DataIndex;
                    lab.AttachMethodData.GroupIndex  = 0;
                    lab.AttachMethodData.SeriesIndex = s;
                    lab.AttachMethodData.PointIndex  = p;
                    lab.Compass = LabelCompassEnum.West;
                    lab.Offset  = 0;
                    lab.Visible = true;
                }
            }
        }
Пример #5
0
        private void Gallery_Load(object sender, EventArgs e)
        {
            categorySales1.ResetBindings(false);
            c1Chart1.ChartArea.AxisX.AnnotationRotation = -30;
            comboPalette.DataSource   = Enum.GetValues(typeof(ColorGeneration));
            comboPalette.SelectedItem = ColorGeneration.Custom;

            // setup tooltips
            ChartDataSeriesCollection sc = c1Chart1.ChartGroups[0].ChartData.SeriesList;

            foreach (ChartDataSeries ds in sc)
            {
                ds.TooltipText = "Series: {#TEXT}" + '\r' + '\n' + "x = {#XVAL}" + '\r' + '\n' + "y = {#YVAL}";
            }

            // setup pointstyle
            InitPointStyle();
            _ps.Selection   = PointStyleSelectionEnum.Index;
            _ps.SeriesIndex = 0;
            _ps.PointIndex  = 0;

            // add demo properties
            AddProperty("Compass", c1Chart1.ChartArea.AxisX, "AxisX.Compass");
            AddProperty("Compass", c1Chart1.ChartArea.AxisY, "AxisY.Compass");
            AddProperty("Alpha", this, "FillStyle.Alpha");
            AddProperty("GridLines", this);
            AddProperty("PointStyle", this, "Highlighting");
            AddProperty("ShowOutline", c1Chart1.ChartGroups.Group0);
            AddProperty("Enabled", c1Chart1.ToolTip, "Tooltips");
            AddProperty("Enabled", c1Chart1.VisualEffects["Default"], "VisualEffects");
        }
Пример #6
0
        //offsets a particular pie slice
        private void ExplodeSlice(C1.Win.C1Chart.C1Chart chart, int series, int offset, bool fromClick)
        {
            if (radImageLabels.Checked)
            {
                ChartGroup g = chart.ChartGroups.Group0;
                ChartDataSeriesCollection seriesList = g.ChartData.SeriesList;

                for (int i = 0; i < seriesList.Count; i++)
                {
                    if (i == series)
                    {
                        if (seriesList[i].Offset == 10 && fromClick)
                        {
                            seriesList[i].Offset = 0;
                            RemoveSliceImage(chart, i);
                        }
                        else
                        {
                            seriesList[i].Offset = offset;
                            AnnotateSlicewithImage(chart, i);
                        }
                        return;
                    }
                }
            }
        }
        private void setDataLabelsStatus(bool labelsOn)
        {
            ChartDataSeriesCollection seriesList = c1Chart1.ChartGroups.Group0.ChartData.SeriesList;

            foreach (ChartDataSeries cds in seriesList)
            {
                cds.DataLabel.Visible = labelsOn;
            }
        }
Пример #8
0
        // Adds a new series to the Gantt chart accepting a task name,
        // an array of starting times and an array of ending times.
        private void AddGanttSeriesData(ChartDataSeriesCollection cdsc,
                                        string taskName, DateTime[] startTimes, DateTime[] endTimes)
        {
            ChartDataSeries cds = cdsc.AddNewSeries();

            cds.Label = taskName;
            cds.Y.CopyDataIn(startTimes);
            cds.Y1.CopyDataIn(endTimes);
        }
Пример #9
0
        private void ConfigureStepChart(bool threed)
        {
            ResetChart();
            ChartGroup g = c1Chart1.ChartGroups.Group0;

            g.ChartType = Chart2DTypeEnum.Step;
            ChartDataSeriesCollection series = g.ChartData.SeriesList;

            g.Use3D = threed;
        }
Пример #10
0
        // Adds a new series to the Gantt chart accepting a task name,
        // an array of starting times and an array of ending times.
        private void AddGanttSeriesData(ChartDataSeriesCollection cdsc, string ServerName, string IP, string[] runtimelist, DateTime[] startTimes, DateTime[] endTimes)
        {
            ChartDataSeries cds = cdsc.AddNewSeries();

            cds.Label = ServerName;
            cds.Y.CopyDataIn(startTimes);
            cds.Y1.CopyDataIn(endTimes);
            cds.Tag         = runtimelist;
            cds.TooltipText = ServerName + "\r\n" + IP;
        }
        private void radioChartTypeChanged(object sender, System.EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;

            if (rb.Checked)
            {
                Chart2DTypeEnum ct = (Chart2DTypeEnum)rb.Tag;
                c1Chart1.ChartGroups[0].ChartType = ct;

                int  maxSeries = 10;
                bool stackable = true;

                // special cases that limit the number of series shown.
                // this allows the demo to use the same data for all charts.
                switch (ct)
                {
                case Chart2DTypeEnum.Pie:
                    stackable = false;
                    break;

                case Chart2DTypeEnum.HiLo:
                case Chart2DTypeEnum.Bubble:
                    stackable = false;
                    maxSeries = 2;
                    break;

                case Chart2DTypeEnum.HiLoOpenClose:
                case Chart2DTypeEnum.Candle:
                    stackable = false;
                    maxSeries = 1;
                    break;
                }

                checkStacked.Enabled = stackable;

                ChartGroup grp = c1Chart1.ChartGroups[0];
                ChartDataSeriesCollection sl = grp.ChartData.SeriesList;
                int slim = sl.Count;
                for (int s = 0; s < slim; s++)
                {
                    if (s < maxSeries)
                    {
                        sl[s].Display = SeriesDisplayEnum.Show;
                    }
                    else
                    {
                        sl[s].Display = SeriesDisplayEnum.Exclude;
                    }
                }
            }
        }
Пример #12
0
        public SeriesData(C1Chart chart, ImageList images)
        {
            ChartDataSeriesCollection sc = chart.ChartGroups[0].ChartData.SeriesList;

            m_sers = (SeriesInfo[])Array.CreateInstance(typeof(SeriesInfo), sc.Count);
            for (int i = 0; i < sc.Count; i++)
            {
                Image img = null;
                if (i < images.Images.Count)
                {
                    img = images.Images[i];
                }
                m_sers[i] = new SeriesInfo(sc[i], img);
            }
        }
Пример #13
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);
        }
Пример #14
0
        private void ConfigureLineChart(bool threed, bool stacked, FitTypeEnum fit)
        {
            ResetChart();
            ChartGroup g = c1Chart1.ChartGroups.Group0;

            g.ChartType = Chart2DTypeEnum.XYPlot;
            ChartDataSeriesCollection series = g.ChartData.SeriesList;

            g.Use3D   = threed;
            g.Stacked = stacked;

            foreach (ChartDataSeries s in series)
            {
                s.FitType = fit;
            }
        }
Пример #15
0
        private void ResetChart()
        {
            categorySales1.ResetBindings(false);
            c1Chart1.ChartArea.Inverted = false;
            c1Chart1.ChartArea.AxisX.AnnotationRotation = -30;
            ChartGroup g = c1Chart1.ChartGroups.Group0;
            ChartDataSeriesCollection series = g.ChartData.SeriesList;

            foreach (ChartDataSeries s in series)
            {
                s.SymbolStyle.Shape   = SymbolShapeEnum.None;
                s.LineStyle.Thickness = 3;
                s.LineStyle.Pattern   = LinePatternEnum.Solid;
            }
            ApplyThemePalette();
            this.Alpha = 192;
        }
Пример #16
0
        private void chkAlpha_CheckedChanged(object sender, System.EventArgs e)
        {
            bool useAlpha = chkAlpha.Checked;
            ChartDataSeriesCollection cdsc = c1Chart1.ChartGroups[0].ChartData.SeriesList;

            foreach (ChartDataSeries cds in cdsc)
            {
                if (useAlpha && cds.FillStyle.Alpha == 255)
                {
                    cds.FillStyle.Alpha = 100;
                }
                else if (cds.FillStyle.Alpha < 255)
                {
                    cds.FillStyle.Alpha = 255;
                }
            }
        }
        private void SliceOffsetTextChanged(object sender, System.EventArgs e)
        {
            TextBox tb    = (TextBox)sender;
            int     index = (int)tb.Tag;
            ChartDataSeriesCollection serList = c1Chart1.ChartGroups[0].ChartData.SeriesList;

            if (index >= 0 && index < serList.Count)
            {
                ChartDataSeries series = serList[index];
                int             offset = series.Offset;
                try
                {
                    offset        = int.Parse(tb.Text);
                    series.Offset = offset;
                }
                catch {}
            }
        }
Пример #18
0
        private void chkAlpha_CheckedChanged(object sender, System.EventArgs e)
        {
            int alpha;

            if (chkAlpha.Checked)
            {
                alpha = 100;
            }
            else
            {
                alpha = 255;
            }

            ChartDataSeriesCollection cdsc = c1Chart1.ChartGroups[0].ChartData.SeriesList;

            cdsc[0].LineStyle.Color = Color.FromArgb(alpha, cdsc[0].LineStyle.Color);
            cdsc[1].LineStyle.Color = Color.FromArgb(alpha, cdsc[1].LineStyle.Color);
        }
Пример #19
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";
        }
Пример #20
0
        private void SetupStatisticsInfo(C1Chart chart)
        {
            // obtain the temperature statistics from the chart series, and report
            // them through the textbox.
            TextBox tb = txtStatistics;
            ChartDataSeriesCollection cdsc = chart.ChartGroups[0].ChartData.SeriesList;

            foreach (ChartDataSeries cds in cdsc)
            {
                double mean  = cds.Y.Statistics.Mean;
                double meanC = (mean - 32) * 5.0 / 9.0;

                double sd  = cds.Y.Statistics.StdDev;
                double sdC = sd * 5.0 / 9.0;

                tb.Text += cds.Label + "\r\n";
                tb.Text += "   Mean:   " + mean.ToString("0.0") + "F (" + meanC.ToString("0.0") + "C)\r\n";
                tb.Text += "   StdDev: " + sd.ToString("0.00") + "F (" + sdC.ToString("0.00") + "C)\r\n\r\n";
            }
        }
Пример #21
0
        void initgrap()
        {
            ChartData cd = Chart1.ChartGroups.Group0.ChartData;
            ChartDataSeriesCollection cdsc = cd.SeriesList;

            foreach (ChartDataSeries cds in cdsc)
            {
                cds.SymbolStyle.Shape = SymbolShapeEnum.Dot;
                cds.SymbolStyle.Size  = 0;
            }

            PointStyle ps = Chart1.ChartGroups.Group0.ChartData.PointStylesList.AddNewPointStyle();

            ps.SymbolStyle.Shape = SymbolShapeEnum.Dot;
            ps.SymbolStyle.Size  = 10;
            ps.SymbolStyle.Color = Color.Red;
            ps.PointIndex        = -1;
            ps.SeriesIndex       = -1;
            ps.Label             = "trackingBall";
        }
Пример #22
0
        private void ConfigurePieChart(bool threed, bool stacked, int doughnut, int slice)
        {
            ResetChart();
            ChartGroup g = c1Chart1.ChartGroups.Group0;

            g.ChartType       = Chart2DTypeEnum.Pie;
            g.Pie.InnerRadius = doughnut;
            ChartDataSeriesCollection series = g.ChartData.SeriesList;

            foreach (ChartDataSeries s in series)
            {
                s.Offset = slice;
            }
            g.Use3D   = threed;
            g.Stacked = stacked;
            if (stacked == true)
            {
                this.Alpha = 255;
            }
            else
            {
                this.Alpha = 192;
            }
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            Form1_Resize(null, null);
            c1Chart1.ChartArea.AxisY.SetMinMax(0, 30);

            // using the routine GetPoints defined above, create some
            // additional data and add it to the chart.
            PointF[] pfs = GetPoints(3, 201, 1, 5, 1, 7.5);
            ChartDataSeriesCollection cdsc = c1Chart1.ChartGroups[0].ChartData.SeriesList;
            ChartDataSeries           cds  = cdsc.AddNewSeries();

            cds.PointData.CopyDataIn(pfs);
            cds.SymbolStyle.Shape = SymbolShapeEnum.None;

            // turn on all of the checked listbox items.
            for (int z = 0; z < zoneSelect.Items.Count; z++)
            {
                zoneSelect.SetItemChecked(z, true);
            }

            // create the alarm zones.
            AlarmZonesCollection azs = c1Chart1.ChartArea.PlotArea.AlarmZones;

            // add the rectangle
            AlarmZone az = azs.AddNewZone();

            az.Name        = (string)zoneSelect.Items[0];
            az.BackColor   = Color.FromArgb(100, Color.Red);
            az.Shape       = AlarmZoneShapeEnum.Rectangle;
            az.UpperExtent = 20;
            az.LowerExtent = 16;
            az.FarExtent   = 2.5;
            az.NearExtent  = 1.5;
            az.Visible     = true;

            // add the ellipse
            az             = azs.AddNewZone();
            az.BackColor   = Color.FromArgb(100, Color.Blue);
            az.Shape       = AlarmZoneShapeEnum.Ellipse;
            az.Name        = (string)zoneSelect.Items[1];
            az.UpperExtent = 24;
            az.LowerExtent = 16;
            az.FarExtent   = 4.5;
            az.NearExtent  = 3;
            az.Visible     = true;

            // add a polygon defined by coordinates.  Coordinates
            // are obtained using the GetPoints method defined above.
            az             = azs.AddNewZone();
            az.BackColor   = Color.FromArgb(100, Color.Green);
            az.Shape       = AlarmZoneShapeEnum.Polygon;
            az.Name        = (string)zoneSelect.Items[2];
            az.UpperExtent = 14;
            az.LowerExtent = 8;
            az.FarExtent   = 4.5;
            az.NearExtent  = 2.5;
            pfs            = GetPoints(1, 15, az.NearExtent, az.FarExtent,
                                       az.LowerExtent, az.UpperExtent);
            az.PolygonData.PointData.CopyDataIn(pfs);
            az.Visible = true;

            // add a polygon
            az                = azs.AddNewZone();
            az.BackColor      = Color.FromArgb(100, Color.Yellow);
            az.PatternStyle   = HatchStyle.DiagonalBrick;
            az.PatternVisible = true;
            az.Shape          = AlarmZoneShapeEnum.Rectangle;
            az.Name           = (string)zoneSelect.Items[4];
            az.UpperExtent    = 24;
            az.LowerExtent    = 24;
            az.FarExtent      = 3;
            az.NearExtent     = 3;
            az.MinHeight      = 32;
            az.MinWidth       = 32;
            az.Visible        = true;

            // add another polygon defined by the DataSeries.
            az           = azs.AddNewZone();
            az.BackColor = Color.FromArgb(100, Color.Brown);
            az.Shape     = AlarmZoneShapeEnum.Polygon;
            az.PolygonData.PolygonSource = PolygonSourceEnum.DataSeries;
            az.PolygonData.SeriesIndex   = 4;
            az.Name        = (string)zoneSelect.Items[3];
            az.UpperExtent = 10;
            az.LowerExtent = 6;
            az.NearExtent  = 1.15;
            az.FarExtent   = 2.25;
            az.Visible     = true;


            // Add a Header that will be updated to the current AlarmZone
            // under the cursor.
            c1Chart1.Header.Text = "-- Mouse is not over an AlarmZone --";

            // now select the first alarmzone
            zoneSelect.SelectedIndex = 0;

            // Add some marker style ValueLabels.  These will be used to
            // mark the Near and Far extents of the DataSeries AlarmZone
            Axis ax = c1Chart1.ChartArea.AxisX;

            ax.AnnoMethod = AnnotationMethodEnum.Mixed;

            ValueLabel vl = ax.ValueLabels.AddNewLabel();

            vl.Appearance    = ValueLabelAppearanceEnum.ArrowMarker;
            vl.Text          = "M1";
            vl.Color         = Color.FromArgb(100, Color.Red);
            vl.GridLine      = true;
            vl.Moveable      = true;
            vl.NumericValue  = az.NearExtent;
            vl.ValueChanged += new EventHandler(ValueLabelChangedHandler);            //!!VBSubst AddHandler vl.ValueChanged, AddressOf ValueLabelChangedHandler
            vl.MarkerSize    = 13;

            vl               = ax.ValueLabels.AddNewLabel();
            vl.Appearance    = ValueLabelAppearanceEnum.ArrowMarker;
            vl.Text          = "M2";
            vl.Color         = Color.FromArgb(100, Color.Red);
            vl.GridLine      = true;
            vl.Moveable      = true;
            vl.NumericValue  = az.FarExtent;
            vl.ValueChanged += new EventHandler(ValueLabelChangedHandler);            //!!VBSubst AddHandler vl.ValueChanged, AddressOf ValueLabelChangedHandler
            vl.MarkerSize    = 13;

            // Call it to get markers and extensions recalculated.
            ValueLabelChangedHandler(null, null);

            // Add some instructions about how to use the markers.
            c1Chart1.Footer.Text = "Drag markers M1 and M2 along the X axis\n" +
                                   "to adjust the extents of the DataSeries sourced AlarmZone";
        }
Пример #24
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;
        }
Пример #25
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.loadRSetting(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             = "Si(炉温)趋势";
            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;
                LegendEnviroment.loadR(gaolu, sjBegin.Value, sjEnd.Value, out siT, out si);
                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;
                LegendEnviroment.loadR(gaolu, toolStrip_Luci1.Text, toolStrip_Luci2.Text, out siLuci, out si);
                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;
            }
        }
Пример #26
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;
            }
        }
Пример #27
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;
            }
        }
Пример #28
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);
        }
Пример #29
0
        private void InitChart()
        {
            try
            {
                //this.colorPanel1.ColorBarValue = colors;
                //Random r = new Random();
                int seriescount = data.Amplitude.Length;

                ChartDataSeriesCollection coll   = c1Chart1.ChartGroups[0].ChartData.SeriesList;
                List <double>             lsttmp = new List <double>();
                #region testdata
                //int i = 0;
                //for (i = 0; i < seriescount; i++)
                //{
                //    lstdata.Add(r.Next(300, 800));
                //}
                NoiseParmBLL NoiseParmbll   = new NoiseParmBLL();
                string       str_DCLen      = NoiseParmbll.GetParm(ConstValue.DCComponentLen); //获取设定的直流分量长度
                int          DCComponentLen = 6;
                if (!string.IsNullOrEmpty(str_DCLen))
                {
                    DCComponentLen = Convert.ToInt32(str_DCLen);
                }

                float min      = DCComponentLen * 2000 / 256;
                float max      = 1000;
                float interval = (max - min) / 4;
                for (int i = 0; i < seriescount; i++)
                {
                    lsttmp = new List <double>();
                    lsttmp.Add(data.Amplitude[i]);
                    lsttmp.Add(1);
                    c1Chart1.ChartGroups[0].ChartData.SeriesList[i].Y.CopyDataIn(lsttmp.ToArray());
                    c1Chart1.ChartGroups[0].ChartData.SeriesList[i].FillStyle.Color1 = GetColor(min, max, data.Frequency[i]);
                }
                #endregion
                while (coll.Count > seriescount)
                {
                    c1Chart1.ChartGroups[0].ChartData.SeriesList.RemoveAt(seriescount);  //将多余的Series移除,总计35个
                }

                colorPanel_static1.SetColorPanel((int)Math.Ceiling(min), (int)Math.Ceiling(min + interval), (int)Math.Ceiling(min + interval * 2),
                                                 (int)Math.Ceiling(min + interval * 3), (int)Math.Ceiling(max)); //set colorpanel mark
                C1.Win.C1Chart.Axis axisX = (C1.Win.C1Chart.Axis)c1Chart1.ChartArea.AxisX;
                if (seriescount > 1)
                {
                    axisX.Max = 0.1 * (30 - seriescount) + 1.71;
                }
                else
                {
                    axisX.Max = 15;
                }

                c1Chart1.ChartArea.AxisY.ValueLabels.Add(Recorder.LeakValue, "");
                c1Chart1.ChartArea.AxisY.ValueLabels[0].Appearance = ValueLabelAppearanceEnum.TriangleMarker;
                c1Chart1.ChartArea.AxisY.ValueLabels[0].GridLine   = false;
                c1Chart1.ChartArea.AxisY.ValueLabels[0].Color      = Color.Red;
                c1Chart1.ChartArea.AxisY.ValueLabels[0].Moveable   = false;
                c1Chart1.ChartArea.AxisY.AnnoMethod = AnnotationMethodEnum.Mixed;

                c1Chart1.ChartArea.AxisY.Max     = 100;
                c1Chart1.ChartArea.AxisY.AutoMax = false;
            }
            catch (Exception ex)
            {
                logger.ErrorException("InitChart", ex);
                XtraMessageBox.Show("加载图表发生错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #30
0
        public void BindSeries(C1Chart c1c, int series, object dataSource, string field, string labels)
        {
            try
            {
                ITypedList il   = (ITypedList)dataSource;
                IList      list = (IList)dataSource;
                if (list == null || il == null)
                {
                    throw new ApplicationException("Datos no válidos en el objeto de origen");
                }

                ChartDataSeriesCollection coll = c1c.ChartGroups[0].ChartData.SeriesList;
                while (series >= coll.Count)
                {
                    coll.AddNewSeries();
                }

                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("Nombre no válido de campo utilizados para Y los valores ({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;
                }

                if (labels != null && labels.Length > 0)
                {
                    pd = pdc[labels];
                    if (pd == null)
                    {
                        throw new ApplicationException(string.Format("Nombre no válido de campo utilizados para los valores de X ({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;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\nMetodo : BindSeries()", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }