Beispiel #1
0
        private void DisplayParetoFront <S>(NondominatedPopulation <S> archive)
            where S : ContinuousVector, new()
        {
            GraphPane pane = chtParetoFront.GraphPane;

            pane.XAxis.Title.Text = "Objective 1";
            pane.YAxis.Title.Text = "Objective 2";
            pane.Title.Text       = string.Format("Problem: {0}", (ProblemType)cboProblem.SelectedItem);

            PointPairList list = new PointPairList();

            foreach (S s in archive.Solutions)
            {
                list.Add(s.FindObjectiveAt(0), s.FindObjectiveAt(1));
            }

            AlgorithmType algorithm_type = (AlgorithmType)cboAlgorithm.SelectedItem;
            LineItem      myCurve        = pane.AddCurve(string.Format("{0} ({1})", algorithm_type.ToString(), cboProblem.SelectedItem), list, GetParetoFrontColor());

            myCurve.Symbol.Type    = ZedGraph.SymbolType.Plus;
            myCurve.Line.IsVisible = false;

            pane.AxisChange();
            chtParetoFront.Invalidate();

            DataTable table = new DataTable();

            table.Columns.Add("#");
            IMOOProblem problem = archive[0].Problem;

            for (int i = 0; i < problem.GetObjectiveCount(); ++i)
            {
                table.Columns.Add(string.Format("Objective {0}", i + 1));
            }
            for (int i = 0; i < problem.GetDimensionCount(); ++i)
            {
                table.Columns.Add(string.Format("x[{0}]", i));
            }

            for (int i = 0; i < archive.Count; ++i)
            {
                S             s      = archive[i];
                List <object> values = new List <object>();
                values.Add(i + 1);
                for (int j = 0; j < problem.GetObjectiveCount(); ++j)
                {
                    values.Add(s.FindObjectiveAt(j));
                }
                for (int j = 0; j < problem.GetDimensionCount(); ++j)
                {
                    values.Add(s[j]);
                }
                table.Rows.Add(values.ToArray());
            }

            dgvParetoFront.DataSource = table;
        }
Beispiel #2
0
        private void LoadQueueHistogramGraph()
        {
            //// For Histogram ..

            //// -- Begin Plotting ..
            List <double> xDataQueueHisto = new List <double>();
            List <double> yDataQueueHisto = new List <double>();

            int MaxGraphQueueHisto = 0;

            GraphPane QueueHistoGraphPane = QueueSizeHistogramPanel.GraphPane;

            // Set the Titles
            QueueHistoGraphPane.Title.Text       = "Queue Size Histogram";
            QueueHistoGraphPane.XAxis.Title.Text = "Delay Value";
            QueueHistoGraphPane.YAxis.Title.Text = "Numbers Of Customers";

            QueueHistoGraphPane.XAxis.Scale.Min = -1;
            QueueHistoGraphPane.YAxis.Scale.Min = 0;

            QueueHistoGraphPane.XAxis.Scale.MajorStep = 1;


            DataGridView HistoData = Program.simulationTableForm.outputDataGrid;

            double[] HistoList = new double[QueuingSystem.maxDelay + 1];

            int MaxHisto = 0;

            for (int i = 0; i < HistoData.Rows.Count; i++)
            {
                HistoList[Convert.ToInt32(HistoData.Rows[i].Cells[9].Value)]++;
                if (HistoList[Convert.ToInt32(HistoData.Rows[i].Cells[9].Value)] >= MaxHisto)
                {
                    MaxHisto = (int)HistoList[Convert.ToInt32(HistoData.Rows[i].Cells[9].Value)];
                }
            }

            QueueHistoGraphPane.XAxis.Scale.Max = HistoList.Length;
            QueueHistoGraphPane.YAxis.Scale.Max = Convert.ToInt32(MaxHisto);

            QueueHistoGraphPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            QueueHistoGraphPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));


            double[] xAxisForQueueHisto = new double[HistoList.Length];
            for (int i = 0; i < HistoList.Length; i++)
            {
                xAxisForQueueHisto[i] = i;
            }

            BarItem b = QueueHistoGraphPane.AddBar("", xAxisForQueueHisto, HistoList, Color.Red);

            QueueHistoGraphPane.AxisChange();
            QueueSizeHistogramPanel.Invalidate();
            //// -- End Plotting
        }
