示例#1
0
        private void drawcandy(DataTable dt)
        {
            // Create a chart.
            //



            ChartControl chart = chartControl1;//= chart;//= new ChartControl();

            chart.Series.Clear();

            chart.DataSource = dt;
            // Create an empty Bar series and add it to the chart.
            Series series = new Series("月产水量", ViewType.Line);

            chart.Series.Add(series);

            // Generate a data table and bind the series to it.
            series.DataSource = dt;

            // Specify data members to bind the series.
            series.ArgumentScaleType  = ScaleType.DateTime;
            series.ArgumentDataMember = "生产年月YYYYMM";
            series.ValueScaleType     = ScaleType.Numerical;
            series.ValueDataMembers.AddRange(new string[] { "月产水量" });
            ((PointSeriesView)series.View).Color = Color.FromArgb(125, Color.Green);
            // Create an empty Bar series and add it to the chart.
            Series series1 = new Series("月产油量", ViewType.Line);

            chart.Series.Add(series1);

            // Generate a data table and bind the series to it.
            series1.DataSource = dt;

            // Specify data members to bind the series.
            series1.ArgumentScaleType  = ScaleType.DateTime;
            series1.ArgumentDataMember = "生产年月YYYYMM";
            series1.ValueScaleType     = ScaleType.Numerical;
            series1.ValueDataMembers.AddRange(new string[] { "月产油量" });
            ((PointSeriesView)series1.View).Color = Color.FromArgb(125, Color.Red);
            Series series2 = new Series("含水", ViewType.Line);

            chart.Series.Add(series2);

            // Generate a data table and bind the series to it.
            series2.DataSource = dt;

            // Specify data members to bind the series.
            series2.ArgumentScaleType  = ScaleType.DateTime;
            series2.ArgumentDataMember = "生产年月YYYYMM";
            series2.ValueScaleType     = ScaleType.Numerical;
            series2.ValueDataMembers.AddRange(new string[] { "含水" });
            ((PointSeriesView)series2.View).Color = Color.FromArgb(125, Color.Blue);
            // Set some properties to get a nice-looking chart.
            //((SideBySideBarSeriesView)series.View).ColorEach = true;
            ((XYDiagram)chart.Diagram).AxisY.Visibility = DevExpress.Utils.DefaultBoolean.True;
            chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;


            //SecondaryAxisX myAxisX = new SecondaryAxisX("watercutx");
            SecondaryAxisY myAxisY = new SecondaryAxisY("含水率");

            // ((XYDiagram)chartControl1.Diagram).SecondaryAxesX.Add(myAxisX);

            ((XYDiagram)chartControl1.Diagram).SecondaryAxesY.Add(myAxisY);

            // Assign the series2 to the created axes.
            //  ((LineSeriesView)series2.View).AxisX = myAxisX;
            ((LineSeriesView)series2.View).AxisY = myAxisY;

            // Customize the appearance of the secondary axes (optional).


            myAxisY.Title.Text      = "含水率(%)";
            myAxisY.Title.Font      = new Font("Microsoft YaHei", 10);
            myAxisY.Title.Visible   = true;
            myAxisY.Title.TextColor = Color.Blue;
            myAxisY.Label.TextColor = Color.Blue;
            myAxisY.Color           = Color.Blue;
            myAxisY.WholeRange.Auto = false;
            myAxisY.WholeRange.SetMinMaxValues(0, 100);
            myAxisY.VisualRange.Auto = false;
            myAxisY.VisualRange.SetMinMaxValues(0, 100);
            myAxisY.WholeRange.SideMarginsValue = 0;

            chart.CrosshairOptions.ShowArgumentLabels = true;
            chart.CrosshairOptions.ShowArgumentLine   = true;
            chart.CrosshairOptions.ShowValueLabels    = true;
            chart.CrosshairOptions.ShowValueLine      = true;
            chart.CrosshairOptions.ValueLineColor     = Color.DarkBlue;

            chart.CrosshairOptions.ArgumentLineColor   = Color.DarkBlue;
            chart.CrosshairOptions.ShowCrosshairLabels = false;
            //series1.CrosshairLabelPattern = series1.Name + ":{V:F0}";
            //series2.CrosshairLabelPattern = series1.Name + ":{V:F0}";
            // chart.CrosshairOptions.sh = true;

            //series2.CrosshairOptions.ShowArgumentLabels  rosshairOptions.ShowValueLabels
            //  series2.CrosshairOptions.sho  CrosshairOptions.ShowValueLine,
            //this.Controls.Add();

            DevExpress.XtraCharts.Legend legend = chart.Legend;

            // Display the chart control's legend.
            legend.Visibility = DevExpress.Utils.DefaultBoolean.True;

            // Define its margins and alignment relative to the diagram.
            legend.Margins.All = 8;


            // Define the layout of items within the legend.
            legend.Direction           = LegendDirection.TopToBottom;
            legend.EquallySpacedItems  = true;
            legend.HorizontalIndent    = 8;
            legend.VerticalIndent      = 8;
            legend.TextVisible         = true;
            legend.TextOffset          = 8;
            legend.MarkerVisible       = true;
            legend.MarkerSize          = new Size(10, 10);
            legend.Padding.All         = 4;
            legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Left;
            legend.AlignmentVertical   = DevExpress.XtraCharts.LegendAlignmentVertical.Top;

            // Define the limits for the legend to occupy the chart's space.
            legend.MaxHorizontalPercentage = 50;
            legend.MaxVerticalPercentage   = 50;

            // Customize the legend text properties.
            legend.Antialiasing = false;
            legend.Font         = new Font("Arial", 9, FontStyle.Bold);
            legend.TextColor    = Color.Black;

            XYDiagram diagram = (XYDiagram)chart.Diagram;

            ////diagram.Panes.Clear();
            //diagram.SecondaryAxesY.Clear();
            //diagram.SecondaryAxesX.Clear();

            // Enable the diagram's scrolling.
            diagram.EnableAxisXScrolling = false;
            diagram.EnableAxisYScrolling = false;

            // Customize the appearance of the axes' grid lines.
            diagram.AxisX.GridLines.Visible      = true;
            diagram.AxisX.GridLines.MinorVisible = false;

            diagram.AxisY.GridLines.Visible      = true;
            diagram.AxisY.GridLines.MinorVisible = true;

            //diagram.AxisY.Range.SetInternalMinMaxValues(1, 12);
            // Customize the appearance of the X-axis title.
            diagram.AxisX.Title.Visibility   = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisX.Title.Alignment    = StringAlignment.Center;
            diagram.AxisX.Title.Text         = "生产时间";
            diagram.AxisX.Title.TextColor    = Color.Black;
            diagram.AxisX.Title.Antialiasing = true;
            diagram.AxisX.Title.Font         = new Font("Microsoft YaHei", 10);

            // Customize the appearance of the Y-axis title.
            diagram.AxisY.Title.Visibility   = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Alignment    = StringAlignment.Center;
            diagram.AxisY.Title.Text         = "产量(方)";
            diagram.AxisY.Title.TextColor    = Color.Black;
            diagram.AxisY.Title.Antialiasing = true;
            diagram.AxisY.Title.Font         = new Font("Microsoft YaHei", 10);
        }
