예제 #1
0
    void Start()
    {
        Application.targetFrameRate = 120;
        joystick  = FindObjectOfType <Joystick>();
        joybutton = FindObjectOfType <JoyButton>();
        bar       = NetworkBehaviour.FindObjectOfType <Bar>();
        arrow     = NetworkBehaviour.FindObjectOfType <ArrowObj>();
        //press = NetworkBehaviour.FindObjectOfType<Press>();

        moveSpeed = boatstatus.Player1.movementspeed * 3;
        //picIndex = PlayerPrefs.GetInt("BoatPic");
        //currentSprite = sprite;
        //boatSprite = currentSprite.GetComponentInChildren<SpriteRenderer>().sprite;


        if (bar != null)
        {
            bar.gameObject.SetActive(false);
        }
        if (arrow != null)
        {
            arrow.gameObject.SetActive(false);
        }

        /*if(press != null)
         * {
         *  press.gameObject.SetActive(false);
         * }*/
        if (moveSpeed == 0)
        {
            moveSpeed = 10;
        }
    }
예제 #2
0
        private void InitGraph(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            myPane.Title.Text       = "Complex Impedance";
            myPane.XAxis.Title.Text = "Real";
            myPane.YAxis.Title.Text = "Imaginary";

            //myPane.XAxis.MajorGrid.IsVisible = true;
            //myPane.YAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.Min       = -15;
            myPane.XAxis.Scale.Max       = 15;
            myPane.XAxis.Scale.MajorStep = 5;

            myPane.YAxis.Scale.Min       = -15;
            myPane.YAxis.Scale.Max       = 15;
            myPane.YAxis.Scale.MajorStep = 5;

            myPane.YAxis.MajorGrid.IsZeroLine = true;
            myPane.XAxis.MajorGrid.IsZeroLine = true;

            ArrowObj arrow = new ArrowObj(Color.Red, 30, 0.0, 0.0, 0.0, 0.0);

            arrow.Line.Width = 2;
            myPane.GraphObjList.Add(arrow);
        }
예제 #3
0
        public void updateGraph(ZedGraphControl zgc, double x, double y)
        {
            GraphPane myPane = zgc.GraphPane;
            ArrowObj  arrow  = new ArrowObj(Color.Red, 30, 0.0, 0.0, x, y);

            arrow.Line.Width = 2;
            myPane.GraphObjList.RemoveAt(0);
            myPane.GraphObjList.Add(arrow);
            zgc.Refresh();
        }
예제 #4
0
        /// <summary>
        /// Draw traceability on the graph
        /// </summary>
        /// <param name="_zgc"></param>
        /// <param name="_pplist"></param>
        /// <param name="_ran_running"></param>
        public void TraceabilityGraph(ZedGraphControl _zgc, PointPairList _pplist, bool _ran_running)
        {
            if (this.myPane.GraphObjList != null)
            {
                this.myPane.GraphObjList.Clear();
            }

            if (_zgc.GraphPane.CurveList != null)
            {
                _zgc.GraphPane.CurveList.Clear();
            }

            // add arrow
            ArrowObj arrow_gps = new ArrowObj(Color.Blue, 30, _pplist[0].X, _pplist[0].Y, _pplist[1].X, _pplist[1].Y);

            this.myPane.GraphObjList.Add(arrow_gps);
            PointPairList arrow_pt = new PointPairList();

            arrow_pt.Add(_pplist[0]);
            arrow_pt.Add(_pplist[1]);
            this.myPane.AddCurve(null, arrow_pt, Color.Blue, SymbolType.None);

            // add body line
            PointPairList body_line = new PointPairList();

            body_line.Add(_pplist[2]);
            body_line.Add(_pplist[3]);
            this.myPane.AddCurve(null, body_line, Color.Orange, SymbolType.None);

            // add path tracking
            this.trace_pplist.Add(_pplist[0]);
            this.myPane.AddCurve(null, this.trace_pplist, Color.Red, SymbolType.None);

            // add extracted ransac line
            if (_ran_running == true)
            {
                PointPairList ransac_line = new PointPairList();
                ransac_line.Add(_pplist[4]);
                ransac_line.Add(_pplist[5]);
                this.myPane.AddCurve(null, ransac_line, Color.BlueViolet, SymbolType.None);
            }

            // tell zedgraph to refigure the axes since the data have changed
            _zgc.AxisChange();

            // force redraw
            _zgc.Invalidate();
        }
예제 #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            double x = DateTime.Now.ToOADate();

            if (nowArrow != null && geoIntraDay.GraphPane.GraphObjList.Contains(nowArrow))
            {
                geoIntraDay.GraphPane.GraphObjList.Remove(nowArrow);
            }

            nowArrow             = new ArrowObj(x, geoIntraDay.GraphPane.YAxis.Scale.Min, x, geoIntraDay.GraphPane.YAxis.Scale.Max);
            nowArrow.IsArrowHead = false;
            nowArrow.Line.Style  = System.Drawing.Drawing2D.DashStyle.Dash;

            geoIntraDay.GraphPane.GraphObjList.Add(nowArrow);

            geoIntraDay.Invalidate();
        }
예제 #6
0
        private void markPlanetEvent()
        {
            List <IPlanetEvent> events = Ephemeris.Geocentric[intradaySince, intradayUntil];

            IPlanetEvent lunarAspect = null;
            double       x;

            foreach (PlanetId id in Ephemeris.Geocentric.Luminaries)
            {
                if (id == PlanetId.SE_MOON || id > PlanetId.SE_FICT_OFFSET)
                {
                    continue;
                }

                lunarAspect = Ephemeris.Geocentric.ExactAspectEventOf(PlanetId.SE_MOON, id, intradaySince);

                if (lunarAspect != null && lunarAspect.When >= intradaySince && lunarAspect.When <= intradayUntil)
                {
                    events.Add(lunarAspect);
                }
            }

            events.Sort();

            foreach (IPlanetEvent evt in events)
            {
                x = evt.When.LocalDateTime.ToOADate();
                ArrowObj newArrow = new ArrowObj(x, 0, x, geoIntraDay.GraphPane.YAxis.Scale.Max / 10);
                newArrow.Line.Style  = System.Drawing.Drawing2D.DashStyle.Dot;
                newArrow.IsArrowHead = false;
                geoIntraDay.GraphPane.GraphObjList.Add(newArrow);

                string description = evt.ShortDescription;

                TextObj text = new TextObj(description, x, 0);
                text.FontSpec.Size             = 6;
                text.FontSpec.Angle            = 45;
                text.FontSpec.Family           = "AstroSymbols";
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.Location.AlignH           = AlignH.Right;
                text.Location.AlignV           = AlignV.Center;
                geoIntraDay.GraphPane.GraphObjList.Add(text);
            }
        }
예제 #7
0
    public override void OnStartClient()
    {
        base.OnStartClient();
        if (netId == 11)
        {
            gameObject.name = "Player 1";
        }
        if (netId == 12)
        {
            gameObject.name = "Player 2";
        }
        if (netId == 13)
        {
            gameObject.name = "Player 3";
        }
        if (netId == 14)
        {
            gameObject.name = "Player 4";
        }
        bars    = Resources.FindObjectsOfTypeAll <Bar>();
        arrows  = Resources.FindObjectsOfTypeAll <ArrowObj>();
        presses = Resources.FindObjectsOfTypeAll <Press>();
        if (bars.Length > 0)
        {
            bar = bars[0];
        }
        if (arrows.Length > 0)
        {
            arrow = arrows[0];
        }

        /*if (presses.Length > 0)
         * {
         *  press = presses[0];
         * }*/
    }