Beispiel #3
0
        private void guardagrafica(double S)
        {
            myPane.XAxis.IsMinorInsideTic = false;
            //myPane.XAxis.TicSize = 0;
            myPane.XAxis.IsShowGrid          = true;
            myPane.XAxis.IsInsideTic         = false;
            myPane.XAxis.IsOppositeTic       = false;
            myPane.XAxis.IsMinorOppositeTic  = false;
            myPane.XAxis.ScaleFontSpec.Angle = 0;
            myPane.XAxis.NumDec = 0;
            myPane.XAxis.IsTicsBetweenLabels = false;
            //            myPane.XAxis.Step = float.Parse((res * 0.1).ToString());
            myPane.XAxis.Min  = S; //cambiar
            myPane.XAxis.Max  = S + 25;
            myPane.XAxis.Type = AxisType.Linear;
            //            myPane.XAxis.StepAuto = true;
            myPane.XAxis.MinorStepAuto           = false;
            myPane.XAxis.TitleFontSpec.Family    = "Times New Roman";
            myPane.XAxis.TitleFontSpec.Size      = 8;
            myPane.XAxis.ScaleFontSpec.Size      = 8;
            myPane.XAxis.IsShowTitle             = true;
            myPane.XAxis.ScaleFontSpec.FontColor = Color.Black;
            myPane.XAxis.IsMinorTic = false;
            myPane.XAxis.Title      = "Semanas";
            myPane.XAxis.Step       = 1;
            myPane.XAxis.IsVisible  = false;
            //            myPane.YAxis.IsMinorInsideTic = true;
            //            myPane.XAxis.IsInsideTic = true;
            myPane.YAxis.IsShowGrid          = false;
            myPane.YAxis.ScaleFontSpec.Angle = 90;
            myPane.YAxis.ScaleFontSpec.Size  = 8;
            myPane.YAxis.Min = 0;
            myPane.YAxis.Max = 35;
            //myPane.YAxis.TicSize = 10;
            myPane.YAxis.TitleFontSpec.Family = "Times New Roman";
            myPane.YAxis.ScaleFontSpec.Family = "Times New Roman";
            myPane.YAxis.Title          = "Servicios";
            myPane.Legend.IsVisible     = true;
            myPane.Legend.Location      = LegendLoc.InsideTopLeft;
            myPane.Legend.FontSpec.Size = 8;
            myPane.PaneFill             = new Fill(Color.White, Color.White, 2F);
            myPane.AxisChange(this.CreateGraphics());
            myPane.IsShowTitle = false;

            pictureBox2.Image       = Image.FromHbitmap(myPane.Image.GetHbitmap());
            pictureBox2.BorderStyle = BorderStyle.None;
            MemoryStream ms1 = new MemoryStream();

            pictureBox2.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.Bmp);
            byte[] arrImage1 = ms1.GetBuffer();
            ms1.Close();

            myPane.Image.Dispose();
            pictureBox2.Image.Dispose();
            dsGrupos1.Grafica.AddGraficaRow(1, arrImage1);
        }
        /*Other methods ---------------------------------------------------------------------------------------------------------------------------*/
        private void clearGraph()
        {
            zGrphPlotData.GraphPane.CurveList.Clear();                  // Xóa đường
            zGrphPlotData.GraphPane.GraphObjList.Clear();               // Xóa đối tượng
            zGrphPlotData.AxisChange();
            zGrphPlotData.Invalidate();

            Realtime = 0;
            //setpoint = 0;
            Measure = 0;

            // Khởi tạo ZedGraph
            GraphPane myPane = zGrphPlotData.GraphPane;      //Tác động các thành phần của Control, (GraphPane)

            myPane.Title.Text       = "Giá trị đặt - giá trị đo";
            myPane.XAxis.Title.Text = "Thời gian (s)";
            myPane.YAxis.Title.Text = "Dữ liệu";

            RollingPointPairList list   = new RollingPointPairList(60000);                                  //Tạo mới danh sách dữ liệu 60000 phần tử, có khả năng cuốn chiếu
            LineItem             curve  = myPane.AddCurve("Giá trị đặt", list, Color.Red, SymbolType.None); //Tạo mới đường cong của đồ thị trên GraphPane dựa vào danh sách dữ liệu
            RollingPointPairList list2  = new RollingPointPairList(60000);
            LineItem             curve2 = myPane.AddCurve("Giá trị đo", list2, Color.MediumSlateBlue, SymbolType.None);

            myPane.XAxis.Scale.Min       = 0;                   //Đặt giới hạn đồ thị
            myPane.XAxis.Scale.Max       = 6;
            myPane.XAxis.Scale.MinorStep = 0.1;                 //Đặt các bước độ chia
            myPane.XAxis.Scale.MajorStep = 1;
            //myPane.YAxis.Scale.Min = 0;                      //Tương tự cho trục y
            //myPane.YAxis.Scale.Max = 100;

            myPane.AxisChange();

            zGraphParameters.GraphPane.CurveList.Clear();                  // Xóa đường
            zGraphParameters.GraphPane.GraphObjList.Clear();               // Xóa đối tượng
            zGraphParameters.AxisChange();
            zGraphParameters.Invalidate();

            // Khởi tạo ZedGraph
            GraphPane myPanePara = zGraphParameters.GraphPane;      //Tác động các thành phần của Control, (GraphPane)

            myPanePara.Title.Text       = "PWM";
            myPanePara.XAxis.Title.Text = "Thời gian (s)";
            myPanePara.YAxis.Title.Text = "Dữ liệu";

            RollingPointPairList listPara  = new RollingPointPairList(60000);                                          //Tạo mới danh sách dữ liệu 60000 phần tử, có khả năng cuốn chiếu
            LineItem             curvePara = myPanePara.AddCurve("Giá trị đặt", listPara, Color.Red, SymbolType.None); //Tạo mới đường cong của đồ thị trên GraphPane dựa vào danh sách dữ liệu

            myPanePara.XAxis.Scale.Min       = 0;                                                                      //Đặt giới hạn đồ thị
            myPanePara.XAxis.Scale.Max       = 6;
            myPanePara.XAxis.Scale.MinorStep = 0.1;                                                                    //Đặt các bước độ chia
            myPanePara.XAxis.Scale.MajorStep = 1;
            //myPanePara.YAxis.Scale.Min = -60;                      //Tương tự cho trục y
            //myPanePara.YAxis.Scale.Max = 60;

            myPanePara.AxisChange();
        }
Beispiel #5
0
        private void LoadCustomerQueueGraph()
        {
            // For Customers Queue Graph ..
            CustomerQueueGraphPanel.Invalidate();
            CustomerQueueGraphPanel.GraphPane.CurveList.Clear();
            CustomerQueueGraphPanel.GraphPane.GraphObjList.Clear();

            // -- Begin Plotting ..

            List <double> xDataCustomerQueueGraph = new List <double>();
            List <double> yDataCustomerQueueGraph = new List <double>();

            int MaxGraphValueQueueGraph = QueuingSystem.queueArray.Length;

            GraphPane CustomerQueueGraphPane = CustomerQueueGraphPanel.GraphPane;

            // Set the Titles
            CustomerQueueGraphPane.Title.Text       = "Customers Queue Graph";
            CustomerQueueGraphPane.XAxis.Title.Text = "Hours";
            CustomerQueueGraphPane.YAxis.Title.Text = "Numbers Of Customers";

            CustomerQueueGraphPane.XAxis.Scale.Min = 0;
            CustomerQueueGraphPane.YAxis.Scale.Min = 0;

            CustomerQueueGraphPane.XAxis.Scale.Max = MaxGraphValueQueueGraph;

            // Getting the maximum value for the queue size ..
            CustomerQueueGraphPane.YAxis.Scale.Max = Convert.ToInt32(Program.simulationTableForm.maxQueueLengthTextBox.Text);

            CustomerQueueGraphPane.YAxis.Scale.MajorStep = 1;

            CustomerQueueGraphPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            CustomerQueueGraphPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));

            int UnitSize = 1;

            for (int i = 0; i < QueuingSystem.queueArray.Length; i++)
            {
                if (QueuingSystem.queueArray[i] != 0)
                {
                    BoxObj box = new BoxObj(i, (int)QueuingSystem.queueArray[i], UnitSize, (int)QueuingSystem.queueArray[i], Color.Empty, Color.Red);
                    box.IsVisible = true;
                    box.Location.CoordinateFrame = CoordType.AxisXYScale;
                    box.ZOrder = ZOrder.A_InFront;
                    CustomerQueueGraphPanel.GraphPane.GraphObjList.Add(box);
                }
            }

            // Tell ZedGraph to refigure the
            // axes since the data have changed

            CustomerQueueGraphPane.AxisChange();
            CustomerQueueGraphPanel.Invalidate();
            // -- End Plotting
        }
