Beispiel #1
0
 public void UpdateCompleteGraph()
 {
     using (Graphics g = m_Graph.CreateGraphics())
     {
         m_Graph.MasterPane.SetLayout(g, PaneLayout.SquareRowPreferred);
         m_Graph.MasterPane.DoLayout(g);
     }
     m_Graph.AxisChange();
     m_Graph.Invalidate();
 }
Beispiel #2
0
        public ZedGraphDataLoader(ZedGraphControl chart)
        {
            chart1 = chart;
            pane   = chart1.GraphPane;
            pane.Chart.Border.IsVisible = false;

            // set scale
            pane.YAxis.Scale.MinGrace = 0;
            pane.YAxis.Scale.MaxGrace = 0;
            pane.XAxis.Scale.MinGrace = 0;
            pane.XAxis.Scale.MaxGrace = 0;
            pane.XAxis.Scale.MagAuto  = false;
            pane.YAxis.Scale.MagAuto  = false;

            SetPaneVisible(false);

            chart1.ZoomEvent      += chart1_ZoomEvent;
            chart1.MouseDownEvent += chart1_MouseDownEvent;
            chart1.MouseUpEvent   += chart1_MouseUpEvent;

            using (Graphics g = chart1.CreateGraphics())
            {
                _dpiFactor = Convert.ToSingle(g.DpiX / 96.0);
            }

            // set fonts
            ApplyFontDefaults();
        }
Beispiel #3
0
        public SIPTransportMetricsGraphAgent(string localGraphsDir, string metricsFileName, string metricsFileCopy)
        {
            m_localGraphsDir = localGraphsDir;
            //m_serverFilename = serverFileName;
            m_metricsFileName     = metricsFileName;
            m_metricsFileCopyName = metricsFileCopy;

            m_graphControl = new ZedGraphControl();
            m_g            = m_graphControl.CreateGraphics();

            m_methodColours.Add(SIPMethodsEnum.REGISTER, Color.Red);
            m_methodColours.Add(SIPMethodsEnum.INVITE, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.BYE, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.CANCEL, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.ACK, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.OPTIONS, Color.Purple);
            m_methodColours.Add(SIPMethodsEnum.UNKNOWN, Color.Orange);
            m_methodColours.Add(SIPMethodsEnum.SUBSCRIBE, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.PING, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.INFO, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.PUBLISH, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.NOTIFY, Color.Aquamarine);

            m_topTalkerColours[0] = Color.FromArgb(252, 2, 4);      // Red.
            m_topTalkerColours[1] = Color.FromArgb(4, 154, 252);    // Navy'ish.
            m_topTalkerColours[2] = Color.FromArgb(4, 154, 156);    // Green'ish.
            m_topTalkerColours[3] = Color.FromArgb(4, 254, 252);    // Aqua.
            m_topTalkerColours[4] = Color.FromArgb(4, 178, 4);      // Flat Green.
            m_topTalkerColours[5] = Color.FromArgb(252, 174, 172);  // Pink'ish.
            m_topTalkerColours[6] = Color.FromArgb(4, 2, 252);      // Blue.
            m_topTalkerColours[7] = Color.FromArgb(252, 202, 4);    // Orange-Yellow.
            m_topTalkerColours[8] = Color.FromArgb(180, 2, 180);    // Purple.
            m_topTalkerColours[9] = Color.Black;
        }
Beispiel #4
0
 public override bool HandleMouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
 {
     using (var g = sender.CreateGraphics())
     {
         object nearestObject;
         int    index;
         if (FindNearestObject(e.Location, g, out nearestObject, out index))
         {
             var lineItem = nearestObject as LineItem;
             if (lineItem != null)
             {
                 var objectList = lineItem.Tag as List <object>;
                 if (objectList != null)
                 {
                     _selectedData = (AreaCVGraphData.CVData)objectList[index];
                     sender.Cursor = Cursors.Hand;
                     return(true);
                 }
             }
         }
         _selectedData = null;
         sender.Cursor = Cursors.Cross;
         return(base.HandleMouseMoveEvent(sender, e));
     }
 }