示例#2
0
        private void CreateChart()
        {
            try
            {
                chartBTS.Legends.Clear();
                //chartBTS.AppearanceNameSerializable = "Chameleon";
                Series series1 = new Series("BTS", ViewType.Bar);
                chartBTS.AnimationStartMode = DevExpress.XtraCharts.ChartAnimationMode.OnDataChanged;
                DevExpress.XtraCharts.SideBySideBarSeriesView  sideBySideBarSeriesView1  = new DevExpress.XtraCharts.SideBySideBarSeriesView();
                DevExpress.XtraCharts.SideBySideBarSeriesLabel sideBySideBarSeriesLabel1 = new DevExpress.XtraCharts.SideBySideBarSeriesLabel();

                Series series2 = new Series("Target", ViewType.Line);
                DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();

                lineSeriesView1.MarkerVisibility            = DevExpress.Utils.DefaultBoolean.False;
                sideBySideBarSeriesView1.ColorEach          = false;
                sideBySideBarSeriesView1.Color              = System.Drawing.Color.LimeGreen;
                sideBySideBarSeriesView1.FillStyle.FillMode = DevExpress.XtraCharts.FillMode.Solid;
                series1.Label.Font        = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                series1.Label.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
                series1.Label.TextPattern = "{V:#,#.0}" + "%";
                series1.View             = sideBySideBarSeriesView1;
                series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;

                series2.Label.Font        = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                series2.LabelsVisibility  = DevExpress.Utils.DefaultBoolean.False;
                series2.Label.TextPattern = "{V:#,#.0}" + "%";
                lineSeriesView1.Color     = System.Drawing.Color.LimeGreen;
                lineSeriesView1.LineMarkerOptions.Color = System.Drawing.Color.FromArgb(((int)(((byte)(146)))), ((int)(((byte)(208)))), ((int)(((byte)(80)))));
                lineSeriesView1.LineStyle.Thickness     = 4;
                series2.View = lineSeriesView1;

                DataTable dt = SEL_SMT_BTS("C", line, mline, opcd, UC_MONTH.GetValue());

                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        series1.Points.Add(new SeriesPoint(dt.Rows[i]["DAY"].ToString(), dt.Rows[i]["BTS"]));
                        series2.Points.Add(new SeriesPoint(dt.Rows[i]["DAY"].ToString(), dt.Rows[i]["TARGET"]));

                        if (Convert.ToDouble(dt.Rows[i]["BTS"]) < Convert.ToDouble(dt.Rows[i]["TARGET"]) && Convert.ToDouble(dt.Rows[i]["BTS"]) >= Convert.ToDouble(dt.Rows[i]["TARGET"]) - 5)
                        {
                            series1.Points[i].Color = Color.Yellow;
                        }
                        else if (Convert.ToDouble(dt.Rows[i]["BTS"]) < Convert.ToDouble(dt.Rows[i]["TARGET"]) - 5)
                        {
                            series1.Points[i].Color = Color.Red;
                        }
                        else
                        {
                            series1.Points[i].Color = System.Drawing.Color.LimeGreen;
                        }
                    }

                    chartBTS.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series1, series2 };

                    ((XYDiagram)chartBTS.Diagram).AxisX.Label.Font        = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    ((XYDiagram)chartBTS.Diagram).AxisX.Title.TextColor   = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
                    ((XYDiagram)chartBTS.Diagram).AxisY.Label.TextPattern = "{V:#,#}";
                    ((XYDiagram)chartBTS.Diagram).AxisY.Label.Font        = new System.Drawing.Font("Tahoma", 13F);
                    ((XYDiagram)chartBTS.Diagram).AxisY.Title.Font        = new System.Drawing.Font("Calibri", 22F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    ((XYDiagram)chartBTS.Diagram).AxisY.Title.Text        = "BTS (%)";
                    ((XYDiagram)chartBTS.Diagram).AxisY.Title.TextColor   = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));

                    DevExpress.XtraCharts.Legend           legend1           = new DevExpress.XtraCharts.Legend();
                    DevExpress.XtraCharts.CustomLegendItem customLegendItem1 = new DevExpress.XtraCharts.CustomLegendItem();
                    DevExpress.XtraCharts.CustomLegendItem customLegendItem2 = new DevExpress.XtraCharts.CustomLegendItem();
                    DevExpress.XtraCharts.CustomLegendItem customLegendItem3 = new DevExpress.XtraCharts.CustomLegendItem();

                    customLegendItem1.MarkerColor = System.Drawing.Color.LimeGreen;
                    customLegendItem1.Name        = "GREEN";
                    customLegendItem1.Text        = ">=" + dt.Rows[0]["TARGET"].ToString() + "%";
                    customLegendItem2.MarkerColor = System.Drawing.Color.Yellow;
                    customLegendItem2.Name        = "YELLOW";
                    customLegendItem2.Text        = ">=" + (Convert.ToDouble(dt.Rows[0]["TARGET"].ToString()) - 5).ToString() + "% and <" + dt.Rows[0]["TARGET"].ToString() + "%";
                    customLegendItem3.MarkerColor = System.Drawing.Color.Red;
                    customLegendItem3.Name        = "RED";
                    customLegendItem3.Text        = "<" + (Convert.ToDouble(dt.Rows[0]["TARGET"].ToString()) - 5).ToString() + "%";

                    legend1.CustomItems.AddRange(new DevExpress.XtraCharts.CustomLegendItem[] {
                        customLegendItem1,
                        customLegendItem2,
                        customLegendItem3
                    });
                    legend1.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Right;
                    legend1.AlignmentVertical   = DevExpress.XtraCharts.LegendAlignmentVertical.TopOutside;
                    legend1.Direction           = DevExpress.XtraCharts.LegendDirection.LeftToRight;
                    legend1.Font = new System.Drawing.Font("Tahoma", 12F);
                    legend1.Name = "Legend1";
                    this.chartBTS.Legends.AddRange(new DevExpress.XtraCharts.Legend[] { legend1 });
                }
            }
            catch (Exception EX)
            {
            }
        }