Beispiel #6
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZeeGraphControl()
        {
            _dragPane = null;
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.ResizeRedraw, true);


            SetStyle(ControlStyles.SupportsTransparentBackColor, true);


            _resourceManager = new ResourceManager("ZeeGraph.ZeeGraphLocale",
                                                   Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle(0, 0, Size.Width, Size.Height);

            _masterPane                 = new MasterPane("", rect);
            _masterPane.Margin.All      = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = _resourceManager.GetString("title_def");
            string xStr     = _resourceManager.GetString("x_title_def");
            string yStr     = _resourceManager.GetString("y_title_def");

            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);

            using (Graphics g = CreateGraphics())
            {
                graphPane.AxisChange(g);
                //g.Dispose();
            }
            _masterPane.Add(graphPane);

            hScrollBar1.Minimum = 0;
            hScrollBar1.Maximum = 100;
            hScrollBar1.Value   = 0;

            vScrollBar1.Minimum = 0;
            vScrollBar1.Maximum = 100;
            vScrollBar1.Value   = 0;

            _xScrollRange      = new ScrollRange(true);
            _yScrollRangeList  = new ScrollRangeList();
            _y2ScrollRangeList = new ScrollRangeList();

            _yScrollRangeList.Add(new ScrollRange(true));
            _y2ScrollRangeList.Add(new ScrollRange(false));

            _zoomState      = null;
            _zoomStateStack = new ZoomStateStack();
        }
Beispiel #7
0
        public Bitmap GetImage(int width, int height, float dpi, bool isAntiAlias, bool init = true)
        {
            if (init)
            {
                ConfigPane();
                DrawPane();
            }
            myPane.AxisChange();

            return(myPane.GetImage(width, height, dpi, isAntiAlias));
        }
Beispiel #8
0
        private void PaneDisplay(PointPairList display, Color LineColor)
        {
            GraphPane myPane = zedGraphControl.GraphPane;

            myPane.CurveList.Clear();
            LineItem myCurve = myPane.AddCurve("Porsche", display, LineColor, SymbolType.None);

            zedGraphControl.IsShowPointValues = true;
            myPane.AxisChange();
            zedGraphControl.Invalidate();
        }
Beispiel #9
0
        private void Plot_form_Load(object sender, EventArgs e)
        {
            pane = Plot_zedGraphControl.GraphPane;
            pane.CurveList.Clear();

            pane.XAxis.Title.Text = NetworkStatets_comboBox.Text;
            pane.YAxis.Title.Text = "Degree";
            pane.Title.Text       = Algorithm_comboBox.Text;

            pane.AxisChange();
        }
 public override void Activate()
 {
     ZedGraphControl.IsEnableGraphEdit   = true;
     ZedGraphControl.IsZoomOnMouseCenter = true;
     //ZedGraphControl.IsShowHScrollBar = true;
     //ZedGraphControl.IsEnableHZoom = false;
     //ZedGraphControl.IsEnableVZoom = true;
     ZedGraphControl.IsAutoScrollRange = true;
     m_DistanceMeasurer.Coord          = CoordType.AxisXY2Scale;
     GraphPane.AxisChange();
 }
Beispiel #11
0
 private void buttonClearData_Click(object sender, EventArgs e)
 {
     time = 0;
     richTextBox1.Clear();
     myCurveOne.Clear();
     myCurveTwo.Clear();
     myPane.XAxis.Scale.Min  = 0;
     myPane.Y2Axis.Scale.Min = 0;
     myPane.Y2Axis.Scale.Max = 25;
     myPane.AxisChange();
 }
Beispiel #12
0
        private void CreateThreshold()
        {
            GraphPane graphPane = graph.PaneList[0];
            double    num       = 0.0;
            LineObj   lineObj   = new LineObj(Color.Green, 0.0, num, 1.0, num);

            lineObj.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            lineObj.IsVisible = true;
            graphPane.GraphObjList.Add((GraphObj)lineObj);
            graphPane.AxisChange();
            graph.Invalidate();
        }
Beispiel #13
0
        /// <summary>
        /// Returns a graph of post frequency over the life of the journal.
        /// </summary>
        /// <param name="j">The <see cref="Journal"/> to analyze frequencies.</param>
        /// <param name="width">The width of the graph.</param>
        /// <param name="height">The height of the graph.</param>
        /// <param name="splitPosts">A category designating posts be split per day, month, or year.</param>
        /// <returns>a graph of post frequency over the life of the journal.</returns>
        static public GraphPane GetGraph(Journal j, int width, int height, SplitPosts splitPosts)
        {
            SortedList sl = new SortedList();
            GraphPane  pane;
            CurveItem  curve;

            double[] x, y;
            foreach (Journal.EventsRow er in j.Events)
            {
                DateTime dt;
                if (er.IsDateNull())
                {
                    continue;
                }
                switch (splitPosts)
                {
                case SplitPosts.Day: dt = er.Date.Date; break;

                case SplitPosts.Month: dt = new DateTime(er.Date.Year, er.Date.Month, 1); break;

                default: dt = new DateTime(er.Date.Year, 1, 1); break;
                }
                if (sl.ContainsKey(dt))
                {
                    sl[dt] = (int)sl[dt] + 1;
                }
                else
                {
                    sl.Add(dt, 1);
                }
            }
            pane = new GraphPane(new Rectangle(0, 0, width, height),
                                 "Post Frequencies Per " + splitPosts.ToString(), "Date", "Post Frequency");
            x = new double[sl.Count];
            y = new double[sl.Count];
            for (int i = 0; i < sl.Count; ++i)
            {
                DateTime dt = (DateTime)sl.GetKey(i);
                x[i] = (double)new XDate(dt.Year, dt.Month, dt.Day);
                y[i] = (int)sl.GetByIndex(i);
            }
            curve                  = pane.AddCurve("Frequency", x, y, Color.Red, SymbolType.Diamond);
            pane.XAxis.Type        = AxisType.Date;
            pane.XAxis.ScaleFormat = "&yyyy";
            pane.XAxis.IsShowGrid  = true;
            pane.YAxis.IsShowGrid  = true;
            pane.XAxis.GridColor   = Color.LightGray;
            pane.YAxis.GridColor   = Color.LightGray;
            pane.AxisBackColor     = Color.LightCyan;
            pane.Legend.IsVisible  = false;
            pane.AxisChange();
            return(pane);
        }