Beispiel #5
0
        public bool zedGraph_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            if (isMousePressed)
            {
                // Координаты, которые переданы в событие
                PointF    eventPoint = new PointF(e.X, e.Y);
                GraphPane pane       = new GraphPane();
                object    nearestObj = new object();
                int       index      = 0;

                using (Graphics g = sender.CreateGraphics())
                {
                    MP.FindNearestPaneObject(eventPoint, g, out pane, out nearestObj, out index);
                }

                // Пересчитать координаты из системы координат, связанной с контролом zedGraph
                // в систему координат, связанную с графиком
                double newX;
                double newY;
                double oldX;
                double oldY;

                pane.ReverseTransform(new PointF(posX, posY), out oldX, out oldY);
                pane.ReverseTransform(new PointF(e.X, e.Y), out newX, out newY);
                MoveImage(oldX, oldY, newX, newY);
            }
            return(false);
        }
 public void MasterPaneLayout()
 {
     using (Graphics graphics = graph.CreateGraphics())
     {
         masterPane.SetLayout(graphics, PaneLayout.SquareColPreferred);
         masterPane.AxisChange(graphics);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Find which bar (if any) contains the coordinates of a mouse event.
        /// </summary>
        /// <param name="e">Mouse event arguments.</param>
        /// <returns>Index of bar or -1 if none contained by mouse point.</returns>
        private int FindBarIndex(MouseEventArgs e)
        {
            object nearestObject;
            int    index;

            _graphControl.GraphPane.FindNearestObject(new PointF(e.X, e.Y), _graphControl.CreateGraphics(), out nearestObject, out index);
            return((nearestObject != null && nearestObject.GetType() == typeof(BarItem)) ? index : -1);
        }
 /// <summary>
 /// Redraw the chart
 /// </summary>
 /// <param name="zedChart"></param>
 private void RefreshChart(ref ZedGraphControl chart)
 {
     using (Graphics g = chart.CreateGraphics())
     {
         chart.MasterPane.SetLayout(g, PaneLayout.SingleColumn);
         chart.AxisChange();
     }
     chart.Invalidate();
 }
Beispiel #9
0
        private void LoadPeaks(ZedGraphControl zgcScan, List <ZedGraphSmallMoleculeFilePeak> zgcPeaks, string[] fileNames, Color color)
        {
            var sigPeaks           = from p in significantPeaks select p.Peak;
            List <FileData2> datas = FileData2.ReadFiles(fileNames, sigPeaks);

            SmallMoleculeZedGraphUtils.LoadPeaks(zgcScan, zgcPeaks, datas, color);

            zgcScan.MasterPane.SetLayout(zgcScan.CreateGraphics(), PaneLayout.SquareRowPreferred);

            zgcScan.AxisChange();
        }
Beispiel #10
0
        public override bool HandleMouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            using (var g = sender.CreateGraphics())
            {
                if (FindNearestObject(e.Location, g, out var nearestObject, out var index) && nearestObject is BarItem)
                {
                    PopulateTooltip(index);
                    ToolTip?.Draw(index, e.Location);

                    sender.Cursor = Cursors.Hand;
                    return(true);
                }
Beispiel #11
0
        public void DrawGraph(ref ZedGraphControl control)
        {
            zedGraph = control;
            ConfigPane();
            DrawPane();
            DrawValues();

            zedGraph.GraphPane           = myPane;
            zedGraph.PointValueEvent    += new ZedGraphControl.PointValueHandler(MyPointValueHandler);
            zedGraph.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(MyContextMenuBuilder);
            zedGraph.GraphPane.ReSize(zedGraph.CreateGraphics(), zedGraph.MasterPane.Rect);

            zedGraph.AxisChange();
        }
Beispiel #12
0
 private void DynamicButton_Click(object sender, EventArgs e)
 {
     if (!button.Checked)
     {
         zgc.GraphPane.CurveList.Add(curve);
         zgc.GraphPane.CurveList.Draw(zgc.CreateGraphics(), zgc.GraphPane, 1.0f);
     }
     else
     {
         zgc.GraphPane.CurveList.Remove(curve);
     }
     GraphProcessing.UpdateGraph(zgc);
     button.Checked = !button.Checked;
 }
        public static string SaveDataToPng(double[] data, int id)
        {
            ZedGraphControl zedGraphControl1 = new ZedGraphControl();
            GraphPane       paneA            = new GraphPane();
            PointPairList   listA            = new PointPairList();

            paneA.Title.IsVisible = false;
            paneA.XAxis.IsVisible = false;
            paneA.YAxis.IsVisible = false;
            if (id != 0)
            {
                paneA.XAxis.Scale.Max = 300000;
            }
            else
            {
                paneA.XAxis.Scale.Max = 550000;
            }

            for (int i = 0; i < data.Length; i++)
            {
                listA.Add(i, data[i]);
            }
            LineItem myCurveA = paneA.AddCurve("", listA, Color.Blue, SymbolType.None);

            using (Graphics g = zedGraphControl1.CreateGraphics())
            {
                paneA.AxisChange(g);
                paneA.ReSize(g, new RectangleF(0, 0, 1800, 300));
            }

            string url      = @"D:\\PipeWeb\\AdImages\\";
            string filename = DateTime.Now.ToString("yyyy-MM-dd") + "--" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() + "--" + id.ToString();//以日期时间命名,避免文件名重复
            string strName  = url + filename + ".png";

            if (!Directory.Exists(url))         //如果不存在就创建file文件夹                 
            {
                Directory.CreateDirectory(url); //创建该文件夹 
                paneA.GetImage().Save(strName, ImageFormat.Png);
            }
            else
            {
                paneA.GetImage().Save(strName, ImageFormat.Png);
            }
            zedGraphControl1.Dispose();

            return(strName);
        }
Beispiel #14
0
        private XAxis GetNearestXAxis(ZedGraphControl sender, MouseEventArgs mouseEventArgs)
        {
            using (Graphics g = sender.CreateGraphics())
            {
                object nearestObject;
                int    index;
                if (FindNearestObject(new PointF(mouseEventArgs.X, mouseEventArgs.Y), g, out nearestObject, out index))
                {
                    var axis = nearestObject as XAxis;
                    if (axis != null)
                    {
                        return(axis);
                    }
                }
            }

            return(null);
        }
Beispiel #15
0
        public bool OnGraphMouseDown(ZedGraphControl sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                m_RightClickPosition = e.Location;
            }

            object selectedObject;

            using (Graphics g = sender.CreateGraphics())
            {
                FindNearestObject(e.Location, g, out selectedObject, out m_SelectedIndex);
            }

            SetSelectedObject(selectedObject);

            return(false);
        }
        private static void ZoomAxis(ZedGraphControl graphControl, Func <GraphPane, Scale> getScale, double min, double max)
        {
            var pane  = graphControl.GraphPane;
            var scale = getScale(pane);

            scale.Min = min;
            scale.Max = max;
            new ZoomState(pane, ZoomState.StateType.Zoom).ApplyState(pane);

            using (var graphics = graphControl.CreateGraphics())
            {
                foreach (MSGraphPane graphPane in graphControl.MasterPane.PaneList.OfType <MSGraphPane>())
                {
                    graphPane.SetScale(graphics);
                }
            }
            graphControl.Refresh();
        }
Beispiel #17
0
        public void ConfigGraphPane(ZedGraphControl zgc, Form f, PaneLayout pl, List <ChartInfo> chInfo)
        {
            MasterPane master = zgc.MasterPane;

            master.PaneList.Clear();
            master.Title.IsVisible = true;
            foreach (ChartInfo ci in chInfo)
            {
                var pane = new GraphPane();
                master.PaneList.Add(pane);
                ConfigGraphPane(pane, ci.Title, ci.XAxisTitle, ci.YAxisTitle);
            }
            using (Graphics g = zgc.CreateGraphics())
            {
                master.SetLayout(g, pl);
                master.AxisChange(g);
            }
            zgc.AxisChange();
        }
Beispiel #18
0
 private void zedGraph_MouseMove(object sender, MouseEventArgs e)
 {
     using (Graphics g = zedGraph.CreateGraphics())
     {
         if (zedGraph.MasterPane.FindNearestPaneObject(new Point(e.X, e.Y), g, out tmpPane, out nearestObj, out ipt))
         {
             if (nearestObj is BarItem && ipt >= 0)
             {
                 //zedGraph.Cursor = Cursors.Hand;
                 inBar = true;
             }
             else
             {
                 //zedGraph.Cursor = Cursors.Default;
                 inBar = false;
             }
         }
     }
 }
Beispiel #19
0
        private void InitializeZedGraph()
        {
            this.ZedGraphControl.IsAntiAlias        = true;
            this.ZedGraphControl.IsEnableVPan       = false;
            this.ZedGraphControl.IsEnableVZoom      = false;
            this.ZedGraphControl.IsSynchronizeXAxes = true;

            this.ZedGraphControl.MasterPane.Add(this.mCandleStickPane);
            this.ZedGraphControl.MasterPane.Add(this.mMacdPane);
            this.ZedGraphControl.MasterPane.Add(this.mStochasticPane);
            this.ZedGraphControl.MasterPane.Fill = new Fill(this.BgColor);

            using (Graphics g = ZedGraphControl.CreateGraphics())
            {
                this.ZedGraphControl.MasterPane.SetLayout(g, true, new int[] { 1, 1, 1 }, new float[] { 6f, 2f, 2f });
                //this.ZedGraphControl.MasterPane.SetLayout( g, PaneLayout.SingleColumn );
                this.ZedGraphControl.MasterPane.InnerPaneGap = 3f;
                this.ZedGraphControl.MasterPane.ReSize(g, new RectangleF(0, 0, this.ZedGraphControl.Width, this.ZedGraphControl.Height));
            }
        }
 public override bool HandleMouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
 {
     using (var g = sender.CreateGraphics())
     {
         object nearestObject;
         int    index;
         if (FindNearestObject(e.Location, g, out nearestObject, out index) && nearestObject is BarItem)
         {
             _selectedData = (CVData)((BarItem)nearestObject).Points[index].Tag;
             sender.Cursor = Cursors.Hand;
             return(true);
         }
         else
         {
             _selectedData = null;
             sender.Cursor = Cursors.Cross;
             return(base.HandleMouseMoveEvent(sender, e));
         }
     }
 }
Beispiel #21
0
        static public Metafile GetMetafile(bool copylocal, bool masterpane, ZedGraphControl zg, PointF MousePos)
        {
            try
            {
                Graphics g        = zg.CreateGraphics();
                IntPtr   hdc      = g.GetHdc();
                Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly);
                g.ReleaseHdc(hdc);
                g.Dispose();

                Graphics gMeta = Graphics.FromImage(metaFile);

                if (masterpane == true)
                {
                    if (copylocal)
                    {
                        zg.MasterPane.FindPane(MousePos).Draw(gMeta);
                    }
                    else
                    {
                        zg.MasterPane.Draw(gMeta);
                    }
                }
                else
                {
                    zg.GraphPane.Draw(gMeta);
                }

                gMeta.Dispose();

                return(metaFile);
            }
            catch
            {
                MessageBox.Show("Could not capture image. Please place the cursor over a graph.");
                return(null);
            }
        }
        public MasterPaneWithSplitterDemo() : base("MasterPane With Splitter",
                                                   "MasterPane With Splitter Sample", DemoType.Financial)
        {
            var myMaster = base.MasterPane;

            // Remove the default GraphPane that comes with ZedGraphControl
            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "ZedGraph MasterPane With Splitter Example";
            myMaster.Title.IsVisible = true;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Enable the masterpane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;

            // Initialize a color and symbol type rotator
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            const int TotPanes = 3;

            // Create some new GraphPanes
            for (int j = 0; j < TotPanes; j++)
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                                 "Case #" + (j + 1).ToString(),
                                                 "Time, Days",
                                                 "Rate, m/s");

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    double x = (double)i + 5;
                    double y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                // Add a curve to the Graph, use the next sequential color and symbol
                LineItem myCurve = myPane.AddCurve("Type " + j.ToString(),
                                                   list, rotator.NextColor, rotator.NextSymbol);
                // Fill the symbols with white to make them opaque
                myCurve.Symbol.Fill = new Fill(Color.White);

                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);

                if (j == TotPanes - 1)
                {
                    break;
                }

                var splitter = new SplitterPane(false);
                myMaster.Add(splitter);
            }

            using (var g = ZedGraphControl.CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.SingleColumn);
                myMaster.AxisChange(g);
            }
        }