示例#3
0
        private void adddraw(List <string> wellfullname, List <double> welllocationx, List <double> welllocationy)
        {
            listDataSource = list(wellfullname, welllocationx, welllocationy);
            //画图数据源
            ChartControl myChart = chartControl1;

            myChart.Series.Clear();
            myChart.DataSource = listDataSource;
            myChart.CrosshairOptions.ShowCrosshairLabels = false;
            myChart.CrosshairOptions.ShowArgumentLine    = false;
            myChart.ToolTipEnabled           = DevExpress.Utils.DefaultBoolean.False;
            myChart.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False;


            // Create a series, and add it to the chart.
            DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series("生产数据", ViewType.Point);
            myChart.Series.Add(series1);
            //series1.Label = "A";
            // Set the scale type for the series' arguments and values.
            series1.ArgumentScaleType = ScaleType.Numerical;
            series1.ValueScaleType    = ScaleType.Numerical;

            //series1.Label.Shadow = true;
            // Adjust the series data members.
            series1.ArgumentDataMember = "Xaxis";
            //series1.LegendText = "Name";
            series1.ValueDataMembers.AddRange(new string[] { "Yaxis" });
            //myChart.DateTimeScaleOptions.MeasureUnit = Month
            // Access the view-type-specific options of the series.
            //((PointSeriesView)series1.View).PointMarkerOptions.BorderColor= Color.Navy;
            ((PointSeriesView)series1.View).Color = Color.FromArgb(125, Color.Black);
            //series1.LegendTextPattern = "{A}";
            series1.Label.LineVisibility         = DevExpress.Utils.DefaultBoolean.False;
            series1.LabelsVisibility             = DevExpress.Utils.DefaultBoolean.True;
            series1.Label.ResolveOverlappingMode = ResolveOverlappingMode.JustifyAllAroundPoint;
            //series1.Label.ResolveOverlappingMode = ResolveOverlappingMode.JustifyAllAroundPoint;
            DevExpress.XtraCharts.Legend legend = myChart.Legend;

            // Display the chart control's legend.
            legend.Visible = true;

            // Define its margins and alignment relative to the diagram.
            legend.Margins.All = 8;


            // Define the layout of items within the legend.
            legend.Direction           = LegendDirection.TopToBottom;
            legend.EquallySpacedItems  = true;
            legend.HorizontalIndent    = 8;
            legend.VerticalIndent      = 8;
            legend.TextVisible         = true;
            legend.TextOffset          = 8;
            legend.MarkerVisible       = true;
            legend.MarkerSize          = new Size(10, 10);
            legend.Padding.All         = 4;
            legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Left;
            legend.AlignmentVertical   = DevExpress.XtraCharts.LegendAlignmentVertical.Bottom;

            // Define the limits for the legend to occupy the chart's space.
            legend.MaxHorizontalPercentage = 50;
            legend.MaxVerticalPercentage   = 50;

            // Customize the legend text properties.
            legend.Antialiasing = false;
            legend.Font         = new Font("Arial", 9, FontStyle.Bold);
            legend.TextColor    = Color.Black;

            XYDiagram diagram = (XYDiagram)myChart.Diagram;

            diagram.EnableAxisXScrolling = true;
            diagram.EnableAxisYScrolling = true;
            diagram.EnableAxisXZooming   = true;
            diagram.EnableAxisYZooming   = true;

            // Customize the appearance of the axes' grid lines.
            diagram.AxisX.GridLines.Visible      = true;
            diagram.AxisX.GridLines.MinorVisible = false;

            diagram.AxisY.GridLines.Visible      = true;
            diagram.AxisY.GridLines.MinorVisible = true;

            //diagram.AxisY.Range.SetInternalMinMaxValues(1, 12);
            // Customize the appearance of the X-axis title.
            diagram.AxisX.Title.Visible      = true;
            diagram.AxisX.Title.Alignment    = StringAlignment.Center;
            diagram.AxisX.Title.Text         = "X轴";
            diagram.AxisX.Title.TextColor    = Color.Black;
            diagram.AxisX.Title.Antialiasing = true;
            diagram.AxisX.Title.Font         = new Font("Microsoft YaHei", 10);

            // Customize the appearance of the Y-axis title.
            diagram.AxisY.Title.Visible      = true;
            diagram.AxisY.Title.Alignment    = StringAlignment.Center;
            diagram.AxisY.Title.Text         = "Y轴";
            diagram.AxisY.Title.TextColor    = Color.Black;
            diagram.AxisY.Title.Antialiasing = true;
            diagram.AxisY.Title.Font         = new Font("Microsoft YaHei", 10);

            diagram.AxisY.WholeRange.AutoSideMargins = true;
        }