Beispiel #14
0
        private void CreateThreshold()
        {
            GraphPane pane = this.graph.PaneList[0];
            double    num  = 0.0;
            LineObj   item = new LineObj(Color.Green, 0.0, num, 1.0, num);

            item.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            item.IsVisible = true;
            pane.GraphObjList.Add(item);
            pane.AxisChange();
            this.graph.Invalidate();
        }
Beispiel #15
0
 public void DrawWaterYears(SeriesList list, string title, string subTitle, bool multiLeftAxis = false)
 {
     CreateSeries(list, title, subTitle, true, multiLeftAxis);
     for (int i = 0; i < list.Count; i++)
     {
         FillTimeSeries(list[i], chart1.GraphPane.CurveList[i]);
     }
     pane.XAxis.Type         = AxisType.Date;
     pane.XAxis.Scale.Format = "MMM d";
     pane.AxisChange();
     chart1.Refresh();
 }
        public GraphPane CreateGraph()
        {
            var myPane = new GraphPane(new RectangleF(0, 0, 1024, 768), Title, XTitle, YTitle);

            // Set the title and axis labels
            myPane.Title.IsVisible           = false;
            myPane.Legend.IsVisible          = false;
            myPane.YAxis.Title.IsVisible     = true;
            myPane.XAxis.Title.IsVisible     = true;
            myPane.XAxis.Scale.IsReverse     = Reverse;
            myPane.XAxis.Scale.Min           = -90;
            myPane.XAxis.Scale.Max           = -40;
            myPane.YAxis.Scale.Min           = 0;
            myPane.YAxis.Scale.Max           = 1;
            myPane.YAxis.Scale.MajorStep     = 0.25;
            myPane.YAxis.Scale.MinorStep     = 0.05;
            myPane.YAxis.Scale.Format        = "f2";
            myPane.YAxis.Scale.MajorStepAuto = false;
            myPane.YAxis.Scale.MinorStepAuto = false;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.PenWidth  = 3f;
            myPane.YAxis.MajorGrid.DashOn    = 7f;
            myPane.YAxis.MajorGrid.DashOff   = 7f;
            myPane.YAxis.MinorGrid.PenWidth  = 2f;

            myPane.Fill             = new Fill(Color.White);
            myPane.Border.IsVisible = false;

            myPane.Chart.Fill = new Fill(Color.White);

            foreach (var boxData in Boxes)
            {
                // Draw a box item to highlight a value range
                var box = new BoxObj(0, boxData.Top, 1, boxData.Top - boxData.Bottom)
                {
                    Fill   = boxData.Fill,
                    ZOrder = ZOrder.E_BehindCurves,
                    IsClippedToChartRect = true,
                    Location             = { CoordinateFrame = CoordType.XChartFractionYScale }
                };
                myPane.GraphObjList.Add(box);
            }
            myPane.GraphObjList.AddRange(TextObjs);

            var list  = new ClippedPointList(XAxis, YAxis, 0, DroppedPackages ? XAxis.Length - 1 : XAxis.Length);
            var curve = new LineItem("", list, Color.Black, SymbolType.None, 3f);

            myPane.CurveList.Add(curve);

            myPane.AxisChange();
            return(myPane);
        }
Beispiel #17
0
        /*Radio Button methods*/
        private void rBtnVP_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                clearGraph();
                if (rBtnVelocity.Checked)
                {
                    lbVelocity.Text = "Velocity";
                    tbCalib.Text    = "4.8";

                    GraphPane myPane = zGrphPlotData.GraphPane;
                    myPane.YAxis.Scale.Min = 0;                      //Tương tự cho trục y
                    myPane.YAxis.Scale.Max = 2500;
                    myPane.AxisChange();

                    //byte[] temp = new byte[1];
                    //temp[0] = (byte)UartCom.controlHeader.Velocity;
                    //sPort.Write(temp, 0, 1);
                    byte[] setPointBuffer;
                    if (UartCom.TxHandshake(UartCom.ControlHeader.Velocity, "0", out setPointBuffer))
                    {
                        sPort.Write(setPointBuffer, 0, 7);
                    }
                    ReTrans.Enabled = true;
                }
                else
                {
                    lbVelocity.Text = "Position";
                    tbCalib.Text    = "40";

                    GraphPane myPane = zGrphPlotData.GraphPane;
                    myPane.YAxis.Scale.Min = 0;                      //Tương tự cho trục y
                    myPane.YAxis.Scale.Max = 600;
                    myPane.AxisChange();

                    //byte[] temp = new byte[1];
                    //temp[0] = (byte)UartCom.controlHeader.Position;
                    //sPort.Write(temp, 0, 1);
                    byte[] setPointBuffer;
                    if (UartCom.TxHandshake(UartCom.ControlHeader.Position, "0", out setPointBuffer))
                    {
                        sPort.Write(setPointBuffer, 0, 7);
                    }
                    ReTrans.Enabled = true;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //throw;
            }
        }