Beispiel #23
0
        private void initializeGraphControl(ZedGraphControl zedGraphControl)
        {
            zedGraphControl.MasterPane.PaneList.Clear();
            zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), 1, (int)IonSeries.Count + 1);
            zedGraphControl.MasterPane.InnerPaneGap     = 0;
            zedGraphControl.MasterPane.Border.IsVisible = true;
            zedGraphControl.IsEnableHPan        = false;
            zedGraphControl.IsEnableHZoom       = false;
            zedGraphControl.IsSynchronizeYAxes  = true;
            zedGraphControl.IsZoomOnMouseCenter = true;

            var axisPane = new GraphPane();

            axisPane.Legend.IsVisible          = false;
            axisPane.IsFontsScaled             = false;
            axisPane.XAxis.IsVisible           = false;
            axisPane.YAxis.Scale.Min           = 0;
            axisPane.YAxis.Scale.Max           = 100;
            axisPane.YAxis.Title.Text          = zedGraphControl.Text;
            axisPane.YAxis.Title.Gap           = 0.05f;
            axisPane.YAxis.MajorTic.IsOpposite = false;
            axisPane.YAxis.MinorTic.IsOpposite = false;
            axisPane.Chart.Border.IsVisible    = false;
            axisPane.Border.IsVisible          = false;
            axisPane.Margin.Left  = 1;
            axisPane.Margin.Right = 0;
            axisPane.Title.Text   = "Series:";
            zedGraphControl.MasterPane.Add(axisPane);

            var csr = new ColorSymbolRotator();

            for (int i = 0; i < (int)IonSeries.Count; ++i)
            {
                var graphPane = new GraphPane();
                graphPane.Title.Text             = IonSeriesLabels[i];
                graphPane.Legend.IsVisible       = false;
                graphPane.IsFontsScaled          = false;
                graphPane.Chart.Border.IsVisible = false;
                graphPane.Border.IsVisible       = false;
                graphPane.XAxis.Scale.Min        = -1;
                graphPane.XAxis.Scale.Max        = 1;
                graphPane.XAxis.IsVisible        = false;
                graphPane.YAxis.Scale.Min        = 0;
                graphPane.YAxis.Scale.Max        = 100;
                graphPane.YAxis.IsVisible        = false;
                zedGraphControl.MasterPane.Add(graphPane);

                graphPane.BarSettings.Type = BarType.Overlay;
                graphPane.BarSettings.ClusterScaleWidth = 1;

                var mean = graphPane.AddCurve(IonSeriesLabels[i],
                                              new PointPairList(),
                                              Color.Black,
                                              SymbolType.Circle);
                mean.Line.IsVisible          = false;
                mean.Symbol.Border.IsVisible = false;
                mean.Symbol.Fill.Type        = FillType.Solid;

                var errorBar = graphPane.AddErrorBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                errorBar.Bar.IsVisible           = true;
                errorBar.Bar.PenWidth            = .1f;
                errorBar.Bar.Symbol.IsVisible    = true;
                errorBar.Bar.Symbol.Type         = SymbolType.HDash;
                errorBar.Bar.Symbol.Border.Width = .1f;
                errorBar.Bar.Symbol.Size         = 4;

                var hiLowBar = graphPane.AddHiLowBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                hiLowBar.Bar.Fill.Type = FillType.None;

                var scatter = graphPane.AddCurve(IonSeriesLabels[i],
                                                 new PointPairList(),
                                                 csr.NextColor,
                                                 SymbolType.Circle);
                scatter.Line.IsVisible          = false;
                scatter.Symbol.IsAntiAlias      = true;
                scatter.Symbol.Border.IsVisible = false;
                scatter.Symbol.Fill.Type        = FillType.Solid;
                scatter.Symbol.Size             = 3f;
            }

            zedGraphControl.MasterPane.AxisChange();
            zedGraphControl.Refresh();
        }