예제 #8
0
        public override void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g,
                                                    MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
            {
                return;
            }

            // Give priority to showing the best peak text object above all other annotations
            if (DragInfo != null || (!HideBest && TransitionChromInfo != null) || CurveAnnotation != null)
            {
                // Show text and arrow for the best peak
                double intensityBest = 0;
                if (_bestPeakTimeIndex != -1)
                {
                    ScaledRetentionTime timeBest = new ScaledRetentionTime(_measuredTimes[_bestPeakTimeIndex], _displayTimes[_bestPeakTimeIndex]);
                    float xBest = graphPane.XAxis.Scale.Transform(timeBest.DisplayTime);
                    intensityBest = _intensities[_bestPeakTimeIndex];
                    float yBest = graphPane.YAxis.Scale.Transform(intensityBest);

                    if (GraphChromatogram.ShowRT != ShowRTChrom.none || DragInfo != null)
                    {
                        // Best peak gets its own label to avoid curve overlap detection
                        double intensityLabel = graphPane.YAxis.Scale.ReverseTransform(yBest - 5);
                        float? massError      = Settings.Default.ShowMassError && TransitionChromInfo != null
                                               ? TransitionChromInfo.MassError
                                               : null;
                        double dotProduct = _dotProducts != null ? _bestProduct : 0;

                        TextObj text;
                        if (CurveAnnotation != null)
                        {
                            // Darken peptide name a little so light colors stand out against the white background.
                            var color = FontSpec.FontColor;
                            if (!GraphInfo.IsSelected)
                            {
                                color = Color.FromArgb(color.R * 7 / 10, color.G * 7 / 10, color.B * 7 / 10);
                            }
                            var fontSpec = new FontSpec(FontSpec)
                            {
                                FontColor = color, Angle = 90
                            };
                            if (GraphInfo.IsSelected)
                            {
                                fontSpec = new FontSpec(fontSpec)
                                {
                                    IsBold = true, Size = fontSpec.Size + 2, IsAntiAlias = true
                                }
                            }
                            ;

                            // Display peptide name label using vertical text.
                            text = new TextObj(CurveAnnotation, timeBest.DisplayTime, intensityLabel,
                                               CoordType.AxisXYScale, AlignH.Left, AlignV.Center)
                            {
                                ZOrder = ZOrder.A_InFront,
                                IsClippedToChartRect = true,
                                FontSpec             = fontSpec,
                                Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest),
                            };
                        }
                        else
                        {
                            string label = FormatTimeLabel(timeBest.DisplayTime, massError, dotProduct);

                            text = new TextObj(label, timeBest.DisplayTime, intensityLabel,
                                               CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom)
                            {
                                ZOrder = ZOrder.A_InFront,
                                IsClippedToChartRect = true,
                                FontSpec             = FontSpec,
                                Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest),
                            };
                        }

                        annotations.Add(text);
                    }

                    // If showing multiple peptides, skip the best peak arrow indicator.
                    if (CurveAnnotation == null)
                    {
                        // Show the best peak arrow indicator
                        double timeArrow      = graphPane.XAxis.Scale.ReverseTransform(xBest - 4);
                        double intensityArrow = graphPane.YAxis.Scale.ReverseTransform(yBest - 2);

                        ArrowObj arrow = new ArrowObj(COLOR_BEST_PEAK, 12f,
                                                      timeArrow, intensityArrow, timeArrow, intensityArrow)
                        {
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            IsArrowHead          = true,
                            IsClippedToChartRect = true,
                            ZOrder = ZOrder.A_InFront
                        };
                        annotations.Add(arrow);
                    }
                }

                // Show the best peak boundary lines
                if (CurveAnnotation == null)
                {
                    double startTime = 0, endTime = 0;
                    if (DragInfo != null)
                    {
                        startTime = DragInfo.StartTime.MeasuredTime;
                        endTime   = DragInfo.EndTime.MeasuredTime;
                    }
                    else if (TransitionChromInfo != null)
                    {
                        var tranPeakInfo = TransitionChromInfo;
                        startTime = tranPeakInfo.StartRetentionTime;
                        endTime   = tranPeakInfo.EndRetentionTime;
                    }
                    AddPeakBoundaries(graphPane, annotations, true,
                                      ScaleRetentionTime(startTime), ScaleRetentionTime(endTime), intensityBest);
                }
                if (Chromatogram.BestPeakIndex >= 0)
                {
                    // Only shade peak when user modified. Otherwise, shading can be added when an entire
                    // precursor was force integrated because of another precursor (e.g. heavy) since that
                    // leads to an empty peak, which will not match the best peak.
                    if (Settings.Default.ShowOriginalPeak && TransitionChromInfo != null && TransitionChromInfo.IsUserModified)
                    {
                        var bestPeak = Chromatogram.GetPeak(Chromatogram.BestPeakIndex);
                        if (bestPeak.StartTime != TransitionChromInfo.StartRetentionTime ||
                            bestPeak.EndTime != TransitionChromInfo.EndRetentionTime)
                        {
                            AddOriginalPeakAnnotation(bestPeak, annotations, graphPane);
                        }
                    }
                }
            }
            if (_displayRawTimes.HasValue)
            {
                AddPeakRawTimes(graphPane, annotations,
                                ScaleRetentionTime(_displayRawTimes.Value.StartBound),
                                ScaleRetentionTime(_displayRawTimes.Value.EndBound),
                                Chromatogram);
            }
        }
예제 #9
0
        private void DrawGraph()
        {
            GraphPane pane = zedGraph.GraphPane;

            pane.CurveList.Clear();

            PointPairList list = new PointPairList();

            double xmin = -50;
            double xmax = 50;

            // Заполняем список точек
            for (double x = xmin; x <= xmax; x += 0.01)
            {
                list.Add(x, f(x));
            }
            LineItem myCurve = pane.AddCurve("Sinc", list, Color.Blue, SymbolType.None);

            zedGraph.AxisChange();

            // !!!
            // Линию рисуем после обновления осей с помощью AxisChange (),
            // так как мы будем использовать значения
            // Нарисуем горизонтальную пунктирную линию от левого края до правого на уровне y = 0.5
            double  level = 0.5;
            LineObj line  = new LineObj(pane.XAxis.Scale.Min, level, pane.XAxis.Scale.Max, level);

            // Стиль линии - пунктирная
            line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;

            // Добавим линию в список отображаемых объектов
            pane.GraphObjList.Add(line);

            // Нарисуем стрелку, указыающую на максимум функции
            // Координаты точки, куда указывает стрелка
            // Координаты привязаны к осям
            double xend = 0.0;
            double yend = f(0);

            // Координаты точки начала стрелки
            double xstart = xend + 5.0;
            double ystart = yend + 0.1;

            // Рисование стрелки с текстом
            // Создадим стрелку
            ArrowObj arrow = new ArrowObj(xstart, ystart, xend, yend);

            // Добавим стрелку в список отображаемых объектов
            pane.GraphObjList.Add(arrow);

            // Напишем текст около начала стрелки
            // Координаты привязаны к осям
            TextObj text = new TextObj("Max", xstart, ystart);

            // Отключим рамку вокруг текста
            text.FontSpec.Border.IsVisible = false;

            // Добавим текст в список отображаемых объектов
            pane.GraphObjList.Add(text);

            // Обновляем график
            zedGraph.Invalidate();
        }
예제 #10
0
        public ComboDemo() : base("A demo that combines bar charts with line graphs, curve filling, text items, etc.",
                                  "Combo Demo", DemoType.General, DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "Wacky Widget Company\nProduction Report";
            myPane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            myPane.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            = myPane.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            = myPane.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 = myPane.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 = myPane.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
            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Fill the axis background with a gradient
            myPane.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
            myPane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            myPane.BarSettings.Type = BarType.Stack;

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

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

            // Add a text item to decorate the graph
            TextObj 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;
            myPane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);

            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            myPane.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;
            myPane.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;
            myPane.GraphObjList.Add(arrow);

            // Add a text "Confidential" stamp to the graph
            text = new TextObj("Confidential", 0.85F, -0.03F);
            // use AxisFraction 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;
            myPane.GraphObjList.Add(text);

            // Add a BoxObj to show a colored band behind the graph data
            BoxObj 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.F_BehindGrid;
            myPane.GraphObjList.Add(box);

            // Add some text inside the above box to indicate "Peak Range"
            TextObj 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;
            myPane.GraphObjList.Add(myText);

            base.ZedGraphControl.AxisChange();
        }