Beispiel #18
0
        static int CreateTablePieChart(string fn)
        {
            GraphPane myPane = new GraphPane(new RectangleF(0, 0, 640, 480), "Flavour", "X", "Y");

            // Add some pie slices
            PieItem segment01 = myPane.AddPieSlice(15, Color.Navy, Color.White, 45f, 0.10, "Salt");
            PieItem segment02 = myPane.AddPieSlice(20, Color.DarkRed, Color.White, 45f, 0.00, "Pepper");
            PieItem segment03 = myPane.AddPieSlice(26, Color.LimeGreen, Color.White, 45f, 0.00, "Nutmeg ");

            segment03.LabelDetail.FontSpec.FontColor = Color.Red;

            // Calculate the Axis Scale Ranges
            myPane.AxisChange();

            Bitmap bm = new Bitmap(1, 1);

            using (Graphics g = Graphics.FromImage(bm))
                myPane.AxisChange(g);
            myPane.GetImage().Save(fn, ImageFormat.Png);

            return(3);
        }
        public static void Start(string logFile)
        {
            // Clear out memory log file.
            using (File.CreateText(logFile))
            {
            }

            var worker = new BackgroundWorker();

            worker.DoWork += (sender, args) =>
            {
                while (true)
                {
                    Thread.Sleep(500);

                    try
                    {
                        string[] lines;
                        using (var reader = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                            using (var stringReader = new StreamReader(reader))
                            {
                                lines = stringReader.ReadToEnd().Split('\n');
                            }

                        lock (_graphPane)
                        {
                            _pointList.Clear();
                            foreach (var line in lines)
                            {
                                int megabytes;
                                if (int.TryParse(line, out megabytes))
                                {
                                    _pointList.Add(_pointList.Count, megabytes);
                                }
                            }
                            _graphPane.AxisChange();
                            if (_memoryChartWindow != null)
                            {
                                _memoryChartWindow.graphControl.Invalidate();
                            }
                        }
                    }
// ReSharper disable once EmptyGeneralCatchClause
                    catch
                    {
                    }
                }
// ReSharper disable once FunctionNeverReturns
            };
            worker.RunWorkerAsync();
        }
Beispiel #20
0
        /// <summary>
        /// zedgragh作图
        /// </summary>
        /// <param name="zg"></param>
        private void SetGragh(ZedGraph.ZedGraphControl zg)
        {
            GraphPane myPane = zg.GraphPane;

            //Set labels
            myPane.Title.Text       = "煤气实绩"; // 表头
            myPane.XAxis.Title.Text = "时间";   // 横坐标lable
            myPane.YAxis.Title.Text = "煤气量";  // 纵坐标label
            //Set list
            PointPairList list = new PointPairList();

            /*            List<HRGasReal> tempList = vList.ToList();
             *
             *          for (int i = 0; i < 100; i++)
             *          {
             *              double C = tempList[i].Consumption;
             *              DateTime T = tempList[i].Time;
             *
             *              double x = Convert.ToDouble(i);
             *              double y = Convert.ToDouble(C);
             *              list.Add(x, y);
             *          }
             */
            /*//DateTime m = Convert.ToDateTime(DG1.Columns[1]);
             * Double n = Convert.ToDouble( DG1.Columns[2]);
             * list.Add(m, n);
             * for (int i = 0; i < 100; i++)
             * {
             *  double x = (double)new XDate(2013, 6,11,i,0,0);
             *
             *  double y = Math.Sin((double)i * Math.PI / 15.0);
             *
             *  list.Add(x, y);
             * }*/

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve = myPane.AddCurve("煤气量", list, Color.Blue, SymbolType.Circle);

            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve.Line.Fill = new Fill(Color.White, Color.Red, 45F);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);
            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
            // Fill the pane background with a color gradient
            myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
            //Calculate the Axis Scale Ranges
            //myPane.XAxis.Type = AxisType.Date;

            myPane.AxisChange();
        }
Beispiel #21
0
        private void FormSerialPort_Load(object sender, EventArgs e)
        {
            string[] port = SerialPort.GetPortNames();
            cBoxPortName.Items.AddRange(port);

            logTable.Columns.Add("Setpoint", typeof(float));
            logTable.Columns.Add("Measure", typeof(float));

            // Khởi tạo ZedGraph
            GraphPane myPane = zGrphPlotData.GraphPane;      //Tác động các thành phần của Control, (GraphPane)

            myPane.Title.Text       = "Giá trị đặt - Giá trị đo";
            myPane.XAxis.Title.Text = "Thời gian (s)";
            myPane.YAxis.Title.Text = "Dữ liệu";

            RollingPointPairList list   = new RollingPointPairList(60000);                                  //Tạo mới danh sách dữ liệu 60000 phần tử, có khả năng cuốn chiếu
            LineItem             curve  = myPane.AddCurve("Giá trị đặt", list, Color.Red, SymbolType.None); //Tạo mới đường cong của đồ thị trên GraphPane dựa vào danh sách dữ liệu
            RollingPointPairList list2  = new RollingPointPairList(60000);
            LineItem             curve2 = myPane.AddCurve("Giá trị đo", list2, Color.MediumSlateBlue, SymbolType.None);

            myPane.XAxis.Scale.Min       = 0;                //Đặt giới hạn đồ thị
            myPane.XAxis.Scale.Max       = 6;
            myPane.XAxis.Scale.MinorStep = 0.1;              //Đặt các bước độ chia
            myPane.XAxis.Scale.MajorStep = 1;
            myPane.YAxis.Scale.Min       = 0;                //Tương tự cho trục y
            myPane.YAxis.Scale.Max       = 2500;

            myPane.AxisChange();

            // Khởi tạo ZedGraph
            GraphPane myPanePara = zGraphParameters.GraphPane;      //Tác động các thành phần của Control, (GraphPane)

            myPanePara.Title.Text       = "Tham số";
            myPanePara.XAxis.Title.Text = "Thời gian (s)";
            myPanePara.YAxis.Title.Text = "Dữ liệu";

            RollingPointPairList listPara   = new RollingPointPairList(60000);                                 //Tạo mới danh sách dữ liệu 60000 phần tử, có khả năng cuốn chiếu
            LineItem             curvePara  = myPanePara.AddCurve("a1", listPara, Color.Red, SymbolType.None); //Tạo mới đường cong của đồ thị trên GraphPane dựa vào danh sách dữ liệu
            RollingPointPairList list2Para  = new RollingPointPairList(60000);
            LineItem             curve2Para = myPanePara.AddCurve("a2", list2Para, Color.MediumSlateBlue, SymbolType.None);

            myPanePara.XAxis.Scale.Min       = 0;                //Đặt giới hạn đồ thị
            myPanePara.XAxis.Scale.Max       = 6;
            myPanePara.XAxis.Scale.MinorStep = 0.1;              //Đặt các bước độ chia
            myPanePara.XAxis.Scale.MajorStep = 1;
            myPanePara.YAxis.Scale.Min       = 0;                //Tương tự cho trục y
            myPanePara.YAxis.Scale.Max       = 10;

            myPanePara.AxisChange();
        }
Beispiel #22
0
        private void InitGragh(ZedGraph.ZedGraphControl zg)
        {
            GraphPane myPane = zg.GraphPane;

            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();

            //Set labels
            myPane.Title.Text       = "煤气实绩"; // 表头
            myPane.XAxis.Title.Text = "时间";   // 横坐标lable
            myPane.YAxis.Title.Text = "煤气量";  // 纵坐标label
            //Set list
            PointPairList list = new PointPairList();

            //DataView dvList = new DataView(dataset.Tables[0]);
            //foreach (DataRowView dv in dvList)
            //{


            //    //double x = Convert.ToDouble(dv["TIME"]);
            //    //double x = (double)new XDate(2013, 6, 11, i, 0, 0);
            //    DateTime xx = DateTime.Parse(dv["TIME"].ToString());
            //    double x = (double)new XDate(xx);
            //    if (dv["FLOW"] is DBNull)
            //        dv["FLOW"] = 500;
            //    double y = Convert.ToDouble(dv["FLOW"]);
            //    list.Add(x, y);

            //}



            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve = myPane.AddCurve("煤气量", list, Color.Blue, SymbolType.Circle);

            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve.Line.Fill = new Fill(Color.White, Color.Red, 45F);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);
            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
            // Fill the pane background with a color gradient
            myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
            //Calculate the Axis Scale Ranges
            myPane.XAxis.Type = AxisType.Date;

            myPane.AxisChange();

            SetSize();
        }