Beispiel #24
0
        public static void GraphPCF(int Width, int Height, ZedGraphControl zedGraphControl1, Matrix PCF, Matrix PACF, bool F*g = true)
        {
            MasterPane masterpane = zedGraphControl1.MasterPane;

            masterpane.PaneList.Clear();
            zedGraphControl1.Visible            = true;
            zedGraphControl1.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl1.IsEnableSelection  = true;
            zedGraphControl1.BorderStyle        = System.Windows.Forms.BorderStyle.None;

            zedGraphControl1.BorderStyle = System.Windows.Forms.BorderStyle.None;
            GraphPane graphpane  = new GraphPane(); //ACF图
            GraphPane graphpane1 = new GraphPane(); //PACF图

            if (!F*g)
            {
                zedGraphControl1.Location = new Point((int)(0.008116 * Width), 0);
                zedGraphControl1.Size     = new Size((int)(0.39772 * Width), (int)(0.84782 * Height));
                graphpane.Rect            = new RectangleF((int)(0.01217 * Width), (int)(0.01672 * Height), (int)(0.34090 * Width), (int)(0.41806 * Height)); //设置分图的大小和位置900, 300
                graphpane.Chart.Rect      = new RectangleF((int)(0.01217 * Width) + 60, (int)(0.10033 * Height), (int)(0.25974 * Width), (int)(0.41806 * Height) - 45 - (int)(0.10033 * Height));
                graphpane1.Rect           = new RectangleF((int)(0.01217 * Width), (int)(0.41806 * Height), (int)(0.34090 * Width), (int)(0.41806 * Height)); //设置分图的大小和位置
                graphpane1.Chart.Rect     = new RectangleF((int)(0.01217 * Width) + 60, (int)(0.43478 * Height), (int)(0.25974 * Width), (int)(0.23411 * Height));
            }
            else
            {
                zedGraphControl1.Location = new Point(10, 0);
                zedGraphControl1.Size     = new Size(490, 507);

                graphpane.Rect        = new RectangleF(15, 10, 420, 250);  //设置分图的大小和位置900, 300
                graphpane.Chart.Rect  = new RectangleF(95, 60, 320, 140);
                graphpane1.Rect       = new RectangleF(15, 250, 420, 250); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF(95, 260, 320, 140);
            }
            graphpane.XAxis.Scale.Max  = PCF.Columns;
            graphpane1.XAxis.Scale.Max = PACF.Columns;
            SetGraphics(graphpane);
            SetGraphics(graphpane1);
            graphpane1.YAxis.MajorGrid.IsVisible = false;
            double[] ACF_x  = new double[PCF.Columns];
            double[] ACF_y  = new double[PCF.Columns];
            double[] PACF_x = new double[PACF.Columns];
            double[] PACF_y = new double[PACF.Columns];
            for (int i = 0; i < PCF.Columns; i++)
            {
                ACF_x[i]  = i + 1;
                PACF_x[i] = i + 1;
                ACF_y[i]  = PCF[0, i];
                PACF_y[i] = PACF[0, i];
            }
            BarItem bar1 = graphpane.AddBar("PCF", ACF_x, ACF_y, Color.Blue);

            graphpane.XAxis.Title.Text = "时间延迟";
            graphpane.YAxis.Title.Text = "PCF";
            bar1.Label.IsVisible       = false;
            BarItem bar2 = graphpane1.AddBar("PACF", PACF_x, PACF_y, Color.Blue);

            graphpane.YAxis.MajorGrid.IsVisible = false;
            graphpane1.XAxis.Title.Text         = "时间延迟";
            graphpane1.YAxis.Title.Text         = "PACF";
            bar2.Label.IsVisible = false;

            masterpane.Add(graphpane);
            masterpane.Add(graphpane1);
            Graphics gd = zedGraphControl1.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl1.Refresh();
        }