예제 #11
0
        public void polowienia()
        {
            //p1 i p2 to przedziały ( początkowy i końcowy )
            Number p1 = new Number(1.0, 2.0);
            Number p2 = new Number(3.0, 2.0);
            //
            Random rnd     = new Random();
            Number epsilon = new Number(rnd.Next(2, 7), 100.0);

            polowienieBox.AppendText("epsilon wynosi " + epsilon.value + "\nkolejne podziały: \n");

            Function f_p1 = new Function(p1.value);
            Function f_p2 = new Function(p2.value);

            if (f_p1.val * f_p2.val < 0.0)
            {
                PointPairList lista  = new PointPairList();
                Random        random = new Random();
                for (int i = 0; i < 15; i++)
                {
                    // dodawanie przedzialow na wykresie
                    lista.Add(f_p1.arg, 0); lista.Add(f_p1.arg, -20 + i * 2.5); lista.Add(f_p2.arg, -20 + i * 2.5); lista.Add(f_p2.arg, 0);
                    System.Threading.Thread.Sleep(25);
                    LineItem myCurve = zedGraphControl1.GraphPane.AddCurve("",
                                                                           lista, Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)), SymbolType.None);
                    myCurve.Line.Width = 1.0f;
                    zedGraphControl1.AxisChange();
                    zedGraphControl1.Invalidate();
                    zedGraphControl1.Refresh();
                    //

                    polowienieBox.AppendText(i + 1 + ". " + f_p1.arg + " - " + f_p2.arg + "\n");
                    Function srodek = new Function((f_p1.arg + f_p2.arg) / 2.0);
                    if (srodek.modulus() < epsilon.value)
                    {
                        polowienieBox.AppendText("\n\nMiejsce zerowe znalezione!\nPrzybliżone miejsce zerowe (" + srodek.val.ToString("0.###") + " < " + epsilon.value + ") znaleziono w x = " + srodek.arg.ToString("#.###"));
                        //dodawanie strzalki na wykresie
                        ArrowObj strzalka = new ArrowObj(Color.Black, 10.0f, srodek.arg, srodek.val + 45, srodek.arg, srodek.val + 5);
                        zedGraphControl1.GraphPane.GraphObjList.Add(strzalka);
                        zedGraphControl1.Refresh();
                        break;
                    }
                    else
                    {
                        if (f_p1.val * srodek.val < 0)
                        {
                            f_p2 = new Function(srodek.arg);
                        }
                        else
                        {
                            f_p1 = new Function(srodek.arg);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Kryczyny błąd",
                                "wartosci funkcji dla tego przedziału są tego samego znaku - algorytm nie może kontynuować",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #12
0
 /// <summary>
 /// Copy the properties of this <see cref="ZedGraphWebArrowObj"/> to the specified
 /// <see cref="ZedGraph.ArrowObj"/> object.
 /// </summary>
 /// <param name="item">The destination <see cref="ZedGraph.ArrowObj"/> object</param>
 internal void CopyTo( ArrowObj item )
 {
     base.CopyTo( item );
     item.Size = this.Size;
     item.Line.Width = this.PenWidth;
     item.Line.Color = this.Color;
     item.IsArrowHead = this.IsArrowHead;
 }
예제 #13
0
        private void DisplayCalibrationCurve()
        {
            Text = TabText = _originalFormTitle;
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type = options.LogYAxis ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.XAxis.Type = options.LogXAxis ? AxisType.Log : AxisType.Linear;
            bool logPlot = options.LogXAxis || options.LogYAxis;

            zedGraphControl.GraphPane.Legend.IsVisible = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            FiguresOfMerit   = FiguresOfMerit.EMPTY;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide;
            PeptideGroupDocNode peptideGroup;

            if (!TryGetSelectedPeptide(out peptideGroup, out peptide))
            {
                zedGraphControl.GraphPane.Title.Text =
                    ModeUIAwareStringFormat(QuantificationStrings
                                            .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve);
                return;
            }
            if (-1 == document.Children.IndexOf(peptideGroup))
            {
                zedGraphControl.GraphPane.Title.Text = ModeUIAwareStringFormat(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_peptide_is_no_longer_part_of_the_Skyline_document_);
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            if (curveFitter.IsEnableSingleBatch && Settings.Default.CalibrationCurveOptions.SingleBatch)
            {
                curveFitter.SingleBatchReplicateIndex = _skylineWindow.SelectedResultsIndex;
            }

            Text = TabText = GetFormTitle(curveFitter);
            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (!(peptideQuantifier.NormalizationMethod is NormalizationMethod.RatioToLabel))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        ModeUIAwareStringFormat(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_);
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            ModeUIAwareStringFormat(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            FiguresOfMerit   = curveFitter.GetFiguresOfMerit(CalibrationCurve);
            double minX = double.MaxValue, maxX = double.MinValue;
            double minY = double.MaxValue;

            _scatterPlots = new CurveList();

            IEnumerable <SampleType> sampleTypes = SampleType.ListSampleTypes()
                                                   .Where(Options.DisplaySampleType);

            foreach (var sampleType in sampleTypes)
            {
                PointPairList pointPairList         = new PointPairList();
                PointPairList pointPairListExcluded = new PointPairList();
                foreach (var standardIdentifier in curveFitter.EnumerateCalibrationPoints())
                {
                    if (!Equals(sampleType, curveFitter.GetSampleType(standardIdentifier)))
                    {
                        continue;
                    }

                    double?y           = curveFitter.GetYValue(standardIdentifier);
                    double?xCalculated = curveFitter.GetCalculatedXValue(CalibrationCurve, standardIdentifier);
                    double?x           = curveFitter.GetSpecifiedXValue(standardIdentifier)
                                         ?? xCalculated;
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = standardIdentifier
                        };
                        if (sampleType.AllowExclude && null == standardIdentifier.LabelType && peptide.IsExcludeFromCalibration(standardIdentifier.ReplicateIndex))
                        {
                            pointPairListExcluded.Add(point);
                        }
                        else
                        {
                            pointPairList.Add(point);
                        }
                        if (!IsNumber(x) || !IsNumber(y))
                        {
                            continue;
                        }
                        if (!logPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        if (!logPlot || y.Value > 0)
                        {
                            minY = Math.Min(minY, y.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                        if (IsNumber(xCalculated))
                        {
                            maxX = Math.Max(maxX, xCalculated.Value);
                            if (!logPlot || xCalculated.Value > 0)
                            {
                                minX = Math.Min(minX, xCalculated.Value);
                            }
                        }
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
                if (pointPairListExcluded.Any())
                {
                    string curveLabel = pointPairList.Any() ? null : sampleType.ToString();
                    var    lineItem   = zedGraphControl.GraphPane.AddCurve(curveLabel, pointPairListExcluded,
                                                                           sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines    = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!logPlot && regressionFit != RegressionFit.LINEAR_IN_LOG_SPACE)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    double[] xValues;
                    if (CalibrationCurve.TurningPoint.HasValue)
                    {
                        xValues = new[] { minX, CalibrationCurve.TurningPoint.Value, maxX };
                    }
                    else
                    {
                        xValues = new[] { minX, maxX };
                    }
                    Array.Sort(xValues);
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, xValues,
                                                                       interpolatedLinePointCount, logPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(CalibrationCurve.RSquaredDisplayText(CalibrationCurve.RSquared.Value));
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format(@"{0}: {1}",
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
                if (options.ShowFiguresOfMerit)
                {
                    string strFiguresOfMerit = FiguresOfMerit.ToString();
                    if (!string.IsNullOrEmpty(strFiguresOfMerit))
                    {
                        labelLines.Add(strFiguresOfMerit);
                    }
                }
            }

            CalibrationPoint?selectionIdentifier = null;

            if (options.ShowSelection)
            {
                if (curveFitter.IsotopologResponseCurve)
                {
                    var labelType = (_skylineWindow.SequenceTree.SelectedNode as SrmTreeNode)
                                    ?.GetNodeOfType <TransitionGroupTreeNode>()?.DocNode.LabelType;
                    if (labelType != null)
                    {
                        selectionIdentifier =
                            new CalibrationPoint(_skylineWindow.SelectedResultsIndex,
                                                 labelType);
                    }
                }
                else
                {
                    selectionIdentifier =
                        new CalibrationPoint(_skylineWindow.SelectedResultsIndex, null);
                }
            }
            if (selectionIdentifier.HasValue)
            {
                double?ySelected = curveFitter.GetYValue(selectionIdentifier.Value);
                if (IsNumber(ySelected))
                {
                    double?     xSelected         = curveFitter.GetCalculatedXValue(CalibrationCurve, selectionIdentifier.Value);
                    var         selectedLineColor = Color.FromArgb(128, GraphSummary.ColorSelected);
                    const float selectedLineWidth = 2;
                    double?     xSpecified        = curveFitter.GetSpecifiedXValue(selectionIdentifier.Value);
                    if (IsNumber(xSelected))
                    {
                        ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                      ySelected.Value)
                        {
                            Line = { Color = GraphSummary.ColorSelected }
                        };
                        zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                        var verticalLine = new LineObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                       options.LogYAxis ? minY / 10 : 0)
                        {
                            Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            ZOrder               = ZOrder.E_BehindCurves,
                            IsClippedToChartRect = true
                        };
                        zedGraphControl.GraphPane.GraphObjList.Add(verticalLine);
                        if (IsNumber(xSpecified))
                        {
                            var horizontalLine = new LineObj(xSpecified.Value, ySelected.Value, xSelected.Value,
                                                             ySelected.Value)
                            {
                                Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                                Location             = { CoordinateFrame = CoordType.AxisXYScale },
                                ZOrder               = ZOrder.E_BehindCurves,
                                IsClippedToChartRect = true
                            };
                            zedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                        }
                    }
                    else
                    {
                        // We were not able to map the observed intensity back to the calibration curve, but we still want to
                        // indicate where the currently selected point is.
                        if (IsNumber(xSpecified))
                        {
                            // If the point has a specified concentration, then use that.
                            ArrowObj arrow = new ArrowObj(xSpecified.Value, ySelected.Value, xSpecified.Value,
                                                          ySelected.Value)
                            {
                                Line = { Color = GraphSummary.ColorSelected }
                            };
                            zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                        }
                        else
                        {
                            // Otherwise, draw a horizontal line at the appropriate y-value.
                            var horizontalLine = new LineObj(minX, ySelected.Value, maxX, ySelected.Value)
                            {
                                Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                                Location             = { CoordinateFrame = CoordType.AxisXYScale },
                                IsClippedToChartRect = true,
                            };
                            ZedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                        }
                    }
                }

                QuantificationResult quantificationResult = null;
                double?calculatedConcentration;
                if (curveFitter.IsotopologResponseCurve)
                {
                    calculatedConcentration =
                        curveFitter.GetCalculatedConcentration(CalibrationCurve, selectionIdentifier.Value);
                }
                else
                {
                    quantificationResult    = curveFitter.GetPeptideQuantificationResult(selectionIdentifier.Value.ReplicateIndex);
                    calculatedConcentration = quantificationResult?.CalculatedConcentration;
                }
                if (calculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format(@"{0} = {1}",
                                                 QuantificationStrings.Calculated_Concentration,
                                                 QuantificationResult.FormatCalculatedConcentration(calculatedConcentration.Value,
                                                                                                    curveFitter.QuantificationSettings.Units)));
                }
                else if (quantificationResult != null && !quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (Options.ShowFiguresOfMerit)
            {
                if (IsNumber(FiguresOfMerit.LimitOfDetection))
                {
                    var lodLine = new LineObj(Color.DarkMagenta, FiguresOfMerit.LimitOfDetection.Value, 0,
                                              FiguresOfMerit.LimitOfDetection.Value, 1)
                    {
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(lodLine);
                }
                if (IsNumber(FiguresOfMerit.LimitOfQuantification))
                {
                    var loqLine = new LineObj(Color.DarkCyan, FiguresOfMerit.LimitOfQuantification.Value, 0,
                                              FiguresOfMerit.LimitOfQuantification.Value, 1)
                    {
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(loqLine);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                double adc_val, temp_adc;
                serialRead = serialPort1.ReadExisting();
                string prevRead = "1.00";

                MethodInvoker setAll = delegate
                {
                    if (serialRead.Contains(":"))
                    {
                        SysDia = Regex.Split(serialRead, @":|\n");
                        richTextBox1.ReadOnly    = false;
                        MainForm.serialDiastolic = SysDia[1];
                        MainForm.serialSystolic  = SysDia[0];
                        textBox1.Text            = MainForm.serialSystolic;
                        textBox2.Text            = MainForm.serialDiastolic;
                        MainForm.comments        = richTextBox1.Text;
                        MainForm.time            = DateTime.Now.ToLongTimeString();
                        MainForm.date            = DateTime.Now.ToShortDateString();
                        SysDia     = null;
                        serialRead = null;
                        if (textBox1.Text == "" || textBox1.Text == null || textBox2.Text == "" || textBox2.Text == null)
                        {
                            MessageBox.Show("Invalid Data");
                        }
                        else
                        {
                            if (forPointAnalysis != null)
                            {
                                for (int i = 0; i < forPointAnalysis.Count; i++)
                                {
                                    if (forPointAnalysis[i].Y > 0 && forPointAnalysis[i].Y < 1.8 && count2 < 10)
                                    {
                                        count++;
                                    }
                                    else
                                    {
                                        if (count > 85)
                                        {
                                            count      = 0;
                                            count2     = 0;
                                            sysPointX  = 0;
                                            sysPointY  = 0;
                                            diasPointX = 0;
                                            diasPointY = 0;
                                        }
                                        if (forPointAnalysis[i].Y >= 1.8)
                                        {
                                            count2++;
                                            if (count2 > 20)
                                            {
                                                count = 0;
                                            }
                                            if ((forPointAnalysis[i].Y / MAP > 0.75) && sysPointX == 0 && sysPointY == 0)
                                            {
                                                sysPointX = forPointAnalysis[i].X;
                                                sysPointY = forPointAnalysis[i].Y;
                                            }
                                            if ((forPointAnalysis[i].Y / MAP > 0.9) && sysPointX != 0 && sysPointY != 0)
                                            {
                                                diasPointX = forPointAnalysis[i].X;
                                                diasPointY = forPointAnalysis[i].Y;
                                            }
                                        }
                                    }
                                }
                                TextObj text = new TextObj("Systolic", sysPointX, 3.8);
                                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;
                                myPane.GraphObjList.Add(text);
                                ArrowObj arrow = new ArrowObj(Color.Black, 1.9F, sysPointX, 3.8, sysPointX, sysPointY);
                                arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
                                myPane.GraphObjList.Add(arrow);
                                zedGraphControl1.AxisChange();

                                TextObj text2 = new TextObj("Diastolic", diasPointX, 3.8);
                                text2.Location.AlignH          = AlignH.Center;
                                text2.Location.AlignV          = AlignV.Bottom;
                                text2.FontSpec.Fill            = new Fill(Color.White, Color.PowderBlue, 45F);
                                text2.FontSpec.StringAlignment = StringAlignment.Near;
                                myPane.GraphObjList.Add(text2);
                                ArrowObj arrow2 = new ArrowObj(Color.Black, 1.9F, diasPointX, 3.8, diasPointX, diasPointY);
                                arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
                                myPane.GraphObjList.Add(arrow2);
                                zedGraphControl1.AxisChange();
                                zedGraphControl1.Refresh();
                            }
                        }
                    }
                    if (MainForm.serialDiastolic != null && MainForm.serialDiastolic != null && MainForm.serialSystolic != "" && MainForm.serialDiastolic != "")
                    {
                        try
                        {
                            if (Convert.ToInt32(MainForm.serialSystolic) > 139 && Convert.ToInt32(MainForm.serialSystolic) <= 159 || Convert.ToInt32(MainForm.serialDiastolic) <= 99 && Convert.ToInt32(MainForm.serialDiastolic) > 89)
                            {
                                textBox3.Text   = "Stage1 Hypertension";
                                MainForm.status = textBox3.Text;
                            }
                            else if (Convert.ToInt32(MainForm.serialSystolic) > 159 && Convert.ToInt32(MainForm.serialSystolic) <= 179 || Convert.ToInt32(MainForm.serialDiastolic) > 99 && Convert.ToInt32(MainForm.serialDiastolic) <= 109)
                            {
                                textBox3.Text   = "Stage2 Hypertension";
                                MainForm.status = textBox3.Text;
                            }
                            else if (Convert.ToInt32(MainForm.serialSystolic) > 179 && Convert.ToInt32(MainForm.serialSystolic) <= 209 || Convert.ToInt32(MainForm.serialDiastolic) > 109 && Convert.ToInt32(MainForm.serialDiastolic) <= 119)
                            {
                                textBox3.Text   = "Stage3 Hypertension";
                                MainForm.status = textBox3.Text;
                            }
                            else if (Convert.ToInt32(MainForm.serialSystolic) < 91 || Convert.ToInt32(MainForm.serialDiastolic) < 61)
                            {
                                textBox3.Text   = "LowBlood";
                                MainForm.status = textBox3.Text;
                            }
                            else if (Convert.ToInt32(MainForm.serialSystolic) > 91 && Convert.ToInt32(MainForm.serialSystolic) <= 139 || Convert.ToInt32(MainForm.serialDiastolic) > 70 && Convert.ToInt32(MainForm.serialDiastolic) <= 89)
                            {
                                textBox3.Text   = "Normal";
                                MainForm.status = textBox3.Text;
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Invalid data");
                        }
                    }
                    if (serialRead != null && serialRead.Contains("r") || buttonIsClicked)
                    {
                        timer1.Enabled = true;
                        timer1.Start();
                        return;
                    }
                    else if (Double.TryParse(serialRead, out adc_val) && adc_val < 3.8)
                    {
                        if (Convert.ToDouble(serialRead) >= 3 && Math.Abs(Convert.ToDouble(serialRead) - MAP) > 0.7 && Double.TryParse(prevRead, out temp_adc))
                        {
                            serialRead = ((Convert.ToDouble(serialRead) + Convert.ToDouble(prevRead)) / 3).ToString();
                        }
                        if (serialRead.Length == 1 && prevRead.Length < 4)
                        {
                            prevRead  += serialRead;
                            serialRead = prevRead;
                        }
                        if (Convert.ToDouble(serialRead) < 0.5)
                        {
                            serialRead = (Convert.ToDouble(serialRead) + 1).ToString();
                        }
                        Draw(serialRead + "\n");
                    }
                    prevRead = serialRead;
                };

                if (zedGraphControl1.InvokeRequired)
                {
                    zedGraphControl1.Invoke(setAll);
                }
                else
                {
                    setAll();
                }
            }
            catch (Exception)
            {
                CloseForm();
            }
        }
예제 #15
0
        private void DrawGraph()
        {
            GraphPane pane = zedGraph.GraphPane;

            pane.CurveList.Clear();

            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            pane.YAxis.MajorGrid.IsZeroLine = false;

            // Создаем список точек
            RadarPointList points = new RadarPointList();


            // Т.к. в списке будет 4 точки, то и окружность будет разбиваться на 4 части
            // Обход точек будет осуществляться против часовой стрелки
            points.Clockwise = false;

            // Первая точка - сверху над началом координат. Расстояние до центра = 1
            points.Add(1, 1);

            // Вторая точка - слева от начала координат.  Расстояние до центра = 2
            points.Add(2, 1);

            // Третья точка - снизу под началом координат.  Расстояние до центра = 3
            points.Add(3, 1);

            // Четвертая точка - справа от начала координат.  Расстояние до центра = 4
            points.Add(4, 1);


            // Добавляем кривую по этим четырем точкам
            LineItem myCurve = pane.AddCurve("", points, Color.Black, SymbolType.None);


            // Для наглядности нарисуем расстояния от начала координат до каждой из точек
            ArrowObj arrow1 = new ArrowObj(0, 0, 0, 1);

            pane.GraphObjList.Add(arrow1);

            ArrowObj arrow2 = new ArrowObj(0, 0, -2, 0);

            pane.GraphObjList.Add(arrow2);

            ArrowObj arrow3 = new ArrowObj(0, 0, 0, -3);

            pane.GraphObjList.Add(arrow3);

            ArrowObj arrow4 = new ArrowObj(0, 0, 4, 0);

            pane.GraphObjList.Add(arrow4);

            // Отметим начало координат черным квадратиком
            BoxObj box = new BoxObj(-0.05, 0.05, 0.1, 0.1, Color.Black, Color.Black);

            pane.GraphObjList.Add(box);

            zedGraph.AxisChange();

            zedGraph.Invalidate();
        }
예제 #16
0
        public ModInitialSampleDemo() : base("Code Project Modified Initial Sample",
                                             "Modified Initial Sample", DemoType.Tutorial)
        {
            GraphPane myPane = base.GraphPane;

            // Set up the title and axis labels
            myPane.Title.Text       = "My Test Graph\n(For CodeProject Sample)";
            myPane.XAxis.Title.Text = "My X Axis";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data arrays based on the Sine function
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                double x  = (double)i + 5;
                double y1 = 1.5 + Math.Sin((double)i * 0.2);
                double y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);
            }

            // Generate a red curve with diamond
            // symbols, and "Porsche" in the legend
            LineItem myCurve = myPane.AddCurve("Porsche",
                                               list1, Color.Red, SymbolType.Diamond);

            // Generate a blue curve with circle
            // symbols, and "Piper" in the legend
            LineItem myCurve2 = myPane.AddCurve("Piper",
                                                list2, Color.Blue, SymbolType.Circle);

            // Change the color of the title
            myPane.Title.FontSpec.FontColor = Color.Green;

            // Add gridlines to the plot, and make them gray
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color     = Color.LightGray;
            myPane.YAxis.MajorGrid.Color     = Color.LightGray;

            // Move the legend location
            base.Pane.Legend.Position = LegendPos.Bottom;

            // Make both curves thicker
            myCurve.Line.Width  = 2.0F;
            myCurve2.Line.Width = 2.0F;

            // Fill the area under the curves
            myCurve.Line.Fill  = new Fill(Color.White, Color.Red, 45F);
            myCurve2.Line.Fill = new Fill(Color.White, Color.Blue, 45F);

            // Increase the symbol sizes, and fill them with solid white
            myCurve.Symbol.Size  = 8.0F;
            myCurve2.Symbol.Size = 8.0F;
            myCurve.Symbol.Fill  = new Fill(Color.White);
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Add a background gradient fill to the axis frame
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 210), -45F);

            // Add a caption and an arrow
            TextObj myText = new TextObj("Interesting\nPoint", 230F, 70F);

            myText.FontSpec.FontColor = Color.Red;
            myText.Location.AlignH    = AlignH.Center;
            myText.Location.AlignV    = AlignV.Top;
            myPane.GraphObjList.Add(myText);
            ArrowObj myArrow = new ArrowObj(Color.Red, 12F, 230F, 70F, 280F, 55F);

            myPane.GraphObjList.Add(myArrow);

            base.ZedGraphControl.AxisChange();
        }
예제 #17
0
        private void DisplayCalibrationCurve()
        {
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type             = zedGraphControl.GraphPane.XAxis.Type
                                                             = options.LogPlot ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.Legend.IsVisible       = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide      = null;
            PeptideGroupDocNode peptideGroup = null;
            SequenceTree        sequenceTree = _skylineWindow.SequenceTree;

            if (null != sequenceTree)
            {
                PeptideTreeNode peptideTreeNode = sequenceTree.GetNodeOfType <PeptideTreeNode>();
                if (null != peptideTreeNode)
                {
                    peptide = peptideTreeNode.DocNode;
                }
                PeptideGroupTreeNode peptideGroupTreeNode = sequenceTree.GetNodeOfType <PeptideGroupTreeNode>();
                if (null != peptideGroupTreeNode)
                {
                    peptideGroup = peptideGroupTreeNode.DocNode;
                }
            }

            if (null == peptide)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings
                    .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve;
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document.Settings, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (string.IsNullOrEmpty(
                        peptideQuantifier.QuantificationSettings.NormalizationMethod.IsotopeLabelTypeName))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_;
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            double minX = double.MaxValue, maxX = double.MinValue;

            _scatterPlots = new CurveList();
            foreach (var sampleType in SampleType.ListSampleTypes())
            {
                if (!Options.DisplaySampleType(sampleType))
                {
                    continue;
                }
                PointPairList pointPairList = new PointPairList();
                for (int iReplicate = 0;
                     iReplicate < document.Settings.MeasuredResults.Chromatograms.Count;
                     iReplicate++)
                {
                    ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[iReplicate];
                    if (!Equals(sampleType, chromatogramSet.SampleType))
                    {
                        continue;
                    }
                    double?y = curveFitter.GetYValue(iReplicate);
                    double?x = curveFitter.GetSpecifiedXValue(iReplicate)
                               ?? curveFitter.GetCalculatedXValue(CalibrationCurve, iReplicate);
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = iReplicate
                        };
                        pointPairList.Add(point);
                        if (!Options.LogPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!options.LogPlot)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, minX, maxX,
                                                                       interpolatedLinePointCount, Options.LogPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
                                   CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format("{0}: {1}", // Not L10N
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
            }

            if (options.ShowSelection)
            {
                double?ySelected = curveFitter.GetYValue(_skylineWindow.SelectedResultsIndex);
                double?xSelected = curveFitter.GetCalculatedXValue(CalibrationCurve, _skylineWindow.SelectedResultsIndex);
                if (xSelected.HasValue && ySelected.HasValue)
                {
                    ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                  ySelected.Value)
                    {
                        Line = { Color = GraphSummary.ColorSelected }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                }

                var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex);
                if (quantificationResult.CalculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format("{0} = {1}", // Not L10N
                                                 QuantificationStrings.Calculated_Concentration, quantificationResult));
                }
                else if (!quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
예제 #18
0
 /// <summary>
 /// Add the <see cref="ZedGraphWebGraphObj" /> objects defined in the webcontrol to
 /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects.
 /// </summary>
 /// <param name="g">The <see cref="Graphics" /> instance of interest.</param>
 /// <param name="pane">The <see cref="GraphPane" /> object to receive the
 /// <see cref="GraphObj" /> objects.</param>
 protected void AddWebGraphItems(IGraphics g, GraphPane pane)
 {
     try
     {
         ZedGraphWebGraphObj draw;
         for (int i = 0; i < GraphObjList.Count; i++)
         {
             draw = GraphObjList[i];
             if (draw is ZedGraphWebTextObj)
             {
                 var item = (ZedGraphWebTextObj) draw;
                 var x = new TextObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebArrowObj)
             {
                 var item = (ZedGraphWebArrowObj) draw;
                 var x = new ArrowObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebImageObj)
             {
                 var item = (ZedGraphWebImageObj) draw;
                 var x = new ImageObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebBoxObj)
             {
                 var item = (ZedGraphWebBoxObj) draw;
                 var x = new BoxObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebEllipseObj)
             {
                 var item = (ZedGraphWebEllipseObj) draw;
                 var x = new EllipseObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
         }
     }
     catch (Exception ex)
     {
         Log.Debug("Exception thrown at AddWebGraphItems: " + ex.Message, ex);
     }
 }
예제 #19
0
        private void CreateGraph_Two(ZedGraphControl zgc)
        {
            // get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;


            // Make up some data arrays based on the Sine function
            double        x, y1, y2;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                x  = (double)i + 5;
                y1 = 1.5 + Math.Sin((double)i * 0.2);
                y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);
            }

            // Generate a red curve with diamond
            // symbols, and "Porsche" in the legend
            LineItem myCurve = myPane.AddCurve("曲线1", list1, Color.Red, SymbolType.Diamond);

            // Generate a blue curve with circle
            // symbols, and "Piper" in the legend
            LineItem myCurve2 = myPane.AddCurve("曲线2", list2, Color.Blue, SymbolType.Circle);

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

            try
            {
                // Change the color of the title
                myPane.Title.FontSpec.FontColor = Color.Green;

                // Add gridlines to the plot, and make them gray
                myPane.XAxis.MajorGrid.IsVisible = true;
                myPane.YAxis.MajorGrid.IsVisible = true;
                myPane.XAxis.MajorGrid.Color     = Color.LightGray;
                myPane.YAxis.MajorGrid.Color     = Color.LightGray;

                // Move the legend location
                myPane.Legend.Position = ZedGraph.LegendPos.Bottom;

                // Make both curves thicker
                myCurve.Line.Width  = 2.0F;
                myCurve2.Line.Width = 2.0F;

                // Fill the area under the curves
                myCurve.Line.Fill  = new Fill(Color.White, Color.Red, 45F);
                myCurve2.Line.Fill = new Fill(Color.White, Color.Blue, 45F);

                // Increase the symbol sizes, and fill them with solid white
                myCurve.Symbol.Size  = 8.0F;
                myCurve2.Symbol.Size = 8.0F;
                myCurve.Symbol.Fill  = new Fill(Color.White);
                myCurve2.Symbol.Fill = new Fill(Color.White);

                // Add a background gradient fill to the axis frame
                myPane.Chart.Fill = new Fill(Color.White,
                                             Color.FromArgb(255, 255, 210), -45F);

                // Add a caption and an arrow
                TextObj myText = new TextObj("Interesting\nPoint", 230F, 70F);
                myText.FontSpec.FontColor = Color.Red;
                myText.Location.AlignH    = AlignH.Center;
                myText.Location.AlignV    = AlignV.Top;
                myPane.GraphObjList.Add(myText);
                ArrowObj myArrow = new ArrowObj(Color.Red, 12F, 230F, 70F, 280F, 55F);
                myPane.GraphObjList.Add(myArrow);//The final "dressed-up" graph will look like this:
            }
            catch { }

            zgc.AxisChange();
        }
예제 #20
0
        private void DisplayCalibrationCurve()
        {
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type             = zedGraphControl.GraphPane.XAxis.Type
                                                             = options.LogPlot ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.Legend.IsVisible       = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            FiguresOfMerit   = FiguresOfMerit.EMPTY;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide;
            PeptideGroupDocNode peptideGroup;

            if (!TryGetSelectedPeptide(out peptideGroup, out peptide))
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings
                    .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve;
                return;
            }
            if (-1 == document.Children.IndexOf(peptideGroup))
            {
                zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_peptide_is_no_longer_part_of_the_Skyline_document_;
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (!(peptideQuantifier.NormalizationMethod is NormalizationMethod.RatioToLabel))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_;
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            FiguresOfMerit   = curveFitter.GetFiguresOfMerit(CalibrationCurve);
            double minX = double.MaxValue, maxX = double.MinValue;
            double minY = double.MaxValue;

            _scatterPlots = new CurveList();
            foreach (var sampleType in SampleType.ListSampleTypes())
            {
                if (!Options.DisplaySampleType(sampleType))
                {
                    continue;
                }
                PointPairList pointPairList         = new PointPairList();
                PointPairList pointPairListExcluded = new PointPairList();
                for (int iReplicate = 0;
                     iReplicate < document.Settings.MeasuredResults.Chromatograms.Count;
                     iReplicate++)
                {
                    ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[iReplicate];
                    if (!Equals(sampleType, chromatogramSet.SampleType))
                    {
                        continue;
                    }
                    double?y           = curveFitter.GetYValue(iReplicate);
                    double?xCalculated = curveFitter.GetCalculatedXValue(CalibrationCurve, iReplicate);
                    double?x           = curveFitter.GetSpecifiedXValue(iReplicate)
                                         ?? xCalculated;
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = iReplicate
                        };
                        if (sampleType.AllowExclude && peptide.IsExcludeFromCalibration(iReplicate))
                        {
                            pointPairListExcluded.Add(point);
                        }
                        else
                        {
                            pointPairList.Add(point);
                        }
                        if (double.IsNaN(x.Value) || double.IsInfinity(x.Value) ||
                            double.IsNaN(y.Value) || double.IsInfinity(y.Value))
                        {
                            continue;
                        }
                        if (!Options.LogPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        if (!Options.LogPlot || y.Value > 0)
                        {
                            minY = Math.Min(minY, y.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                        if (xCalculated.HasValue)
                        {
                            maxX = Math.Max(maxX, xCalculated.Value);
                            if (!Options.LogPlot || xCalculated.Value > 0)
                            {
                                minX = Math.Min(minX, xCalculated.Value);
                            }
                        }
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
                if (pointPairListExcluded.Any())
                {
                    string curveLabel = pointPairList.Any() ? null : sampleType.ToString();
                    var    lineItem   = zedGraphControl.GraphPane.AddCurve(curveLabel, pointPairListExcluded,
                                                                           sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines    = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!options.LogPlot)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    double[] xValues;
                    if (CalibrationCurve.TurningPoint.HasValue)
                    {
                        xValues = new[] { minX, CalibrationCurve.TurningPoint.Value, maxX };
                    }
                    else
                    {
                        xValues = new[] { minX, maxX };
                    }
                    Array.Sort(xValues);
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, xValues,
                                                                       interpolatedLinePointCount, Options.LogPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
                                   CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format("{0}: {1}", // Not L10N
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
                string strFiguresOfMerit = FiguresOfMerit.ToString();
                if (!string.IsNullOrEmpty(strFiguresOfMerit))
                {
                    labelLines.Add(strFiguresOfMerit);
                }
            }

            if (options.ShowSelection)
            {
                double?ySelected = curveFitter.GetYValue(_skylineWindow.SelectedResultsIndex);
                double?xSelected = curveFitter.GetCalculatedXValue(CalibrationCurve, _skylineWindow.SelectedResultsIndex);
                if (xSelected.HasValue && ySelected.HasValue)
                {
                    const float selectedLineWidth = 2;
                    ArrowObj    arrow             = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                                 ySelected.Value)
                    {
                        Line = { Color = GraphSummary.ColorSelected }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                    var selectedLineColor = Color.FromArgb(128, GraphSummary.ColorSelected);
                    var verticalLine      = new LineObj(xSelected.Value, ySelected.Value, xSelected.Value, options.LogPlot ? double.MinValue : 0)
                    {
                        Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                        Location             = { CoordinateFrame = CoordType.AxisXYScale },
                        ZOrder               = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(verticalLine);
                    double?xSpecified = curveFitter.GetSpecifiedXValue(_skylineWindow.SelectedResultsIndex);
                    if (xSpecified.HasValue)
                    {
                        var horizontalLine = new LineObj(xSpecified.Value, ySelected.Value, xSelected.Value,
                                                         ySelected.Value)
                        {
                            Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            ZOrder               = ZOrder.E_BehindCurves,
                            IsClippedToChartRect = true
                        };
                        zedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                    }
                }

                var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex);
                if (quantificationResult.CalculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format("{0} = {1}", // Not L10N
                                                 QuantificationStrings.Calculated_Concentration, quantificationResult));
                }
                else if (!quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
예제 #21
0
        /// <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( Graphics 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
            TextObj 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
            ArrowObj 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
            BoxObj 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"
            TextObj 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 );
        }
예제 #22
0
 /// <summary>
 /// Add the <see cref="ZeeGraphWebGraphObj" /> objects defined in the webcontrol to
 /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects.
 /// </summary>
 /// <param name="g">The <see cref="Graphics" /> instance of interest.</param>
 /// <param name="pane">The <see cref="GraphPane" /> object to receive the
 /// <see cref="GraphObj" /> objects.</param>
 protected void AddWebGraphItems( Graphics g, GraphPane pane )
 {
     try
     {
         ZeeGraphWebGraphObj draw;
         for ( int i = 0; i < GraphObjList.Count; i++ )
         {
             draw = GraphObjList[i];
             if ( draw is ZeeGraphWebTextObj )
             {
                 ZeeGraphWebTextObj item = (ZeeGraphWebTextObj)draw;
                 TextObj x = new TextObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZeeGraphWebArrowObj )
             {
                 ZeeGraphWebArrowObj item = (ZeeGraphWebArrowObj)draw;
                 ArrowObj x = new ArrowObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZeeGraphWebImageObj )
             {
                 ZeeGraphWebImageObj item = (ZeeGraphWebImageObj)draw;
                 ImageObj x = new ImageObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZeeGraphWebBoxObj )
             {
                 ZeeGraphWebBoxObj item = (ZeeGraphWebBoxObj)draw;
                 BoxObj x = new BoxObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZeeGraphWebEllipseObj )
             {
                 ZeeGraphWebEllipseObj item = (ZeeGraphWebEllipseObj)draw;
                 EllipseObj x = new EllipseObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
         }
     }
     catch ( Exception )
     {
     }
 }
예제 #23
0
        private void CreateMutiLineChart()
        {
            dgDataSource.DataSource = dt;

            GraphPane myPane = zedGraphControl1.GraphPane;

            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();
            myPane.Title.Text       = "不同环境下用水总量对比模拟";
            myPane.XAxis.Title.Text = "年份";
            myPane.YAxis.Title.Text = "用水总量";
            list1 = new PointPairList();
            list2 = new PointPairList();
            list3 = new PointPairList();
            list4 = new PointPairList();
            LineItem myCurve1 = null, myCurve2 = null, myCurve3 = null, myCurve4 = null;

            myCurve1 = myPane.AddCurve("农业",
                                       list1, Color.Red, SymbolType.Diamond);
            myCurve2 = myPane.AddCurve("工业",
                                       list2, Color.Blue, SymbolType.Circle);
            myCurve3 = myPane.AddCurve("生活",
                                       list3, Color.Green, SymbolType.Star);
            myCurve4 = myPane.AddCurve("生态",
                                       list4, Color.Orange, SymbolType.Square);
            myPane.Title.FontSpec.FontColor  = Color.Green;
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color     = Color.LightGray;
            myPane.YAxis.MajorGrid.Color     = Color.LightGray;
            myPane.Legend.Position           = ZedGraph.LegendPos.Bottom;
            myCurve1.Line.Width = 1.0F;
            myCurve2.Line.Width = 1.0F;
            myCurve3.Line.Width = 1.0F;
            myCurve4.Line.Width = 1.0F;


            myCurve1.Symbol.Size = 2.0F;
            myCurve2.Symbol.Size = 2.0F;
            myCurve3.Symbol.Size = 2.0F;
            myCurve4.Symbol.Size = 2.0F;

            myCurve1.Symbol.Fill = new Fill(Color.White);
            myCurve2.Symbol.Fill = new Fill(Color.White);
            myCurve3.Symbol.Fill = new Fill(Color.White);
            myCurve4.Symbol.Fill = new Fill(Color.White);


            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 210), -45F);


            TextObj myText = new TextObj("Interesting\nPoint", 230F, 70F);

            myText.FontSpec.FontColor = Color.Red;
            myText.Location.AlignH    = AlignH.Center;
            myText.Location.AlignV    = AlignV.Top;
            myPane.GraphObjList.Add(myText);
            ArrowObj myArrow = new ArrowObj(Color.Red, 12F, 230F, 70F, 280F, 55F);

            myPane.GraphObjList.Add(myArrow);

            myPane.AxisChange();
            zedGraphControl1.Refresh();
        }
예제 #24
0
        private void Form1_Load(object sender, EventArgs e)
        {
            memGraphics.CreateDoubleBuffer(this.CreateGraphics(),
                                           this.ClientRectangle.Width, this.ClientRectangle.Height);

            myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                   "Wacky Widget Company\nProduction Report",
                                   "Time, Days\n(Since Plant Construction Startup)",
                                   "Widget Production\n(units/hour)");
            SetSize();

            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            LineItem curve;

            curve                    = myPane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle);
            curve.Line.Width         = 1.5F;
            curve.Line.Fill          = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F);
            curve.Line.IsSmooth      = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill        = new Fill(Color.White);
            curve.Symbol.Size        = 10;

            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            curve            = myPane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle);
            curve.Line.Width = 1.5F;
            //curve.Line.IsSmooth = true;
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Line.Fill   = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F);
            curve.Symbol.Size = 10;

            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 = myPane.AddBar("Wheezy", x4, y4, Color.SteelBlue);

            bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown);
            myPane.BarSettings.ClusterScaleWidth = 100;
            myPane.BarSettings.Type = BarType.Stack;

            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          = myPane.AddBar("Curly", x2, y2, Color.RoyalBlue);
            bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue);
            myPane.BarSettings.ClusterScaleWidth = 100;

            myPane.Fill       = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245),
                                         Color.FromArgb(255, 255, 190), 90F);

            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.Scale.Max           = 120;

            TextObj text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F);

            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill   = new Fill(Color.White, Color.PowderBlue, 45F);
            myPane.GraphObjList.Add(text);

            ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);

            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            myPane.GraphObjList.Add(arrow);

            text = new TextObj("Upgrade", 700F, 50.0F);
            text.FontSpec.Angle            = 90;
            text.FontSpec.FontColor        = Color.Black;
            text.Location.AlignH           = AlignH.Right;
            text.Location.AlignV           = AlignV.Center;
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(text);

            arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.PenWidth = 2.0F;
            myPane.GraphObjList.Add(arrow);

            text = new TextObj("Confidential", 0.85F, -0.03F);
            text.Location.CoordinateFrame = CoordType.ChartFraction;

            text.FontSpec.Angle            = 15.0F;
            text.FontSpec.FontColor        = Color.Red;
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color     = Color.Red;
            text.FontSpec.Fill.IsVisible   = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            myPane.GraphObjList.Add(text);

            BoxObj box = new BoxObj(0, 110, 1200, 10,
                                    Color.Empty, Color.FromArgb(225, 245, 225));

            box.Location.CoordinateFrame = CoordType.AxisXYScale;

            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            box.ZOrder          = ZOrder.E_BehindAxis;
            myPane.GraphObjList.Add(box);

            text = new TextObj("Peak Range", 1170, 105);
            text.Location.CoordinateFrame  = CoordType.AxisXYScale;
            text.Location.AlignH           = AlignH.Right;
            text.Location.AlignV           = AlignV.Center;
            text.FontSpec.IsItalic         = true;
            text.FontSpec.IsBold           = false;
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(text);

            myPane.AxisChange(this.CreateGraphics());
        }
예제 #25
0
        private void CreateMutiLineChart()
        {
            dgDataSource.DataSource = dt;

            int iRow = dt.Rows.Count;

            GraphPane myPane = zedGraphControl1.GraphPane;

            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();
            // Set up the title and axis labels
            myPane.Title.Text       = "气温趋势模拟";
            myPane.XAxis.Title.Text = "年份";
            myPane.YAxis.Title.Text = "温度值";

            //PointPairList list1 = null, list3 = null, list2 = null, list = null;
            // Make up some data arrays based on the Sine function
            list1 = new PointPairList();
            list3 = new PointPairList();
            list2 = new PointPairList();
            list4 = new PointPairList();

            //double x = double.Parse(dt.Rows[0]["year"].ToString().Trim());
            //double y1 = double.Parse(dt.Rows[0]["gdp1"].ToString().Trim());
            //double y3 = double.Parse(dt.Rows[0]["gdp3"].ToString().Trim());
            //double y2 = double.Parse(dt.Rows[0]["gdp2"].ToString().Trim());
            //double y = double.Parse(dt.Rows[0]["gdp"].ToString().Trim());
            //list.Add(x, y);
            //list1.Add( x, y1);
            //list2.Add( x, y2 );
            //list3.Add(x, y3);

            LineItem myCurve1 = null, myCurve2 = null, myCurve3 = null, myCurve4 = null;

            // Generate a red curve with diamond
            // symbols, and "GDP1" in the legend
            myCurve1 = myPane.AddCurve("rcp2.6",
                                       list1, Color.Red, SymbolType.Diamond);

            // Generate a blue curve with circle
            // symbols, and "GDP2" in the legend
            myCurve2 = myPane.AddCurve("rcp4.5",
                                       list2, Color.Blue, SymbolType.Circle);

            // Generate a blue curve with circle
            // symbols, and "GDP3" in the legend
            myCurve3 = myPane.AddCurve("rcp6.0",
                                       list3, Color.Green, SymbolType.Star);

            // Generate a blue curve with circle
            // symbols, and "GDP" in the legend
            myCurve4 = myPane.AddCurve("rcp8.5",
                                       list4, Color.Orange, SymbolType.Square);


            // Change the color of the title
            myPane.Title.FontSpec.FontColor = Color.Green;

            // Add gridlines to the plot, and make them gray
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color     = Color.LightGray;
            myPane.YAxis.MajorGrid.Color     = Color.LightGray;

            // Move the legend location
            myPane.Legend.Position = ZedGraph.LegendPos.Bottom;

            // Make both curves thicker
            myCurve1.Line.Width = 1.0F;
            myCurve2.Line.Width = 1.0F;
            myCurve3.Line.Width = 1.0F;
            myCurve4.Line.Width = 1.0F;

            // Fill the area under the curves

            //myCurve1.Line.Fill = new Fill(Color.White, Color.Red, 45F );
            //myCurve2.Line.Fill = new Fill( Color.White, Color.Blue, 45F );
            //myCurve3.Line.Fill = new Fill(Color.White, Color.Green, 45F);

            // Increase the symbol sizes, and fill them with solid white
            myCurve1.Symbol.Size = 2.0F;
            myCurve2.Symbol.Size = 2.0F;
            myCurve3.Symbol.Size = 2.0F;
            myCurve4.Symbol.Size = 2.0F;

            myCurve1.Symbol.Fill = new Fill(Color.White);
            myCurve2.Symbol.Fill = new Fill(Color.White);
            myCurve3.Symbol.Fill = new Fill(Color.White);
            myCurve4.Symbol.Fill = new Fill(Color.White);

            // Add a background gradient fill to the axis frame
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 210), -45F);

            // Add a caption and an arrow
            TextObj myText = new TextObj("Interesting\nPoint", 230F, 70F);

            myText.FontSpec.FontColor = Color.Red;
            myText.Location.AlignH    = AlignH.Center;
            myText.Location.AlignV    = AlignV.Top;
            myPane.GraphObjList.Add(myText);
            ArrowObj myArrow = new ArrowObj(Color.Red, 12F, 230F, 70F, 280F, 55F);

            myPane.GraphObjList.Add(myArrow);

            myPane.AxisChange();
            zedGraphControl1.Refresh();
        }
예제 #26
0
        public void add(List <Position> positions, List <Trade> trades, Simulator simulator)
        {
            Action <Trade, double> addTrade = (trade, x) => {
                var y     = trade.price;
                var color = trade.direction.longShort(Color.Green, Color.Red);
                var line  = AddCurve("", new PointPairList {
                    { x, y }
                }, color, SymbolType.Circle);
                line.Symbol.Fill       = new Fill(color);
                line.Label.IsVisible   = false;
                line.Line.IsVisible    = false;
                line.IsOverrideOrdinal = true;
                var arrow = new ArrowObj(x, trade.direction.longShort(0.93, 0.07), x, trade.direction.longShort(0.89, 0.11))
                {
                    Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                    ZOrder   = ZOrder.A_InFront
                };
                GraphObjList.Add(arrow);
                var dottedLine = new LineObj(Color.LightGray, x, 0.11, x, 0.89)
                {
                    ZOrder   = ZOrder.E_BehindCurves,
                    Line     = { Style = DashStyle.Dot },
                    Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                };
                GraphObjList.Add(dottedLine);
                var text = new TextObj(
                    trade.description + "\n" + trade.size + "@" + trade.price.ToString("n4"),
                    x, trade.direction.longShort(0.935, 0.065),
                    CoordType.XScaleYChartFraction,
                    AlignH.Center,
                    trade.direction.longShort(AlignV.Top, AlignV.Bottom)
                    )
                {
                    FontSpec = { Size = 8, Border = { IsVisible = false } }
                };
                if (Objects.username().Equals("rsheftel"))
                {
                    text.FontSpec.FontColor = Color.Fuchsia;
                    text.FontSpec.Size      = 11;
                }
                GraphObjList.Add(text);
            };

            Objects.each(trades, trade => addTrade(trade, dateParent.index(trade.time)));

            Action <Position> addPositionMaybe = position => {
                if (!position.isClosed())
                {
                    return;
                }
                var pnl   = position.pnl(true, simulator.runInNativeCurrency());
                var color = pnl > 0 ? Color.Green : (pnl < 0 ? Color.Red : Color.Black);
                var line  = AddCurve("", new PointPairList {
                    { dateParent.index(position.entry().time), position.entry().price }, { dateParent.index(position.exitTrade().time), position.exitTrade().price }
                }, color);
                line.Symbol.IsVisible  = false;
                line.Line.Style        = DashStyle.Dot;
                line.Line.Width        = 2;
                line.Label.IsVisible   = false;
                line.IsOverrideOrdinal = true;
            };

            Objects.each(positions, addPositionMaybe);

            simulator.addNewTradeListener((position, trade) => {
                if (!position.symbol.Equals(symbol))
                {
                    return;
                }
                addTrade(trade, bars.count());
                addPositionMaybe(position);
            });
        }