Beispiel #23
0
        private void redrawGraph()
        {
            GraphPane myPane = zg1.GraphPane;

            myPane.YAxis.Scale.Max = (double)nudGrafiekYmax.Value;
            myPane.YAxis.Scale.Min = 0;

            //myPane.XAxis.Scale.Max = (double)nudGrafiekXmax.Value;
            //myPane.XAxis.Scale.Min = 0;

            myPane.AxisChange();
            zg1.Invalidate(); // Make sure the Graph gets redrawn
            zg1.Refresh();
        }
Beispiel #24
0
        public void WriteChart(string folder, string strategyName, string chartName, TradeStats stats, TransactionPairs daily)
        {
            if (daily.Count == 0)
            {
                return;
            }
            GraphPane myPane = new GraphPane(new RectangleF(0, 0, 640, 480),
                                             chartName, "Date", "Price");

            PointPairList ppl = new PointPairList();
            double        y   = stats.BeginningBalance;

            ppl.Add(daily[0].EntryTime.ToOADate(), y);
            for (int i = 0; i < daily.Count; i++)
            {
                y += daily.CalcProfitLoss(i);
                ppl.Add(daily[i].ExitTime.ToOADate(), y);
            }

            if (trace)
            {
                log.Trace("Chart start = " + ppl[0].Y + ", end = " + ppl[ppl.Count - 1].Y);
            }

            LineItem myCurve = myPane.AddCurve("Profit/Loss Equity Curve", ppl, Color.Blue, SymbolType.None);

            myCurve.Line.Fill = new Fill(Color.Blue);

            // pretty it up a little
            myPane.Chart.Fill                = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
            myPane.Fill                      = new Fill(Color.White);
            myPane.Border.IsVisible          = false;
            myPane.Title.FontSpec.Size       = 20.0f;
            myPane.XAxis.Type                = AxisType.DateAsOrdinal;
            myPane.XAxis.Title.FontSpec.Size = 14.0f;
            myPane.XAxis.Scale.FontSpec.Size = 14.0f;
            myPane.XAxis.Title.IsOmitMag     = true;

            myPane.YAxis.Title.FontSpec.Size = 14.0f;
            myPane.YAxis.Scale.FontSpec.Size = 14.0f;
//		    myPane.YAxis.Title.IsOmitMag = true;
            myPane.Legend.IsVisible = false;

            myPane.AxisChange();

            string pathName = folder + strategyName + @"\Images\" + chartName + ".gif";

            Directory.CreateDirectory(Path.GetDirectoryName(pathName));
            myPane.GetImage().Save(pathName, ImageFormat.Gif);
        }
Beispiel #25
0
    protected void PopulateSPAGauge(ZedGraphWeb z, Graphics g, MasterPane masterPane)
    {
        GraphPane myPane = masterPane[0];

        // Define the title
        myPane.Title.Text                 = (String)ViewState["territory"];
        myPane.Title.FontSpec.Size        = 34;
        myPane.Title.FontSpec.IsAntiAlias = false;
        myPane.Title.FontSpec.IsBold      = false;
        myPane.Title.FontSpec.FontColor   = Util.ColourTryParse("#989898");

        // Fill the pane and chart
        myPane.Fill                = new Fill(Util.ColourTryParse("#ff191919"), Util.ColourTryParse("#ff191919"), 45.0f);
        myPane.Chart.Fill          = new Fill(Util.ColourTryParse("#333333"), Util.ColourTryParse("#333333"), 45.0f); //Color.LightGray, Color.Black,
        myPane.Chart.Fill.RangeMax = 16;
        myPane.Chart.Fill.RangeMin = 0;

        // Don't show any axes for the gas gauge
        myPane.XAxis.IsVisible  = false;
        myPane.Y2Axis.IsVisible = false;
        myPane.YAxis.IsVisible  = false;

        //Define needles
        // Plot average RAG value by converting to percentage of 18 max then reverse value as chart plots backwards.
        float          plotVal = 100 - (((float)ViewState["avgRAG"] / (float)16) * 100);
        GasGaugeNeedle gg1     = new GasGaugeNeedle("Suspects", plotVal, Color.DimGray);

        gg1.NeedleWidth = 100;
        myPane.CurveList.Add(gg1);

        //Define all regions
        GasGaugeRegion ggr1 = new GasGaugeRegion("Green", 0.0f, 7.0f, Color.Green);
        GasGaugeRegion ggr2 = new GasGaugeRegion("Yellow", 7.0f, 63.0f, Color.Gold);
        GasGaugeRegion ggr3 = new GasGaugeRegion("Red", 63.0f, 100.0f, Color.Red);

        // Add the regions
        myPane.CurveList.Add(ggr1);
        myPane.CurveList.Add(ggr2);
        myPane.CurveList.Add(ggr3);
        myPane.Legend.IsVisible   = false;
        myPane.Chart.Border.Color = Color.DimGray;
        myPane.Margin.Left        = 34;
        myPane.Margin.Right       = 34;
        myPane.Margin.Bottom      = 30;
        myPane.Margin.Top         = 4;
        myPane.AxisChange();

        ViewState["myPane"] = myPane;
    }