Beispiel #25
0
        public static void GraphDataSource(int Width, int Height, ZedGraphControl zedGraphControl5, double[,] DataSource, string PointNaem, DataGridView dataGridView4 = null)
        {
            zedGraphControl5.BorderStyle = System.Windows.Forms.BorderStyle.None;
            MasterPane masterpane = zedGraphControl5.MasterPane;//获取zedGraphControl1的面板

            //去掉面板中所有的子面板,默认会有一个面板在里面,清除默认面板
            masterpane.PaneList.Clear();
            int Days = DataSource.GetLength(0);

            zedGraphControl5.Visible            = true;
            zedGraphControl5.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl5.IsEnableSelection  = true;
            //创建一个面板
            GraphPane graphpane = new GraphPane(); //拟合图

            graphpane.XAxis.Scale.Max = Days;      //设置最大刻度                                           //设置公共信息
            SetGraphics(graphpane);
            graphpane.YAxis.MajorGrid.IsZeroLine = false;
            //创建点序列
            PointPairList list = new PointPairList();//创建点的集合

            if (dataGridView4 != null)
            {
                dataGridView4.RowHeadersVisible = false;//隐藏行头
                dataGridView4.Columns.Add("col1", "期数");
                dataGridView4.Columns.Add("col2", "观测值(mm)");
                foreach (DataGridViewColumn item in dataGridView4.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }
                dataGridView4.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView4.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView4.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView4.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            double[] y = new double[Days];
            double[] x = new double[Days];
            for (int i = 0; i < Days; i++)
            {
                x[i] = i + 1;
                y[i] = DataSource[i, 0];
                if (dataGridView4 != null)
                {
                    dataGridView4.Rows.Add();
                    dataGridView4[0, i].Value = "第" + (1 + i).ToString() + "期";
                    dataGridView4[1, i].Value = Math.Round(y[i], 2);
                }
            }



            zedGraphControl5.Size = new Size((int)(0.96740 * Width), (int)(0.59834 * Height));
            graphpane.Rect        = new RectangleF((int)(0.015778 * Width), (int)(0.04126 * Height), (int)(0.94637 * Width), (int)(0.55020 * Height));//设置分图的大小和位置900, 300
            graphpane.Chart.Rect  = new RectangleF((int)(0.015778 * Width) + 55, (int)(0.11004 * Height), (int)(0.78864 * Width), (int)(0.55020 * Height) - 40 - (int)(0.11004 * Height));


            graphpane.XAxis.Title.Text            = "期数";
            graphpane.XAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Title.FontSpec.Size   = 15;
            graphpane.XAxis.Title.FontSpec.IsBold = false;
            graphpane.XAxis.Title.IsVisible       = true;

            graphpane.YAxis.Title.Text            = "位移量/mm";
            graphpane.YAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Scale.IsVisible       = true;
            graphpane.XAxis.Scale.MajorStep       = x.Length / graphpane.Rect.Width * 60;
            graphpane.YAxis.Title.FontSpec.Size   = 15;
            graphpane.YAxis.Title.FontSpec.IsBold = false;
            graphpane.Legend.Position             = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible     = false;
            graphpane.Legend.FontSpec.Family      = "Arial";
            graphpane.Legend.FontSpec.Size        = 15;
            graphpane.Legend.FontSpec.IsBold      = false;
            graphpane.Legend.IsVisible            = false;
            LineItem myline = graphpane.AddCurve("观测值", null, y, Color.DeepPink, SymbolType.None);

            myline.Line.Width = 1.5F;//线宽

            float width = graphpane.Chart.Rect.Width;
            float heigh = graphpane.Chart.Rect.Height;

            TextObj text = new TextObj(PointNaem, 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                 //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;    //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            masterpane.Add(graphpane);

            Graphics gd = zedGraphControl5.CreateGraphics();

            masterpane.AxisChange(gd);

            zedGraphControl5.Refresh();
        }
Beispiel #26
0
        public static void GraphPreY(int Width, int Height, ZedGraphControl zedGraphControl2, Matrix _PreY, Matrix PreEoror, Matrix PreYSource, int DeformationDays, string PointName, DataGridView dataGridView2 = null, int MulStep = 1, bool F*g = true)
        {
            MasterPane masterpane = zedGraphControl2.MasterPane;

            masterpane.PaneList.Clear();
            if (F*g)
            {
                zedGraphControl2.Visible = true;
            }
            else
            {
                zedGraphControl2.Visible = false;
            }

            zedGraphControl2.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl2.IsEnableSelection  = true;
            zedGraphControl2.BorderStyle        = System.Windows.Forms.BorderStyle.None;

            int       PreDays    = _PreY.Rows;
            GraphPane graphpane  = new GraphPane(); //预测拟合图
            GraphPane graphpane1 = new GraphPane(); //预测残差图

            graphpane.XAxis.Scale.Max = PreDays;
            //设置公共信息
            SetGraphics(graphpane);
            SetGraphics(graphpane1);
            graphpane.YAxis.MajorGrid.IsZeroLine  = false;
            graphpane1.YAxis.MajorGrid.IsZeroLine = false;
            graphpane1.XAxis.Scale.Max            = PreDays;
            graphpane1.YAxis.MajorGrid.IsVisible  = false;


            graphpane.YAxis.Title.Text             = "位移量/mm";
            graphpane.Legend.FontSpec.Family       = "Arial";
            graphpane.YAxis.Title.FontSpec.Size    = 15;
            graphpane.YAxis.Title.FontSpec.IsBold  = false;
            graphpane.Legend.Position              = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible      = false;
            graphpane.Legend.FontSpec.Size         = 15;
            graphpane.YAxis.Title.FontSpec.Family  = "Arial";
            graphpane.Legend.FontSpec.IsBold       = false;
            graphpane.YAxis.Scale.MajorStep        = 2;
            graphpane.Legend.IsShowLegendSymbols   = true;
            graphpane1.YAxis.Title.Text            = "△/mm";
            graphpane1.YAxis.Title.FontSpec.Size   = 15;
            graphpane1.YAxis.Title.FontSpec.IsBold = false;
            graphpane1.YAxis.Title.FontSpec.Family = "Arial";

            graphpane1.XAxis.Title.Text            = "期数";
            graphpane1.XAxis.Title.FontSpec.Family = "Arial";
            graphpane1.XAxis.Title.FontSpec.Size   = 15;
            graphpane1.XAxis.Title.FontSpec.IsBold = false;
            double[] y     = new double[PreDays];
            double[] _y    = new double[PreDays];
            double[] x     = new double[PreDays];
            double[] error = new double[PreDays];
            if (dataGridView2 != null)
            {
                dataGridView2.RowHeadersVisible = false;//隐藏行头
                dataGridView2.Columns.Add("col1", "期数");
                dataGridView2.Columns.Add("col2", "观测值(mm)");
                dataGridView2.Columns.Add("col3", "预测值(mm)");
                dataGridView2.Columns.Add("col4", "残差(mm)");
                foreach (DataGridViewColumn item in dataGridView2.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }

                dataGridView2.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView2.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView2.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            string[] _x = new string[PreDays];
            double   sd = 0.0;

            for (int i = 0; i < PreDays; i++)
            {
                x[i] = DeformationDays + i + MulStep - 1;

                _y[i] = _PreY[i, 0];
                y[i]  = PreYSource[i, 0];

                error[i] = PreEoror[i, 0];
                sd      += Math.Pow(error[i], 2);
                _x[i]    = (DeformationDays + i + 1 + MulStep - 1).ToString();
                //获取曲线的点序列
                if (dataGridView2 != null)
                {
                    dataGridView2.Rows.Add();
                    dataGridView2[0, i].Value = "第" + (DeformationDays + i + 1 + MulStep - 1).ToString() + "期";
                    dataGridView2[1, i].Value = Math.Round(y[i], 2);
                    dataGridView2[2, i].Value = Math.Round(_y[i], 2);
                    dataGridView2[3, i].Value = Math.Round(error[i], 2);
                }
            }
            sd /= PreDays;
            sd  = Math.Sqrt(sd);
            if (!F*g)
            {
                zedGraphControl2.Size = new Size(920 - 120, 480);
                graphpane.Rect        = new RectangleF(15, 30, 900 - 120, 280);  //设置分图的大小和位置
                graphpane.Chart.Rect  = new RectangleF(95, 80, 750 - 120, 200);
                graphpane1.Rect       = new RectangleF(15, 320, 900 - 120, 150); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF(95, 330, 750 - 120, 80);
            }
            else
            {
                zedGraphControl2.Size = new Size((int)(0.94117 * Width), (int)(0.65753 * Height));
                graphpane.Rect        = new RectangleF((int)(0.01764 * Width), (int)(0.04109 * Height), (int)(0.91764 * Width), (int)(0.38356 * Height)); //设置分图的大小和位置900, 300
                graphpane.Chart.Rect  = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.04109 * Height) + 40, (int)(0.74117 * Width), (int)(0.27397 * Height));
                graphpane1.Rect       = new RectangleF((int)(0.01764 * Width), (int)(0.43835 * Height), (int)(0.91764 * Width), (int)(0.20547 * Height)); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.45205 * Height), (int)(0.74117 * Width), (int)(0.27397 * Height) - 100 - (int)(0.01369 * Height));
            }



            graphpane.XAxis.Scale.IsVisible   = false;
            graphpane.Legend.Position         = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible = false;
            graphpane.XAxis.Scale.MajorStep   = x.Length / graphpane.Rect.Width * 60;



            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            double min, max;

            if ((min = Math.Abs(error.Min())) > (max = Math.Abs(error.Max())))
            {
                graphpane1.YAxis.Scale.Max = (int)min + 1;    //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)min - 1;   //设置最大刻度
            }
            else
            {
                graphpane1.YAxis.Scale.Max = (int)max + 1;                 //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)max - 1;                //设置最大刻度
            }
            graphpane1.YAxis.Scale.MajorStep = graphpane1.YAxis.Scale.Max; //设置大刻度步长
            LineItem myline  = graphpane.AddCurve("观测值", null, y, Color.Green, SymbolType.Diamond);
            LineItem myline1 = graphpane.AddCurve("预测值", null, _y, Color.Red, SymbolType.Circle);
            LineItem myline3 = graphpane1.AddCurve("残差", null, error, Color.Red, SymbolType.Circle);

            graphpane1.XAxis.Type             = AxisType.Text;
            graphpane1.XAxis.Scale.TextLabels = _x;
            myline.Symbol.Size = 3.0F;                  //设置节点形状大小
            myline.Symbol.Fill = new Fill(Color.Green); //设置节点填充
            myline.Line.Width  = 1;                     //线宽

            zedGraphControl2.IsShowCursorValues = true;
            myline1.Symbol.Size = 3.0F;                        //设置节点形状大小
            myline1.Symbol.Fill = new Fill(Color.Red);         //设置节点填充
            myline1.Line.Width  = 1;                           //线宽

            myline3.Symbol.Size         = 3.0F;                //设置节点形状大小
            myline3.Symbol.Fill         = new Fill(Color.Red); //设置节点填充
            myline3.Line.Width          = 1;                   //线宽
            graphpane1.Legend.IsVisible = false;

            myline.Symbol.Size  = 5.0F;                             //设置节点形状大小
            myline.Symbol.Fill  = new Fill(Color.Green);            //设置节点填充
            myline.Line.Width   = 1;                                //线宽
            myline1.Symbol.Size = 5.0F;                             //设置节点形状大小
            myline1.Symbol.Fill = new Fill(Color.Red);              //设置节点填充
            myline1.Line.Width  = 1;                                //线宽

            myline3.Symbol.Size              = 5.0F;                //设置节点形状大小
            myline3.Symbol.Fill              = new Fill(Color.Red); //设置节点填充
            myline3.Line.Width               = 1;                   //线宽
            graphpane1.Legend.IsVisible      = false;
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            float   width  = graphpane.Chart.Rect.Width;
            float   heigh  = graphpane.Chart.Rect.Height;
            float   width1 = graphpane1.Chart.Rect.Width;
            float   heigh1 = graphpane1.Chart.Rect.Height;
            TextObj text   = new TextObj(PointName + ":" + MulStep + "步预测", 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                                           //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                                          //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;                              //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            TextObj text1 = new TextObj(PointName, 2 / width1, 2 / heigh1); //定义文本对象

            text1.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text1.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text1.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text1.FontSpec.Border.IsVisible = false;
            text1.FontSpec.FontColor        = Color.Blue;
            text1.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text1);
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            TextObj text2 = new TextObj("RMS=" + Math.Round(sd, 2) + "mm", 2 / width1, (heigh1 - 2) / heigh1); //定义文本对象

            text2.Location.AlignV           = AlignV.Bottom;                                                   //确定文本的x轴为于文本的最下端
            text2.Location.AlignH           = AlignH.Left;                                                     //确定文本的y轴为于文本的最左端
            text2.Location.CoordinateFrame  = CoordType.ChartFraction;                                         //设置文本的坐标系统,原点位于内框的左上角
            text2.FontSpec.Border.IsVisible = false;
            text2.FontSpec.FontColor        = Color.Blue;
            text2.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text2);
            masterpane.Add(graphpane);
            masterpane.Add(graphpane1);
            Graphics gd = zedGraphControl2.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl2.Refresh();
        }