Beispiel #26
0
        private void ZoomYAxis()
        {
            if (_msDataFileScanHelper.ScanProvider == null || _msDataFileScanHelper.ScanProvider.Transitions.Length == 0)
            {
                return;
            }

            var yScale = GraphPane.YAxis.Scale;

            yScale.MinAuto = yScale.MaxAuto = false;
            bool isSpectrum = !spectrumBtn.Visible || spectrumBtn.Checked;

            GraphPane.LockYAxisAtZero = isSpectrum;

            // Auto scale graph for spectrum view.
            if (isSpectrum)
            {
                yScale.Min = 0;
                yScale.Max = _maxIntensity * 1.1;
                if (magnifyBtn.Checked)
                {
                    yScale.MaxAuto = true;
                }
            }
            else if (!filterBtn.Checked && !magnifyBtn.Checked)
            {
                yScale.Min = 0;
                yScale.Max = _maxIonMobility * 1.1;
            }
            else
            {
                double minDriftTime, maxDriftTime;
                _msDataFileScanHelper.GetIonMobilityRange(out minDriftTime, out maxDriftTime, _msDataFileScanHelper.Source);
                if (minDriftTime > double.MinValue && maxDriftTime < double.MaxValue)
                {
                    double range = filterBtn.Checked
                        ? (maxDriftTime - minDriftTime) / 2
                        : (maxDriftTime - minDriftTime) * 2;
                    yScale.Min = minDriftTime - range;
                    yScale.Max = maxDriftTime + range;
                }
                else
                {
                    yScale.Min = 0;
                    yScale.Max = _maxIonMobility * 1.1;
                }
            }
            GraphPane.AxisChange();
        }
Beispiel #27
0
        public void Initialize(ZedGraphControl graph, double XMax, double XMin, double YMax, double YMin, string title = "Title", string XTitle = "", string YTitle = "")
        {
            GraphPane pane = graph.GraphPane;

            pane.Title.Text       = title;
            pane.XAxis.Scale.Max  = XMax;
            pane.XAxis.Scale.Min  = XMin;
            pane.XAxis.Title.Text = XTitle;
            pane.YAxis.Scale.Max  = YMax;
            pane.YAxis.Scale.Min  = XMin;
            pane.YAxis.Title.Text = YTitle;
            pane.AxisChange();
            graph.Invalidate();
            graph.Refresh();
        }
Beispiel #28
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = t;
            myPane.AxisChange();
            GraphPane myPane1 = zedGraphControl2.GraphPane;

            myPane1.XAxis.Scale.Min = 0;
            myPane1.XAxis.Scale.Max = t;
            myPane1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl2.Invalidate();
        }
Beispiel #29
0
        private void LoadForm(object sender, EventArgs e)
        {
            GraphPane pane = functionGraph.GraphPane;

            pane.Chart.Fill      = new Fill(Color.AntiqueWhite, Color.Honeydew, -45F);
            pane.Title.IsVisible = false;
            pane.YAxis.IsVisible = false;
            pane.YAxis.Scale.Max = 1d;
            pane.YAxis.Scale.Min = 0d;

            pane.Legend.IsVisible = false;

            pane.XAxis.Title.Text          = "Drag the points to position them and define the function";
            pane.XAxis.Title.FontSpec.Size = 15;
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.XAxis.Scale.IsVisible     = false;

            curve.Line.IsVisible              = false;
            curve.Symbol.Fill.Type            = FillType.Solid;
            functionGraph.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(
                delegate(ZedGraphControl graph, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
            {
                for (int i = 0; i < menuStrip.Items.Count; i++)
                {
                    string tag = (string)menuStrip.Items[i].Tag;
                    if (tag == "undo_all" || tag == "unzoom" || tag == "set_default")
                    {
                        menuStrip.Items.RemoveAt(i);
                        i--;
                    }
                }
            });

            functionGraph.IsEnableVEdit                = true;
            functionGraph.EditModifierKeys             = Keys.None;
            functionGraph.EditButtons                  = MouseButtons.Left;
            functionGraph.IsEnableZoom                 = false;
            functionGraph.IsEnableSelection            = false;
            functionGraph.IsEnableHPan                 = false;
            functionGraph.IsEnableVPan                 = false;
            functionGraph.GraphPane.CurveList.Capacity = 2;
            OnPointEdit(functionGraph, pane, curve, 0);
            pane.AxisChange();
            EnableControls(true);
            txtCycles.Text       = cycles.ToString();
            txtLearningRate.Text = learningRate.ToString();
            txtNeuronCount.Text  = neuronCount.ToString();
        }
Beispiel #30
0
        public void Reset()
        {
            GraphPane myPane = zg1.GraphPane;

            stopwatch = new Stopwatch(); stopwatch.Start();

            //Maak nieuw Lists aan voor de grafiek
            lists = new PointPairList[aantalGeselecteerdeKanalen];
            for (int i = 0; i < aantalGeselecteerdeKanalen; i++)
            {
                lists[i] = new PointPairList();
            }

            //Maak grafieklijnen aan
            myCurves = new LineItem[aantalGeselecteerdeKanalen];
            int tempGetalLists = 0;

            for (int i = 0; i < aantalKanalen; i++)
            {
                if (geselecteerdeKanalen[i])
                {
                    myCurves[tempGetalLists] = myPane.AddCurve(namenVanKanalen[i], lists[tempGetalLists], kleurLijst[i], SymbolType.None);
                    tempGetalLists++;
                }
            }

            nudGraphX.Value = sampleFrequentie * 10;

            //uiterlijk grafiek
            myPane.Title.Text       = TitelGrafiek;
            myPane.XAxis.Title.Text = LabelXas;
            myPane.YAxis.Title.Text = LabelYas;

            myPane.YAxis.Scale.Max = (double)nudGraphY.Value + 10;
            myPane.YAxis.Scale.Min = 0;

            myPane.XAxis.Scale.Max = (double)nudGraphX.Value;
            myPane.XAxis.Scale.Min = 0;

            myPane.AxisChange();

            //resetten van stuurvariabelen
            telAantalKeerTekenen = 0;

            //index getal bepalen
            aantalNieuweMeetPunten = sampleFrequentie / (1000 / timer1.Interval); //aantal samples dat er bij is gekomen
            redrawGraph();
        }
        /// <summary>
        /// Zoom a specified pane in or out according to the specified zoom fraction.
        /// </summary>
        /// <remarks>
        /// The zoom will occur on the <see cref="XAxis" />, <see cref="YAxis" />, and
        /// <see cref="Y2Axis" /> only if the corresponding flag, <see cref="IsEnableHZoom" /> or
        /// <see cref="IsEnableVZoom" />, is true.  Note that if there are multiple Y or Y2 axes, all of
        /// them will be zoomed.
        /// </remarks>
        /// <param name="pane">The <see cref="GraphPane" /> instance to be zoomed.</param>
        /// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than
        /// 1 to zoom out.  For example, 0.9 will zoom in such that the scale is 90% of what it was
        /// originally.</param>
        /// <param name="centerPt">The screen position about which the zoom will be centered.  This
        /// value is only used if <see paramref="isZoomOnCenter" /> is true.
        /// </param>
        /// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point
        /// <see paramref="centerPt" />, false to center on the <see cref="Chart.Rect" />.
        /// </param>
        /// <param name="isRefresh">true to force a refresh of the control, false to leave it unrefreshed</param>
        protected void ZoomPane(GraphPane pane, double zoomFraction, PointF centerPt,
                                bool isZoomOnCenter, bool isRefresh)
        {
            double x;
            double x2;
            double[] y;
            double[] y2;

            pane.ReverseTransform(centerPt, out x, out x2, out y, out y2);

            if (_isEnableHZoom)
            {
                ZoomScale(pane.XAxis, zoomFraction, x, isZoomOnCenter);
                ZoomScale(pane.X2Axis, zoomFraction, x2, isZoomOnCenter);
            }
            if (_isEnableVZoom)
            {
                for (int i = 0; i < pane.YAxisList.Count; i++)
                    ZoomScale(pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter);
                for (int i = 0; i < pane.Y2AxisList.Count; i++)
                    ZoomScale(pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter);
            }

            using (Graphics g = CreateGraphics())
            {
                pane.AxisChange(g);
                //g.Dispose();
            }

            SetScroll(hScrollBar1, pane.XAxis, _xScrollRange.Min, _xScrollRange.Max);
            SetScroll(vScrollBar1, pane.YAxis, _yScrollRangeList[0].Min,
                      _yScrollRangeList[0].Max);

            if (isRefresh)
                Refresh();
        }
        /// <summary>
        /// Renders the demo graph with one call.
        /// </summary>
        /// <param name="g">A <see cref="Graphics"/> object for which the drawing will be done.</param>
        /// <param name="pane">A reference to the <see cref="GraphPane"/></param>
        public static void RenderDemo(IGraphics g, GraphPane pane)
        {
            // Set the titles and axis labels
            pane.Title.Text = "Wacky Widget Company\nProduction Report";
            pane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            pane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y = {20, 10, 50, 25, 35, 75, 90, 40, 33, 50};
            // Use green, with circle symbols
            curve = pane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F);
            // Make it a smooth line
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = {150, 250, 400, 520, 780, 940};
            double[] y3 = {5.2, 49.0, 33.8, 88.57, 99.9, 36.8};
            // Use a red color with triangle symbols
            curve = pane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F);
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y4 = {30, 45, 53, 60, 75, 83, 84, 79, 71, 57};
            BarItem bar = pane.AddBar("Wheezy", x4, y4, Color.SteelBlue);
            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown);

            // Fourth curve is a bar
            double[] x2 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y2 = {10, 15, 17, 20, 25, 27, 29, 26, 24, 18};
            bar = pane.AddBar("Curly", x2, y2, Color.RoyalBlue);
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue);

            // Fill the pane background with a gradient
            pane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Fill the axis background with a gradient
            pane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245),
                                       Color.FromArgb(255, 255, 190), 90F);

            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            pane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            pane.BarSettings.Type = BarType.Stack;

            // Enable the X and Y axis grids
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            // Manually set the scale maximums according to user preference
            pane.XAxis.Scale.Max = 1200;
            pane.YAxis.Scale.Max = 120;

            // Add a text item to decorate the graph
            var text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F);
            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill(Color.White, Color.PowderBlue, 45F);
            text.FontSpec.StringAlignment = StringAlignment.Near;
            pane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            var arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            pane.GraphObjList.Add(arrow);

            // Add a another text item to to point out a graph feature
            text = new TextObj("Upgrade", 700F, 50.0F);
            // rotate the text 90 degrees
            text.FontSpec.Angle = 90;
            // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            // Disable the border and background fill options for the text
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            pane.GraphObjList.Add(arrow);

            // Add a text "Confidential" stamp to the graph
            text = new TextObj("Confidential", 0.85F, -0.03F);
            // use ChartFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.ChartFraction;
            // rotate the text 15 degrees
            text.FontSpec.Angle = 15.0F;
            // Text will be red, bold, and 16 point
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            // Disable the border and background fill options for the text
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;
            // Align the text such the the Left-Bottom corner is at the specified coordinates
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            pane.GraphObjList.Add(text);

            // Add a BoxObj to show a colored band behind the graph data
            var box = new BoxObj(0, 110, 1200, 10,
                                 Color.Empty, Color.FromArgb(225, 245, 225));
            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            // Align the left-top of the box to (0, 110)
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            // place the box behind the axis items, so the grid is drawn on top of it
            box.ZOrder = ZOrder.D_BehindAxis;
            pane.GraphObjList.Add(box);

            // Add some text inside the above box to indicate "Peak Range"
            var myText = new TextObj("Peak Range", 1170, 105);
            myText.Location.CoordinateFrame = CoordType.AxisXYScale;
            myText.Location.AlignH = AlignH.Right;
            myText.Location.AlignV = AlignV.Center;
            myText.FontSpec.IsItalic = true;
            myText.FontSpec.IsBold = false;
            myText.FontSpec.Fill.IsVisible = false;
            myText.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add(myText);

            pane.AxisChange(g);
        }
Beispiel #33
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZeeGraphControl()
        {
            _dragPane = null;
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.ResizeRedraw, true);

            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            _resourceManager = new ResourceManager("ZeeGraph.ZeeGraphLocale",
                                                   Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle(0, 0, Size.Width, Size.Height);
            _masterPane = new MasterPane("", rect);
            _masterPane.Margin.All = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = _resourceManager.GetString("title_def");
            string xStr = _resourceManager.GetString("x_title_def");
            string yStr = _resourceManager.GetString("y_title_def");

            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);
            using (Graphics g = CreateGraphics())
            {
                graphPane.AxisChange(g);
                //g.Dispose();
            }
            _masterPane.Add(graphPane);

            hScrollBar1.Minimum = 0;
            hScrollBar1.Maximum = 100;
            hScrollBar1.Value = 0;

            vScrollBar1.Minimum = 0;
            vScrollBar1.Maximum = 100;
            vScrollBar1.Value = 0;

            _xScrollRange = new ScrollRange(true);
            _yScrollRangeList = new ScrollRangeList();
            _y2ScrollRangeList = new ScrollRangeList();

            _yScrollRangeList.Add(new ScrollRange(true));
            _y2ScrollRangeList.Add(new ScrollRange(false));

            _zoomState = null;
            _zoomStateStack = new ZoomStateStack();
        }