Beispiel #27
0
        ///// <summary>
        /////     设置字体格式
        ///// </summary>
        ///// <param name="doc"></param>
        ///// <param name="table"></param>
        ///// <param name="setText"></param>
        ///// <returns></returns>
        //public XWPFParagraph SetCellText(XWPFDocument doc, XWPFTable table, string setText)
        //{
        //    //table中的文字格式设置
        //    var para = new CT_P();
        //    var pCell = new XWPFParagraph(para, table.Body);
        //    pCell.Alignment = ParagraphAlignment.CENTER; //字体居中
        //    pCell.VerticalAlignment = TextAlignment.CENTER; //字体居中

        //    var r1c1 = pCell.CreateRun();
        //    r1c1.SetText(setText);
        //    r1c1.FontSize = 12;
        //    r1c1.SetFontFamily("华文楷体", FontCharRange.None); //设置雅黑字体

        //    return pCell;
        //}

        ///// <summary>
        /////     设置单元格格式
        ///// </summary>
        ///// <param name="doc">doc对象</param>
        ///// <param name="table">表格对象</param>
        ///// <param name="setText">要填充的文字</param>
        ///// <param name="align">文字对齐方式</param>
        ///// <param name="textPos">rows行的高度</param>
        ///// <returns></returns>
        //public XWPFParagraph SetCellText(XWPFDocument doc, XWPFTable table, string setText, ParagraphAlignment align,
        //    int textPos)
        //{
        //    var para = new CT_P();
        //    var pCell = new XWPFParagraph(para, table.Body);
        //    //pCell.Alignment = ParagraphAlignment.LEFT;//字体
        //    pCell.Alignment = align;

        //    var r1c1 = pCell.CreateRun();
        //    r1c1.SetText(setText);
        //    r1c1.FontSize = 12;
        //    r1c1.SetFontFamily("华文楷体", FontCharRange.None); //设置雅黑字体
        //    r1c1.SetTextPosition(textPos); //设置高度

        //    return pCell;
        //}



        #endregion

        /// <summary>
        /// 绘制拟合图
        /// </summary>
        /// <param name="dataGridView1"></param>
        /// <param name="zedGraphControl4"></param>
        /// <param name="Y"></param>
        /// <param name="FitY"></param>
        /// <param name="order"></param>
        /// <param name="PointNaem"></param>

        public static void GraphFitY(int Width, int Height, ZedGraphControl zedGraphControl4, Matrix Y, Matrix FitY, int order, string PointNaem, DataGridView dataGridView1 = null, bool F*g = true)
        {
            zedGraphControl4.BorderStyle = System.Windows.Forms.BorderStyle.None;
            MasterPane masterpane = zedGraphControl4.MasterPane;//获取zedGraphControl1的面板

            //去掉面板中所有的子面板,默认会有一个面板在里面,清除默认面板
            masterpane.PaneList.Clear();
            int Days = Y.Rows;

            if (F*g)
            {
                zedGraphControl4.Visible = true;
            }
            else
            {
                zedGraphControl4.Visible = false;
            }
            zedGraphControl4.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl4.IsEnableSelection  = true;
            //创建一个面板
            GraphPane graphpane  = new GraphPane(); //拟合图
            GraphPane graphpane1 = new GraphPane(); //残差图

            graphpane.XAxis.Scale.Max = Days;       //设置最大刻度                                           //设置公共信息
            SetGraphics(graphpane);
            SetGraphics(graphpane1);
            graphpane.YAxis.MajorGrid.IsZeroLine  = false;
            graphpane1.YAxis.MajorGrid.IsZeroLine = false;
            //创建点序列
            PointPairList list = new PointPairList();//创建点的集合

            if (dataGridView1 != null)
            {
                dataGridView1.RowHeadersVisible = false;//隐藏行头
                dataGridView1.Columns.Add("col1", "期数");
                dataGridView1.Columns.Add("col2", "观测值(mm)");
                dataGridView1.Columns.Add("col3", "拟合值(mm)");
                dataGridView1.Columns.Add("col4", "残差(mm)");
                foreach (DataGridViewColumn item in dataGridView1.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }
                dataGridView1.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView1.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            double[] y     = new double[Days];
            double[] _y    = new double[Days];
            double[] x     = new double[Days];
            double[] error = new double[Days];
            double   sd    = 0;


            if (!F*g)
            {
                zedGraphControl4.Size = new Size(920 - 120, 480);
                graphpane.Rect        = new RectangleF(15, 30, 900 - 120, 280);  //设置分图的大小和位置
                graphpane.Chart.Rect  = new RectangleF(95, 80, 750 - 120, 200);
                graphpane1.Rect       = new RectangleF(15, 320, 900 - 120, 150); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF(95, 330, 750 - 120, 80);
            }
            else
            {
                zedGraphControl4.Size = new Size((int)(0.94117 * Width), (int)(0.65753 * Height));
                graphpane.Rect        = new RectangleF((int)(0.01764 * Width), (int)(0.04109 * Height), (int)(0.91764 * Width), (int)(0.38356 * Height)); //设置分图的大小和位置900, 300
                graphpane.Chart.Rect  = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.04109 * Height) + 40, (int)(0.74117 * Width), (int)(0.27397 * Height));
                graphpane1.Rect       = new RectangleF((int)(0.01764 * Width), (int)(0.43835 * Height), (int)(0.91764 * Width), (int)(0.20547 * Height)); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.45205 * Height), (int)(0.74117 * Width), (int)(0.27397 * Height) - 100 - (int)(0.01369 * Height));
            }
            for (int i = 0; i < Days; i++)
            {
                x[i]     = i + 1;
                y[i]     = Y[i, 0];
                _y[i]    = FitY[i, 0];
                error[i] = FitY[i, 0] - Y[i, 0];
                if (dataGridView1 != null)
                {
                    dataGridView1.Rows.Add();
                    dataGridView1[3, i].Value = Math.Round(error[i], 2);
                    dataGridView1[0, i].Value = "第" + (order + 1 + i).ToString() + "期";
                    dataGridView1[1, i].Value = Math.Round(y[i], 2);
                    dataGridView1[2, i].Value = Math.Round(_y[i], 2);
                }
                sd += Math.Pow(error[i], 2);
            }
            sd /= Days;
            sd  = Math.Sqrt(sd);

            graphpane.YAxis.Title.Text            = "位移量/mm";
            graphpane.YAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Scale.IsVisible       = false;
            graphpane.XAxis.Scale.MajorStep       = x.Length / graphpane.Rect.Width * 60;
            graphpane.YAxis.Title.FontSpec.Size   = 15;
            graphpane.YAxis.Title.FontSpec.IsBold = false;
            graphpane.Legend.Position             = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible     = false;
            graphpane.Legend.FontSpec.Family      = "Arial";
            graphpane.Legend.FontSpec.Size        = 15;
            graphpane.Legend.FontSpec.IsBold      = false;
            graphpane1.XAxis.Scale.Max            = Days;//设置最大刻度
            double min, max;

            if ((min = Math.Abs(error.Min())) > (max = Math.Abs(error.Max())))
            {
                graphpane1.YAxis.Scale.Max = (int)min + 1;    //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)min - 1;   //设置最大刻度
            }
            else
            {
                graphpane1.YAxis.Scale.Max = (int)max + 1;                       //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)max - 1;                      //设置最大刻度
            }
            graphpane1.YAxis.Scale.MajorStep       = graphpane1.YAxis.Scale.Max; //设置大刻度步长
            graphpane1.XAxis.Scale.IsSkipLastLabel = false;

            graphpane1.YAxis.Title.Text            = "△/mm";
            graphpane1.YAxis.Title.FontSpec.Family = "Arial";
            graphpane1.YAxis.Title.FontSpec.Size   = 15;
            graphpane1.YAxis.Title.FontSpec.IsBold = false;

            graphpane1.XAxis.Title.Text            = "期数";
            graphpane1.XAxis.Title.FontSpec.Family = "Arial";
            graphpane1.XAxis.Title.FontSpec.Size   = 15;
            graphpane1.XAxis.Title.FontSpec.IsBold = false;


            LineItem myline  = graphpane.AddCurve("观测值", null, y, Color.SpringGreen, SymbolType.None);
            LineItem myline1 = graphpane.AddCurve("拟合值", null, _y, Color.Red, SymbolType.None);
            LineItem myline3 = graphpane1.AddCurve("残差", null, error, Color.Red, SymbolType.None);

            myline.Line.Width           = 1.5F; //线宽
            myline1.Line.Width          = 1.5F; //线宽
            myline3.Line.Width          = 1.5F; //线宽
            graphpane1.Legend.IsVisible = false;

            float   width  = graphpane.Chart.Rect.Width;
            float   heigh  = graphpane.Chart.Rect.Height;
            float   width1 = graphpane1.Chart.Rect.Width;
            float   heigh1 = graphpane1.Chart.Rect.Height;
            TextObj text   = new TextObj(PointNaem, 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            TextObj text1 = new TextObj(PointNaem, 2 / width1, 2 / heigh1); //定义文本对象

            text1.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text1.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text1.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text1.FontSpec.Border.IsVisible = false;
            text1.FontSpec.FontColor        = Color.Blue;
            text1.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text1);
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            TextObj text2 = new TextObj("RMS=" + Math.Round(sd, 2) + "mm", 2 / width1, (heigh1 - 2) / heigh1); //定义文本对象

            text2.Location.AlignV           = AlignV.Bottom;                                                   //确定文本的x轴为于文本的最下端
            text2.Location.AlignH           = AlignH.Left;                                                     //确定文本的y轴为于文本的最左端
            text2.Location.CoordinateFrame  = CoordType.ChartFraction;                                         //设置文本的坐标系统,原点位于内框的左上角
            text2.FontSpec.Border.IsVisible = false;
            text2.FontSpec.FontColor        = Color.Blue;
            text2.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text2);
            masterpane.Add(graphpane);
            masterpane.Add(graphpane1);
            Graphics gd = zedGraphControl4.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl4.Refresh();
        }
Beispiel #28
0
        public static void GraphBIC(int Width, int Height, ZedGraphControl zedGraphControl3, Matrix BIC, Matrix AIC, bool F*g = true)
        {
            MasterPane masterpane = zedGraphControl3.MasterPane;

            masterpane.PaneList.Clear();
            zedGraphControl3.Visible            = true;
            zedGraphControl3.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl3.IsEnableSelection  = true;
            zedGraphControl3.BorderStyle        = System.Windows.Forms.BorderStyle.None;

            GraphPane graphpane = new GraphPane();//BIC图

            if (!F*g)

            {
                zedGraphControl3.Location = new Point((int)(0.40584 * Width), 0);
                zedGraphControl3.Size     = new Size((int)(0.47889 * Width), (int)(0.84782 * Height));
                graphpane.Rect            = new RectangleF((int)(0.01217 * Width), (int)(0.01672 * Height), (int)(0.43019 * Width), (int)(0.80267 * Height));//设置分图的大小和位置900, 300
                graphpane.Chart.Rect      = new RectangleF((int)(0.01217 * Width) + 60, (int)(0.01672 * Height) + 50, (int)(0.35714 * Width), (int)(0.80267 * Height) - 60 - 50);
            }
            else
            {
                zedGraphControl3.Location = new Point(500, 0);
                zedGraphControl3.Size     = new Size(590, 507);
                graphpane.Rect            = new RectangleF(15, 10, 530, 480);//设置分图的大小和位置900, 300
                graphpane.Chart.Rect      = new RectangleF(95, 60, 440, 340);
            }


            graphpane.XAxis.Scale.Max = BIC.Rows;
            SetGraphics(graphpane);
            graphpane.YAxis.MajorGrid.IsVisible = false;
            double[] BIC_x = new double[BIC.Rows];
            double[] BIC_y = new double[BIC.Rows];
            double[] AIC_y = new double[AIC.Rows];
            for (int i = 0; i < BIC.Rows; i++)
            {
                BIC_x[i] = i + 1;
                BIC_y[i] = BIC[i, 0];
                AIC_y[i] = AIC[i, 0];
            }
            LineItem myline  = graphpane.AddCurve("BIC", BIC_x, BIC_y, Color.SpringGreen, SymbolType.Square);
            LineItem myline1 = graphpane.AddCurve("AIC", BIC_x, AIC_y, Color.Black, SymbolType.Star);

            graphpane.XAxis.Title.Text = "时间延迟";
            graphpane.YAxis.Title.Text = "BIC";

            myline.Symbol.Size         = 5.0F;                 //设置节点形状大小
            myline.Symbol.Fill         = new Fill(Color.Red);  //设置节点填充
            myline.Symbol.Border.Color = Color.Red;
            myline.Line.Width          = 1;                    //线宽

            myline1.Symbol.Size         = 5.0F;                //设置节点形状大小
            myline1.Symbol.Fill         = new Fill(Color.Red); //设置节点填充
            myline1.Symbol.Border.Color = Color.Blue;
            myline1.Line.Width          = 1;                   //线宽

            masterpane.Add(graphpane);
            Graphics gd = zedGraphControl3.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl3.Refresh();
        }