public void TestOneDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(2, n).Select(i => new DateTime(1900, i, 1));

            double[] y = Enumerable.Range(100, n).Select(i => Convert.ToDouble(i)).ToArray();

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 33, 61, 92, 122, 153, 183, 214, 245, 275, 306 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(y[i], point.Y);
                i++;
            }
        }
Exemple #2
0
        public MainWindowModel()
        {
            PlotModel = new PlotModel();

            var s1 = new OxyPlot.Series.LineSeries();

            s1.Points.Add(new DataPoint(0, 4));
            s1.Points.Add(new DataPoint(10, 13));
            s1.Points.Add(new DataPoint(20, 15));
            s1.Points.Add(new DataPoint(30, 16));
            s1.Points.Add(new DataPoint(40, 12));
            s1.Points.Add(new DataPoint(50, 12));

            PlotModel.Series.Add(s1);

            var l1 = new OxyPlot.Annotations.LineAnnotation();

            l1.Type      = OxyPlot.Annotations.LineAnnotationType.Horizontal;
            l1.Y         = 5;
            l1.MinimumX  = 2;
            l1.MaximumX  = 15;
            l1.LineStyle = OxyPlot.LineStyle.Solid;
            PlotModel.Annotations.Add(l1);
            double x;

            l1.MouseDown += (s, e) =>
            {
                x           = (l1 as OxyPlot.Annotations.LineAnnotation).InverseTransform(e.Position).X;
                l1.MinimumX = x;
                PlotModel.RefreshPlot(true);
                PlotModel.InvalidatePlot(true);
                //OnPropertyChanged("PlotModel");
                e.Handled = true;
            };
        }
        public void TestSimpleCase()
        {
            IEnumerable <object> x = new object[] { 0d, 1d, 2d, 4d };
            IEnumerable <object> y = new object[] { 1d, 2d, 4d, 8d };
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            string     title  = "asdf";
            LineSeries input  = new LineSeries(title, Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(title, series.Title);
            Assert.AreEqual(4, series.ItemsSource.Count());

            // Marker style
            Assert.AreEqual(OxyPlot.MarkerType.Square, series.MarkerType);
            Assert.AreEqual(7, series.MarkerSize);

            // Line style
            Assert.AreEqual(OxyPlot.LineStyle.Solid, series.LineStyle);
            Assert.AreEqual(0.25, series.StrokeThickness);

            // Colours
            Assert.AreEqual(OxyColors.Blue, series.Color);
        }
Exemple #4
0
        private static void MakeTotalLinePlot([JetBrains.Annotations.NotNull] string outputPath, [JetBrains.Annotations.NotNull] List <double> sums)
        {
            var plotModel1 = new PlotModel
            {
                LegendPosition    = LegendPosition.BottomCenter,
                LegendPlacement   = LegendPlacement.Outside,
                LegendOrientation = LegendOrientation.Horizontal,
                Title             = "Total"
            };
            var linearAxis1 = new LinearAxis
            {
                Position = AxisPosition.Bottom
            };

            plotModel1.Axes.Add(linearAxis1);
            var lineSeries1 = new LineSeries
            {
                Title = "Sum"
            };

            for (var j = 0; j < sums.Count; j++)
            {
                lineSeries1.Points.Add(new DataPoint(j, sums[j]));
            }
            plotModel1.Series.Add(lineSeries1);
            var path = Path.Combine(outputPath, "Sum.line.png");

            PngExporter.Export(plotModel1, path, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
Exemple #5
0
        public static void AddLine <T>(
            this PlotModel model,
            IEnumerable <T> data,
            Func <T, double> ySelector,
            Func <T, double> xSelector = null,
            LineStyle lineStyle        = null)
        {
            var series = new OxyPlot.Series.LineSeries();

            var dataList = data.ToList();

            for (int i = 0; i < dataList.Count; i++)
            {
                var item = dataList[i];
                var x    = xSelector != null?xSelector(item) : (double)i;

                var y = ySelector(item);
                series.Points.Add(new DataPoint(x, y));
            }

            if (lineStyle != null)
            {
                series.Color           = lineStyle.Color;
                series.StrokeThickness = lineStyle.Thickness;
                series.LineStyle       = lineStyle.Style;
            }

            model.Series.Add(series);
        }
Exemple #6
0
        private static void MakeLinePlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day)
        {
            var p          = OxyPalettes.HueDistinct(columns.Count);
            var plotModel1 = new PlotModel
            {
                LegendPosition    = LegendPosition.BottomCenter,
                LegendPlacement   = LegendPlacement.Outside,
                LegendOrientation = LegendOrientation.Horizontal,
                Title             = "Day " + day
            };
            var linearAxis1 = new LinearAxis
            {
                Position = AxisPosition.Bottom
            };

            plotModel1.Axes.Add(linearAxis1);

            for (var i = 1; i < columns.Count; i++)
            {
                var lineSeries1 = new LineSeries
                {
                    Title = columns[i].HHNumber,
                    Color = p.Colors[i]
                };
                for (var j = position; j < position + 1440; j++)
                {
                    lineSeries1.Points.Add(new DataPoint(j, columns[i].Values[j]));
                }
                plotModel1.Series.Add(lineSeries1);
            }
            var path = Path.Combine(outputPath, "Plot." + day + ".line.png");

            PngExporter.Export(plotModel1, path, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
Exemple #7
0
        public PlotModel LineSeries(TrendbarJson[] data)
        {
            var model = new PlotModel {
                Title = "LineSeries", LegendSymbolLength = 24
            };
            var s1 = new OxyPlot.Series.LineSeries {
                Title = currentSymbol.SymbolName,
                Color = OxyColors.Orange,
            };

            foreach (TrendbarJson item in data)
            {
                s1.Points.Add(new DataPoint(item.Timestamp, item.Close));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, MaximumPadding = 0.3, MinimumPadding = 0.3
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, MaximumPadding = 0.03, MinimumPadding = 0.03
            });

            var arrowAnnotation = new LineAnnotation {
                Type      = LineAnnotationType.Horizontal,
                Color     = OxyColors.Red,
                Y         = data[data.Length - 1].Close,
                Text      = data[data.Length - 1].Close.ToString(),
                TextColor = OxyColors.White
            };

            model.Annotations.Add(arrowAnnotation);
            return(model);
        }
Exemple #8
0
        public CStepRespPlot(PlotView _plotBodeMag)
        {
            m_plotBodeMag = _plotBodeMag;
            // Mag
            m_plotBodeMag.Dock                 = System.Windows.Forms.DockStyle.Bottom;
            m_plotBodeMag.Location             = new System.Drawing.Point(0, 0);
            m_plotBodeMag.Name                 = "StepRespPlot";
            m_plotBodeMag.PanCursor            = System.Windows.Forms.Cursors.Hand;
            m_plotBodeMag.Size                 = new System.Drawing.Size(200, 120);
            m_plotBodeMag.TabIndex             = 0;
            m_plotBodeMag.Text                 = "StepRespPlot";
            m_plotBodeMag.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
            m_plotBodeMag.ZoomRectangleCursor  = System.Windows.Forms.Cursors.SizeNWSE;
            m_plotBodeMag.ZoomVerticalCursor   = System.Windows.Forms.Cursors.SizeNS;

            m_PlotModelBodeMag       = new OxyPlot.PlotModel();
            m_PlotModelBodeMag.Title = "Step Response";

            m_PlotModelBodeMag.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Maximum = 0, Minimum = 1e-3
            });                                                                                                         //X
            m_PlotModelBodeMag.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Maximum = 5, Minimum = -5
            });                                                                                                     //Y

            seriesBodeMag            = new LineSeries();
            seriesBodeMag.Title      = "(output)";// legend
            seriesBodeMag.MarkerType = MarkerType.None;
            seriesBodeMag.Points.Add(new DataPoint(0, 0));
            seriesBodeMag.Points.Add(new DataPoint(1, 10));
            seriesBodeMag.Background = OxyColors.White;

            m_PlotModelBodeMag.Series.Add(seriesBodeMag);
        }
        /// <summary>
        /// Construct a new instance of the class.
        /// </summary>
        /// <param name="title">The plot title.</param>
        /// <param name="results">The data to plot.</param>
        public Plot(string title, List <List <double> > results)
        {
            // set up plot model
            var plotModel = new OxyPlot.PlotModel();

            plotModel.Title = title;

            // set up axes and colors
            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Error"
            });
            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs"
            });
            var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green, OxyPlot.OxyColors.Red, OxyPlot.OxyColors.Black };

            // set up lines
            for (int i = 0; i < results.Count; i++)
            {
                var lineSeries = new OxyPlot.Series.LineSeries();
                lineSeries.ItemsSource = results[i].Select((value, index) => new OxyPlot.DataPoint(index, value));
                lineSeries.Title       = string.Format("KFold {0}/{1}", i + 1, results.Count);
                //lineSeries.Color = colors[i];
                plotModel.Series.Add(lineSeries);
            }

            var plotView = new OxyPlot.Wpf.PlotView();

            plotView.Model = plotModel;

            Title   = title;
            Content = plotView;
        }
Exemple #10
0
        // ************************************************************************
        private void DrawPoints(params DrawInfo[] drawInfos)
        {
            Model.PlotModel.Series.Clear();

            foreach (var drawInfo in drawInfos)
            {
                if (drawInfo.DrawStyle == DrawStyle.Line)
                {
                    var s = new OxyPlot.Series.LineSeries {
                        Title = drawInfo.Name, MarkerType = MarkerType.Square, Color = drawInfo.Color
                    };
                    foreach (var pt in drawInfo.Points)
                    {
                        s.Points.Add(new DataPoint(pt.X, pt.Y));
                    }
                    Model.PlotModel.Series.Insert(0, s);
                }
                else if (drawInfo.DrawStyle == DrawStyle.Point)
                {
                    var s = new OxyPlot.Series.ScatterSeries {
                        Title = drawInfo.Name, MarkerType = MarkerType.Circle, MarkerSize = 2, MarkerFill = drawInfo.Color
                    };
                    foreach (var pt in drawInfo.Points)
                    {
                        s.Points.Add(new ScatterPoint(pt.X, pt.Y));
                    }
                    Model.PlotModel.Series.Insert(0, s);
                }
            }

            Model.PlotModel.PlotView?.InvalidatePlot();
        }
Exemple #11
0
        public static PlotModel initializePlotModelWithAxes()
        {
            // Plot model constructing
            PlotModel plotModel = getPlotModel(
                "Treatement system test",
                TitleHorizontalAlignment.CenteredWithinPlotArea,
                "Legend",
                LegendOrientation.Horizontal,
                LegendPlacement.Inside,
                LegendPosition.TopRight
                );

            // Initializing axes
            Axis xAxis = getAxis("XAxis", "X Axis", AxisPosition.Bottom);
            Axis yAxis = getAxis("YAxis", "Y Axis", AxisPosition.Left);


            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);


            // Prepear initial series
            LineSeries lineSerie = new LineSeries
            {
                StrokeThickness             = 2,
                CanTrackerInterpolatePoints = false,
                Title = "Value",
            };

            plotModel.Series.Add(lineSerie);

            return(plotModel);
        }
Exemple #12
0
        private void SetUpModel()
        {
            var dateAxis = new OxyPlot.Axes.DateTimeAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
            };

            PlotModel.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            };

            PlotModel.Axes.Add(valueAxis);


            var lineSerie = new OxyPlot.Series.LineSeries
            {
                StrokeThickness             = 2,
                MarkerSize                  = 3,
                CanTrackerInterpolatePoints = false,
                //Title = string.Format("Detector {0}", 0),
                Smooth = false,
            };

            lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now), 1));
            PlotModel.Series.Add(lineSerie);
        }
        public void TestTwoDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(1, n).Select(i => new DateTime(2000, 1, i));
            IEnumerable <DateTime> y = Enumerable.Range(2000, n).Select(i => new DateTime(i, 1, 1));

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 36526, 36527, 36528, 36529, 36530, 36531, 36532, 36533, 36534, 36535 };
            double[] expectedY = new double[] { 36526, 36892, 37257, 37622, 37987, 38353, 38718, 39083, 39448, 39814 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(expectedY[i], point.Y);
                i++;
            }
        }
        public void B11_Backgrounds()
        {
            var plot = new PlotModel { Title = "Backgrounds" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            var yaxis1 = new LinearAxis { Position = AxisPosition.Left, Title = "Y1", Key = "Y1", StartPosition = 0, EndPosition = 0.5 };
            var yaxis2 = new LinearAxis { Position = AxisPosition.Left, Title = "Y2", Key = "Y2", StartPosition = 0.5, EndPosition = 1 };
            plot.Axes.Add(yaxis1);
            plot.Axes.Add(yaxis2);

            Action<LineSeries> addExamplePoints = ls =>
                {
                    ls.Points.Add(new DataPoint(3, 13));
                    ls.Points.Add(new DataPoint(10, 47));
                    ls.Points.Add(new DataPoint(30, 23));
                    ls.Points.Add(new DataPoint(40, 65));
                    ls.Points.Add(new DataPoint(80, 10));
                };

            var ls1 = new LineSeries { Background = OxyColors.LightSeaGreen, YAxisKey = "Y1" };
            addExamplePoints(ls1);
            plot.Series.Add(ls1);

            var ls2 = new LineSeries { Background = OxyColors.LightSkyBlue, YAxisKey = "Y2" };
            addExamplePoints(ls2);
            plot.Series.Add(ls2);

            // OxyAssert.AreEqual(plot, "B11");
        }
Exemple #15
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            if (dataPcm == null)
            {
                return;
            }

            if (!gPlotDataX_flag)
            {
                PlotInitialize();
            }

            updateFFT();

            if (cbAutoAxis.Checked)
            {
            }
            if (dataX != null)
            {
                PlotModel model   = new PlotModel();
                PlotModel t_model = new PlotModel();

                var line = new OxyPlot.Series.LineSeries()
                {
                    Title           = $"Series 1",
                    Color           = OxyPlot.OxyColors.Blue,
                    StrokeThickness = 1,
                    MarkerSize      = 2,
                    MarkerType      = OxyPlot.MarkerType.Circle
                };

                var line2 = new OxyPlot.Series.LineSeries()
                {
                    Title           = $"Series t",
                    Color           = OxyPlot.OxyColors.Blue,
                    StrokeThickness = 1,
                    MarkerSize      = 2,
                    MarkerType      = OxyPlot.MarkerType.Circle
                };

                for (int i = 0; i < dataX.Length; i++)
                {
                    line.Points.Add(new OxyPlot.DataPoint(dataX[i], dataFft[i]));
                }

                for (int i = 0; i < dataPcm.Length; i++)
                {
                    line2.Points.Add(new OxyPlot.DataPoint(i, dataPcm[i]));
                }

                model.Series.Add(line);
                oxyPlot1.Model = model;

                t_model.Series.Add(line2);
                oxyPlot2.Model = t_model;
            }
        }
Exemple #16
0
 private static void AddNRWPoints([JetBrains.Annotations.NotNull] LineSeries sc, int multiplicator)
 {
     sc.Points.Add(new DataPoint(1 * multiplicator, 1798));
     sc.Points.Add(new DataPoint(2 * multiplicator, 2850));
     sc.Points.Add(new DataPoint(3 * multiplicator, 3733));
     sc.Points.Add(new DataPoint(4 * multiplicator, 4480));
     sc.Points.Add(new DataPoint(5 * multiplicator, 5311));
     sc.Points.Add(new DataPoint(6 * multiplicator, 5816));
 }
Exemple #17
0
        // Loop over list of values and map them with an index to construct a point
        public static LineSeries generateLineSeriesBasedOnListOfPoints(List <double> points)
        {
            var series = new LineSeries();
            int i      = 0;

            foreach (double val in points)
            {
                series.Points.Add(new DataPoint(i, val));
                i++;
            }
            return(series);
        }
Exemple #18
0
            public void PodajDaneDoWykresu2(List <double> X, List <List <double> > Y, List <Process> procesy)//Lista X i Y podana jako parametr metody
            {
                this.PlotModel = new OxyPlot.PlotModel();
                //Usunięcie ustawionych parametrów z poprzedniego uruchomienia metody
                plotModel.Series = new System.Collections.ObjectModel.Collection <OxyPlot.Series.Series> {
                };
                punktySeriiTab   = new OxyPlot.Series.LineSeries[Y.Count()];//Ile jest List w zmiennej Y
                plotModel.Axes   = new System.Collections.ObjectModel.Collection <OxyPlot.Axes.Axis> {
                };
                Random random = new Random();

                //Graficzne ustawienia wykresów
                for (int n = 0; n < Y.Count(); n++)
                {
                    punktySeriiTab[n] = new OxyPlot.Series.LineSeries
                    {
                        MarkerType   = ksztaltPunktowWykresu[n % 5],                                             //oznaczenie punktów
                        MarkerSize   = 4,                                                                        //wielkość punktów
                        MarkerStroke = OxyPlot.OxyColor.FromUInt32((uint)random.Next(0, 16777215) + 4278190080), //Kolor obramowania punktów wykresu / kolory losowane funkcją random
                        Title        = procesy[n].ProcessName.ToString()                                         //tytuł serii
                    };
                }
                //Uzupełnianie danych
                for (int i = 0; i < Y.Count(); i++)
                {
                    for (int n = 0; n < Y[i].Count(); n++)                                  //uzupełniam tylko dla włączonych
                    {
                        punktySeriiTab[i].Points.Add(new OxyPlot.DataPoint(X[n], Y[i][n])); //dodanie wszystkich serii do wykresu
                    }
                }
                for (int i = 0; i < Y.Count(); i++)
                {
                    plotModel.Series.Add(punktySeriiTab[i]);
                }
                //Opis i parametry osi wykresu
                var xAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, "czas [s]")
                {
                    MajorGridlineStyle =
                        OxyPlot.LineStyle.Solid,
                    MinorGridlineStyle = OxyPlot.LineStyle.Dot
                };

                plotModel.Axes.Add(xAxis);
                var yAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, "% udziału czasu")
                {
                    MajorGridlineStyle =
                        OxyPlot.LineStyle.Solid,
                    MinorGridlineStyle = OxyPlot.LineStyle.Dot
                };

                plotModel.Axes.Add(yAxis);
            }
 public void AddLineSerias(string name, List <Data> datas)
 {
     OxyPlot.Series.LineSeries linearAxis = new OxyPlot.Series.LineSeries()
     {
         Title = name
     };
     foreach (var d in datas)
     {
         this.MyModel.Series.Add(linearAxis);
         linearAxis.Points.Add(new DataPoint(d.Category, d.Value));
     }
     this.MyModel.Series.Add(linearAxis);
 }
Exemple #20
0
        private void AddLineSeries(PlotModel model, int index, string title)
        {
            var ls = new LineSeries
            {
                StrokeThickness             = 1,
                MarkerType                  = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                Title  = string.Format(title, index),
                Smooth = false,
                Color  = index == 0 ? OxyColors.Orange : OxyColors.LightBlue
            };

            model.Series.Add(ls);
        }
Exemple #21
0
        /*
         * transformation des valeurs du modèle dans des objets observables par la vue
         * */
        private PlotModel ToObservableView(List <PricingResults> pricingResults, List <Portefeuille> portefeuilles)
        {
            PlotModel model = new PlotModel();

            LineSeries plotOption       = new OxyPlot.Series.LineSeries();
            LineSeries plotPortefeuille = new OxyPlot.Series.LineSeries();

            drawOption(pricingResults, plotOption);
            drawPortefeuille(portefeuilles, plotPortefeuille);
            model.Series.Add(plotOption);
            model.Series.Add(plotPortefeuille);

            return(model);
        }
Exemple #22
0
        public void A00_NoAxesDefined()
        {
            var plot = new PlotModel { Title = "Simple plot without axes defined" };

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(3, 13));
            ls.Points.Add(new DataPoint(10, 47));
            ls.Points.Add(new DataPoint(30, 23));
            ls.Points.Add(new DataPoint(40, 65));
            ls.Points.Add(new DataPoint(80, 10));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A00");
        }
        void Render(SprintData data)
        {
            var model = new PlotModel
            {
                Title = data.Name,
                Axes  =
                {
                    new CategoryAxis {
                        Title = "Day", Position = AxisPosition.Bottom
                    },
                    new LinearAxis
                    {
                        Title              = "Points",
                        Position           = AxisPosition.Left,
                        MinorGridlineStyle = LineStyle.Solid,
                        MajorGridlineStyle = LineStyle.Solid,
                        MinimumPadding     = 0.0,
                        MaximumPadding     = 0.1
                    }
                },
                IsLegendVisible = true,
                LegendPlacement = LegendPlacement.Outside
            };
            var sustain = new SprintCheckpoint
            {
                Done  = 0,
                Total = data.Checkpoints.Select(c => c.Total).LastOrDefault()
            };
            var days            = data.Checkpoints.Concat(Enumerable.Repeat(sustain, data.Duration - data.Checkpoints.Count));
            var completedSeries = new ColumnSeries {
                Title = "Done"
            };

            foreach (var day in days)
            {
                completedSeries.Items.Add(new ColumnItem(day.Done));
            }
            model.Series.Add(completedSeries);
            var totalSeries = new LineSeries {
                Title = "Scope"
            };
            var i = 0;

            foreach (var day in days)
            {
                totalSeries.Points.Add(new DataPoint(i++, day.Total));
            }
            model.Series.Add(totalSeries);
            this.plot.Model = model;
        }
        private void PlotGraph()
        {
            PlotData = new PlotModel();
            var yAxis = new OxyPlot.Axes.LinearAxis {
                Position           = AxisPosition.Left,
                Title              = "Fiber Attenuation",
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.None
            };
            var xAxis = new OxyPlot.Axes.LinearAxis {
                Position           = AxisPosition.Bottom,
                Title              = "Wavelengths (nm)",
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.None
            };

            PlotData.Axes.Add(xAxis);
            PlotData.Axes.Add(yAxis);
            DataPoint[]    linePoints   = new DataPoint[loss.Count];
            ScatterPoint[] markerPoints = new ScatterPoint[loss.Count];
            for (int i = 0; i < loss.Count; i++)
            {
                if (markers.Contains(wavelengths[i]))
                {
                    markerPoints[i] = new ScatterPoint((double)wavelengths[i], (double)loss[i]);
                }
                else
                {
                    markerPoints[i] = new ScatterPoint((double)wavelengths[i], 0);
                }
                linePoints[i] = new DataPoint((double)wavelengths[i], (double)loss[i]);
            }



            var lineSeries = new OxyPlot.Series.LineSeries {
                StrokeThickness = 2,
                ItemsSource     = linePoints
            };
            var circleSeries = new OxyPlot.Series.ScatterSeries {
                MarkerSize = 3,
                MarkerType = MarkerType.Circle
            }; // W850 TO W1550 S10;

            circleSeries.Points.AddRange(markerPoints.Where(i => i.Y > 0));
            PlotData.Series.Add(lineSeries);
            PlotData.Series.Add(circleSeries);
            PlotData.InvalidatePlot(true);
        }
Exemple #25
0
        private void CreatePLByStrategyChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position     = OxyPlot.Axes.AxisPosition.Bottom,
                StringFormat = "yyyy-MM-dd"
            };

            model.Axes.Add(xAxis);

            var yAxis = new OxyPlot.Axes.LinearAxis
            {
                Position           = OxyPlot.Axes.AxisPosition.Left,
                StringFormat       = "c0",
                MajorGridlineStyle = LineStyle.Dash
            };

            model.Axes.Add(yAxis);

            foreach (DataColumn column in Data.StrategyPLCurves.Columns)
            {
                if (column.ColumnName == "date")
                {
                    continue;
                }

                DataColumn column1 = column;
                var        series  = new OxyPlot.Series.LineSeries
                {
                    ItemsSource = Data.StrategyPLCurves.Select(x => new { X = x.date, Y = x.Field <double>(column1.ColumnName) }),
                    Title       = column.ColumnName,
                    CanTrackerInterpolatePoints = false,
                    TrackerFormatString         = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} P/L: {4:c0}",
                    DataFieldX = "X",
                    DataFieldY = "Y",
                    MarkerType = MarkerType.None
                };
                model.Series.Add(series);
            }

            model.LegendPosition    = LegendPosition.BottomCenter;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement   = LegendPlacement.Outside;

            PLByStrategyModel = model;
        }
Exemple #26
0
        public void A01_SimpleAxes()
        {
            var plot = new PlotModel { Title = "Simple plot" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(3, 13));
            ls.Points.Add(new DataPoint(10, 47));
            ls.Points.Add(new DataPoint(30, 23));
            ls.Points.Add(new DataPoint(40, 65));
            ls.Points.Add(new DataPoint(80, 10));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A01");
        }
Exemple #27
0
        public void A02_ReversedAxes()
        {
            var plot = new PlotModel { Title = "Reversed axes" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", StartPosition = 1, EndPosition = 0 });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", StartPosition = 1, EndPosition = 0 });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(0, 13));
            ls.Points.Add(new DataPoint(10, 47));
            ls.Points.Add(new DataPoint(30, 23));
            ls.Points.Add(new DataPoint(40, 65));
            ls.Points.Add(new DataPoint(80, 10));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A02");
        }
        public void TestNoData()
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            LineSeries input  = new LineSeries("", Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(0, series.ItemsSource.Count());
        }
Exemple #29
0
        public void Reset()
        {
            LineSeries ls = _plotModelPer.Series[0] as LineSeries;

            ls.Points.Clear();
            ls = _plotModelPer.Series[1] as LineSeries;
            ls.Points.Clear();
            ls = _plotModelTick.Series[0] as LineSeries;
            ls.Points.Clear();

            HighLowSeries hls = PlotModelTick.Series[1] as HighLowSeries;

            hls.Items.Clear();
            hls = PlotModelTick.Series[2] as HighLowSeries;
            hls.Items.Clear();
        }
Exemple #30
0
        public void GetStatistic()
        {
            Random rand = new Random();

            double[] y = new double[N];
            for (int i = 0; i < N; i++)
            {
                double ksi = rand.NextDouble();
                double x = ksi * (b - a) + a;
                y[i] = Math.Abs(Math.Cos(x));
            }

            double[] v = y.OrderBy((x) => x).ToArray();
            double[] F = new double[N];
            for (int i = 0; i < N; i++)
            {
                int w = 0;
                for (int j = 0; j < N; j++)
                    if (v[i] == v[j]) w++;

                F[i] = (double)w / N;
                if (i > 0) F[i] += F[i - 1];
            }

            VariationArray = v;
            EmpiricalFunction = new LineSeries() { Title = "Эмпирическая функция распределения" };
            for (int i = 0; i < N; i++)
            {
                EmpiricalFunction.Points.Add(new DataPoint(v[i], (i > 0) ? F[i - 1] : 0));
                EmpiricalFunction.Points.Add(new DataPoint(v[i], F[i]));
            }

            Func<double, double> tF = (arg) =>
            {
                if (arg < 0)
                    return 0;
                else if (arg >= 1)
                    return 1;
                else if (arg >= 0 && arg < Math.Cos(a))
                    return (-2 * Math.Acos(arg) + Math.PI) / 4;
                else if (arg >= Math.Cos(a) && arg < -Math.Cos(b))
                    return (Math.PI - 3 * Math.Acos(arg) - a) / 4;
                else
                    return (-2 * Math.Acos(arg) - a + b) / 4;
            };
            TheoreticalFunction = new FunctionSeries(tF, 0, 1, dx) { Title = "Теоретическая" };
        }
        /// <summary>
        /// Constructor for graphing a pixel
        /// </summary>
        /// <param name="data">The data to graph</param>
        /// <param name="x">The x coordinate of the selected pixel</param>
        /// <param name="y">The y coordinate of the selected pixel</param>
        /// <param name="wavelength">The wavelength of the current image</param>
        public Graph(float[] data, int x, int y, int wavelength)
        {
            InitializeComponent();

            this.Title = "Graph for pixel (" + x + ", " + y + ")";

            this.data = data;
            this.x    = x;
            this.y    = y;

            // Create the plot model
            var tmp = new PlotModel {
                Title = "Spectrum", Subtitle = "for (" + x + ", " + y + ")"
            };

            // Create two line series (markers are hidden by default)
            var series1 = new OxyPlot.Series.LineSeries {
                Title = "Pixel values for (" + x + ", " + y + ")", MarkerType = MarkerType.Circle
            };

            for (int i = 0; i < data.Length; i++)
            {
                series1.Points.Add(new DataPoint(LOWEST_WAVELENGTH + (i * WAVELENGTH_INCREMENT), data[i]));
            }

            // Add the series to the plot model
            tmp.Series.Add(series1);

            // Set the titles for the x-axis and y-axis
            tmp.Axes.Add(new OxyPlot.Axes.LinearAxis {
                Position = AxisPosition.Bottom, Title = "Wavelengths (nm)", TitleColor = OxyColors.Red
            });
            tmp.Axes.Add(new OxyPlot.Axes.LinearAxis {
                Position = AxisPosition.Left, Title = "Pixel values", TitleColor = OxyColors.Blue
            });

            // Add an annotation that indicates which wavelength was clicked on
            tmp.Annotations.Add(new OxyPlot.Annotations.LineAnnotation {
                Type = LineAnnotationType.Vertical, X = wavelength, MaximumY = 255, Color = OxyColors.Green, Text = "Wavelength: " + wavelength + " nm"
            });

            // Set the Model property, the INotifyPropertyChanged event will make the WPF Plot control update its content
            this.Model       = tmp;
            this.DataContext = this;

            this.graphType = GraphType.PIXEL;
        }
Exemple #32
0
        internal void AddSeries(OxyPlot.MarkerType showType, OxyPlot.OxyColor color, string title, List <double> X, List <double> Y)
        {
            OxyPlot.Series.LineSeries seriesPoints = new OxyPlot.Series.LineSeries
            {
                MarkerType   = showType,
                MarkerSize   = 9,
                MarkerStroke = chartColors[1],
                Title        = title
            };

            for (int n = 0; n < X.Count; n++)
            {
                seriesPoints.Points.Add(new OxyPlot.DataPoint(X[n], Y[n]));
            }

            plotModel.Series.Add(seriesPoints);
        }
        /// <summary>
        /// Create a series with the given marker size, conver it to an oxyplot
        /// series, and return the generated series' marker size.
        /// </summary>
        /// <param name="markerSize">Desired marker size.</param>
        private double GetExportedMarkerSize(MarkerSize markerSize)
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.Solid, LineThickness.Normal);
            Marker     marker      = new Marker(MarkerType.FilledCircle, markerSize, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            return(series.MarkerSize);
        }
        /// <summary>
        /// Create a series with the given title and 'show on legend' value.
        /// Then convert to an oxyplot series and ensure that the generated
        /// series' title matches the specified expected value.
        /// </summary>
        /// <param name="title">Input title.</param>
        /// <param name="showOnLegend">Input value for 'show on legend'.</param>
        /// <param name="expectedTitle">Expected title of the oxyplot series.</param>
        private void TestShowOnLegend(string title, bool showOnLegend, string expectedTitle)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries(title, Color.Black, false, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.Null(series.Title);
        }
        /// <summary>
        /// Create a series with the given System.Drawing.Color and marker type,
        /// then convert to an oxyplot series and ensure that the generated series'
        /// marker colour matches the given colour.
        /// </summary>
        /// <param name="inputColour">Colour to use when creating the series.</param>
        /// <param name="markerType">Marker type for the created series.</param>
        /// <param name="expectedOutput">Expected colour of the output series.</param>
        private void TestMarkerColour(Color inputColour, MarkerType markerType, OxyColor expectedOutput)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(markerType, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", inputColour, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(expectedOutput, series.MarkerFill);
        }
Exemple #36
0
        public void C01_DateTimeAxis()
        {
            var plot = new PlotModel { Title = "DateTime axis", PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Title = "DateTime X",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -46,
                MajorStep = 1
            };
            var yaxis = new DateTimeAxis
            {
                Position = AxisPosition.Left,
                Title = "DateTime Y",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -45,
                MajorStep = 1
            };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 1), new DateTime(2011, 3, 1)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 4), new DateTime(2011, 3, 8)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 6), new DateTime(2011, 3, 12)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 10), new DateTime(2011, 3, 13)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 19), new DateTime(2011, 3, 14)));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C01");
        }
Exemple #37
0
        public void C03_DateTimeAxis_WithAllUndefinedPoints()
        {
            var plot = new PlotModel { Title = "DateTime axis", PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Title = "DateTime X",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -46,
                MajorStep = 1
            };
            var yaxis = new DateTimeAxis
            {
                Position = AxisPosition.Left,
                Title = "DateTime Y",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -45,
                MajorStep = 1
            };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(double.NaN, double.NaN));
            ls.Points.Add(new DataPoint(double.NaN, double.NaN));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C03");
        }
        /// <summary>
        /// The mobility fit FitLine plot.
        /// </summary>
        /// <param name="fitline">
        /// The fitline.
        /// </param>
        /// <returns>
        /// The <see cref="PlotModel"/>.
        /// </returns>
        private PlotModel MobilityFitLinePlot(FitLine fitline)
        {
            IEnumerable<ContinuousXYPoint> fitPointList = fitline.FitPointCollection.Select(x => x.Point);
            IEnumerable<ContinuousXYPoint> outlierList = fitline.OutlierCollection.Select(x => x.Point);
            Func<object, ScatterPoint> fitPointMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double size = 5;
                double color = 0;
                ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color);
                return sp;
            };

            Func<object, ScatterPoint> OutlierPointMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double size = 5;
                double color = 1;
                ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color);
                return sp;
            };

            PlotModel model = new PlotModel();
            model.TitlePadding = 0;
            model.Title = "Mobility Fit FitLine";

            ScatterSeries fitPointSeries = new ScatterSeries
            {
                Mapping = fitPointMap,
                ItemsSource = fitPointList,
            };

            ScatterSeries outlierSeries = new ScatterSeries
            {
                Mapping = OutlierPointMap,
                ItemsSource = outlierList,
            };

            Func<object, DataPoint> lineMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double x = point.X;
                double y = fitline.ModelPredictX2Y(x);
                DataPoint sp = new DataPoint(x, y);
                return sp;
            };

            LineSeries fitlineSeries = new LineSeries()
            {
                Mapping = lineMap,
                ItemsSource = fitPointList,
                Color = OxyColors.Purple
            };

            var yAxis = new LinearAxis()
            {
                Title = "IMS scan time (milliseconds)",
                MajorGridlineStyle = LineStyle.Solid,
                Position = AxisPosition.Left,

                //MajorStep = 100.0,
                //MinorStep = 50.0,
                //Minimum = 0,
                //Maximum = 360,
                //FilterMinValue = 0,
                //FilterMaxValue = 360,
            };

            var xAxis = new LinearAxis()
            {
                Title = "Pressure / (Temperature * Voltage) (1 / V))",
                Position = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                //MajorStep = 100.0,
                //MinorStep = 50.0,
                //Minimum = 1000,
                //Maximum = 2000,
                //MinimumRange = 100.0,
                //FilterMinValue = 1000,
                //FilterMaxValue = 2000,
            };

            model.Axes.Add(yAxis);
            model.Axes.Add(xAxis);
            model.Series.Add(fitPointSeries);
            model.Series.Add(outlierSeries);
            model.Series.Add(fitlineSeries);
            return model;
        }
        public void C02_DateTimeAxis_WithSomeUndefinedPoints()
        {
            var plot = new PlotModel("DateTime axis") { PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis(AxisPosition.Bottom, "DateTime X", null, DateTimeIntervalType.Days) { Angle = -46, MajorStep = 1 };
            var yaxis = new DateTimeAxis(AxisPosition.Left, "DateTime Y", null, DateTimeIntervalType.Days) { Angle = -45, MajorStep = 1 };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 1), new DateTime(2011, 3, 1)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(double.NaN, new DateTime(2011, 3, 8)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 6), new DateTime(2011, 3, 12)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 10), double.NaN));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 19), new DateTime(2011, 3, 14)));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C02");
        }
Exemple #40
0
        private void InitializeDisplacementPlot()
        {
            this.displacementPlot = new OxyPlot.WindowsForms.PlotView();
            this.SuspendLayout();
            this.displacementPlot.Dock = System.Windows.Forms.DockStyle.Fill;
            this.displacementPlot.Location = new System.Drawing.Point(0, 0);
            this.displacementPlot.Name = "displacementPlot";
            this.displacementPlot.PanCursor = System.Windows.Forms.Cursors.Hand;
            this.displacementPlot.Size = new System.Drawing.Size(200, 200);
            this.displacementPlot.TabIndex = 0;
            this.displacementPlot.Text = "displacement";
            this.displacementPlot.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
            this.displacementPlot.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
            this.displacementPlot.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;

            DisplacementPlotPanel.Controls.Add(this.displacementPlot);
            this.ResumeLayout(false);

            wSeries = new OxyPlot.Series.LineSeries();
            wSeries.Title = "w(t)";
            xSeries = new OxyPlot.Series.LineSeries();
            xSeries.Title = "x(t)";
            wxSeries = new OxyPlot.Series.LineSeries();
            wxSeries.Title = "w(t) - x(t)";
            var myModel = new PlotModel();
            myModel.Series.Add(wSeries);
            myModel.Series.Add(xSeries);
            myModel.Series.Add(wxSeries);
            this.displacementPlot.Model = myModel;
        }
Exemple #41
0
        public void UpdatePlots(PICMonitor monitor)
        {
            Task.Run(() =>
            {
                foreach (var model in Workspaces.Where(p => p.GetType() == typeof(PlotViewModel)).Cast<PlotViewModel>())
                {
                    switch (model.PICPlot.PlotType)
                    {
                        case PlotType.Heatmap:
                            switch (model.PICPlot.PlotSource)
                            {
                                case PlotSource.Density:
                                    model.HeatMapSeries.Data = monitor.Rho;
                                    break;
                                case PlotSource.Potential:
                                    model.HeatMapSeries.Data = monitor.Potential;
                                    break;
                                case PlotSource.ElectricFieldX:
                                    model.HeatMapSeries.Data = monitor.Ex;
                                    break;
                                case PlotSource.ElectricFieldY:
                                    model.HeatMapSeries.Data = monitor.Ey;
                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            model.HeatMapSeries.Invalidate();
                            model.PlotModel.InvalidatePlot(true);
                            break;
                        case PlotType.Line:
                            var lineSeries = new LineSeries { MarkerType = MarkerType.Circle };
                            var data = monitor.GetLine(model.PICPlot.PlotSource, model.PICPlot.LinePlotAlignment, model.PICPlot.LinePlotСoordinate);
                            for (var i = 0; i < data.Length; i++) lineSeries.Points.Add(new DataPoint(monitor.GridX[i], data[i]));
                            model.PlotModel.Series.Clear();
                            model.PlotModel.Series.Add(lineSeries);
                            model.PlotModel.InvalidatePlot(true);
                            break;
                        case PlotType.Trajectories:

                            model.PlotModel.Series.Clear();
                            foreach (var trajectory in monitor.Trajectories.OrderBy(x => x.First().Item3).Where((c, i) => i % 5 == 0))
                            {
                                var series = new LineSeries { MarkerType = MarkerType.None, LineStyle = LineStyle.Solid, Color = OxyColors.Black };
                                foreach (var point in trajectory) series.Points.Add(new DataPoint(point.Item2, point.Item3));
                                model.PlotModel.Series.Add(series);
                            }
                            model.PlotModel.InvalidatePlot(true);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
            });
        }
Exemple #42
0
        public void A16_TwoClosePoints()
        {
            var plot = new PlotModel { Title = "Two close points" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", MinimumRange = 1e-3 });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1, 2.4));
            ls.Points.Add(new DataPoint(1.000000000001, 2.4));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A16");
        }
Exemple #43
0
        public void A12_LargeRangeAxis()
        {
            var plot = new PlotModel { Title = "Large range axis", PlotMargins = new OxyThickness(80, 60, 50, 50) };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1e40, 1e38));
            ls.Points.Add(new DataPoint(1.2e40, 1.9e38));
            ls.Points.Add(new DataPoint(1.4e40, 3.3e38));
            ls.Points.Add(new DataPoint(1.6e40, 2.5e38));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A12");
        }
Exemple #44
0
        public void A14_ConstantValue()
        {
            var plot = new PlotModel { Title = "Constant value" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1, 2.4));
            ls.Points.Add(new DataPoint(2, 2.4));
            ls.Points.Add(new DataPoint(3, 2.4));
            ls.Points.Add(new DataPoint(4, 2.4));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A14");
        }
Exemple #45
0
        public void A15_SinglePoint()
        {
            var plot = new PlotModel { Title = "Single point" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1, 2.4));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A15");
        }
Exemple #46
0
        public void A13B_BadConditionedAxis_SettingMinimumRange()
        {
            var plot = new PlotModel
            {
                Title = "Bad conditioned axis with MinimumRange",
                PlotMargins = new OxyThickness(80, 60, 50, 50)
            };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", MinimumRange = 1e-3 });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", MinimumRange = 1e8, StringFormat = "0.00E00" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1.20000000001, 2400000001));
            ls.Points.Add(new DataPoint(1.20000000002, 2400000000));
            ls.Points.Add(new DataPoint(1.20000000004, 2400000004));
            ls.Points.Add(new DataPoint(1.20000000007, 2400000003));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A13B");
        }
Exemple #47
0
        public void A13_BadConditionedAxis()
        {
            var plot = new PlotModel { Title = "Bad conditioned axis", PlotMargins = new OxyThickness(80, 60, 50, 50) };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1.20000000001, 2400000001));
            ls.Points.Add(new DataPoint(1.20000000002, 2400000000));
            ls.Points.Add(new DataPoint(1.20000000004, 2400000004));
            ls.Points.Add(new DataPoint(1.20000000007, 2400000003));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A13");
        }
Exemple #48
0
        private void UpdateData2(double[] valPortef, double[] valBenchmark)
        {
            var tmp = new PlotModel { Title = "Valeur du portefeuille vs Benchmark (Zoom)" };

            var series1 = new OxyPlot.Series.LineSeries { Title = "Portefeuille", MarkerType = MarkerType.Circle };
            for (int i = 0; i < valPortef.Length; i++)
            {
                series1.Points.Add(new DataPoint(i, valPortef[i]));
            }

            var series2 = new OxyPlot.Series.LineSeries { Title = "Benchmark", MarkerType = MarkerType.Circle };
            for (int i = 0; i < valBenchmark.Length; i++)
            {
                series2.Points.Add(new DataPoint(i, valBenchmark[i]));
            }

            tmp.Series.Add(series1);
            tmp.Series.Add(series2);
            this.PlotModel2 = tmp;
            this.PlotModel2.Axes.Add(new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
        }
Exemple #49
0
        private void InitializeTrajectoryPlot()
        {
            this.trajectoryPlot = new OxyPlot.WindowsForms.PlotView();
            this.SuspendLayout();
            this.trajectoryPlot.Dock = System.Windows.Forms.DockStyle.Fill;
            this.trajectoryPlot.Location = new System.Drawing.Point(0, 0);
            this.trajectoryPlot.Name = "trajectoryPlot";
            this.trajectoryPlot.PanCursor = System.Windows.Forms.Cursors.Hand;
            this.trajectoryPlot.Size = new System.Drawing.Size(200, 200);
            this.trajectoryPlot.TabIndex = 0;
            this.trajectoryPlot.Text = "trajectory";
            this.trajectoryPlot.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
            this.trajectoryPlot.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
            this.trajectoryPlot.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;

            TrajectoryPlotPanel.Controls.Add(this.trajectoryPlot);
            this.ResumeLayout(false);

            trajectorySeries = new OxyPlot.Series.LineSeries();
            var myModel = new PlotModel { Title = "Trajectory" };
            myModel.Series.Add(trajectorySeries);
            this.trajectoryPlot.Model = myModel;

            using (StreamWriter outputFile = new StreamWriter("Pages.txt"))
            {
                int start = 21;
                var line = "";
                while (start <= 120)
                {
                    line = line + start + ",";
                    start++;
                    line = line + start + ",";
                    start+=3;
                }
                line.Remove(line.Length - 1);
                outputFile.WriteLine(line);

                start = 23;
                line = "";
                while (start <= 120)
                {
                    line = line + start + ",";
                    start++;
                    line = line + start + ",";
                    start+=3;
                }
                line.Remove(line.Length - 1);
                outputFile.WriteLine(line);
            }
        }
Exemple #50
0
        public void B01_LogarithmicAxis()
        {
            var plot = new PlotModel { Title = "Logarithmic axis" };
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1.2, 3.3));
            ls.Points.Add(new DataPoint(10, 30));
            ls.Points.Add(new DataPoint(100, 20));
            ls.Points.Add(new DataPoint(1000, 400));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "B01");
        }
Exemple #51
0
        private void InitializeKinematicsPlot()
        {
            this.kinematicsPlot = new OxyPlot.WindowsForms.PlotView();
            this.SuspendLayout();
            this.kinematicsPlot.Dock = System.Windows.Forms.DockStyle.Fill;
            this.kinematicsPlot.Location = new System.Drawing.Point(0, 0);
            this.kinematicsPlot.Name = "KinematicsPlot";
            this.kinematicsPlot.PanCursor = System.Windows.Forms.Cursors.Hand;
            this.kinematicsPlot.Size = new System.Drawing.Size(200, 200);
            this.kinematicsPlot.TabIndex = 0;
            this.kinematicsPlot.Text = "Kinematics";
            this.kinematicsPlot.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
            this.kinematicsPlot.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
            this.kinematicsPlot.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;

            KinematicsPlotPanel.Controls.Add(this.kinematicsPlot);
            this.ResumeLayout(false);

            positionSeries = new OxyPlot.Series.LineSeries();
            positionSeries.Title = "x(t)";
            velocitySeries = new OxyPlot.Series.LineSeries();
            velocitySeries.Title = "v(t)";
            accelerationSeries = new OxyPlot.Series.LineSeries();
            accelerationSeries.Title = "a(t)";
            errorSeries = new OxyPlot.Series.LineSeries();
            errorSeries.Title = "err(t)";
            var myModel = new PlotModel { Title = "Kinematics" };
            myModel.Series.Add(positionSeries);
            myModel.Series.Add(velocitySeries);
            myModel.Series.Add(accelerationSeries);
            myModel.Series.Add(errorSeries);
            this.kinematicsPlot.Model = myModel;
        }
Exemple #52
0
        public void B02_LogarithmicAxis()
        {
            var plot = new PlotModel { Title = "Logarithmic axis" };
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1, 12));
            ls.Points.Add(new DataPoint(3, 14));
            ls.Points.Add(new DataPoint(24, 18));
            ls.Points.Add(new DataPoint(27, 19));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "B02");
        }
Exemple #53
0
        private void InitializeForcesPlot()
        {
            this.forcesPlot = new OxyPlot.WindowsForms.PlotView();
            this.SuspendLayout();
            this.forcesPlot.Dock = System.Windows.Forms.DockStyle.Fill;
            this.forcesPlot.Location = new System.Drawing.Point(0, 0);
            this.forcesPlot.Name = "ForcesPlot";
            this.forcesPlot.PanCursor = System.Windows.Forms.Cursors.Hand;
            this.forcesPlot.Size = new System.Drawing.Size(200, 200);
            this.forcesPlot.TabIndex = 0;
            this.forcesPlot.Text = "Forces";
            this.forcesPlot.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
            this.forcesPlot.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
            this.forcesPlot.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;

            ForcesPlotPanel.Controls.Add(this.forcesPlot);
            this.ResumeLayout(false);

            fSeries = new OxyPlot.Series.LineSeries();
            fSeries.Title = "f(t)";
            gSeries = new OxyPlot.Series.LineSeries();
            gSeries.Title = "g(t)";
            hSeries = new OxyPlot.Series.LineSeries();
            hSeries.Title = "h(t)";
            var myModel = new PlotModel { Title = "Forces" };
            myModel.Series.Add(fSeries);
            myModel.Series.Add(gSeries);
            myModel.Series.Add(hSeries);
            this.forcesPlot.Model = myModel;
        }
Exemple #54
0
        public void B03_LogarithmicAxis()
        {
            var plot = new PlotModel { Title = "Logarithmic axis" };
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "X-axis" });
            plot.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Title = "Y-axis" });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1e10, 1e18));
            ls.Points.Add(new DataPoint(1.2e20, 1.9e28));
            ls.Points.Add(new DataPoint(1.4e30, 3.3e30));
            ls.Points.Add(new DataPoint(1.6e40, 2.5e38));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "B03");
        }
 private void ExtractComponents()
 {
     //foreach (var comp in ComponentInfoList)
     //{
     //    if (comp.IsSelected)
     //    {
     //        Console.WriteLine(comp.Name);
     //        Console.WriteLine(comp.Poids);
     //    }
     //}
     //Console.WriteLine(maturite);
     //Console.WriteLine(strikePrice);
     //Console.WriteLine(dateDebut);
     //Console.WriteLine(typeDonnees);
     //Console.WriteLine(dureeEstimation);
     //SetUpModel();
     //this.MyModel = new PlotModel { Title = "Example 1" };
     //this.MyModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));
     MyModel = new PlotModel();
     OxyPlot.Series.LineSeries courbe = new OxyPlot.Series.LineSeries();
     courbe.Points.Add(new OxyPlot.DataPoint(0, 1));
     courbe.Points.Add(new OxyPlot.DataPoint(0, 2));
     courbe.Points.Add(new OxyPlot.DataPoint(0, 1));
     MyModel.Series.Add(courbe);
 }
Exemple #56
0
        public void B04_LogarithmicAxis_Padding()
        {
            var plot = new PlotModel { Title = "Logarithmic axis with padding" };
            plot.Axes.Add(
                new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "X-axis", MinimumPadding = 0.3, MaximumPadding = 0.3 });
            plot.Axes.Add(
                new LogarithmicAxis { Position = AxisPosition.Left, Title = "Y-axis", MinimumPadding = 0.3, MaximumPadding = 0.3 });

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1, 12));
            ls.Points.Add(new DataPoint(3, 14));
            ls.Points.Add(new DataPoint(24, 18));
            ls.Points.Add(new DataPoint(27, 19));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "B04");
        }
Exemple #57
0
 OxyPlot.Series.LineSeries CreateDefaultLineSeries(double thickness)
 {
     var lineSeries1 = new OxyPlot.Series.LineSeries();
     lineSeries1.Color = OxyColors.Black;
     lineSeries1.LineStyle = LineStyle.Solid;
     lineSeries1.StrokeThickness = thickness;
     lineSeries1.MarkerSize = thickness/3;
     lineSeries1.MarkerStroke = OxyColors.Black;
     lineSeries1.MarkerStrokeThickness = thickness;
     lineSeries1.MarkerType = MarkerType.Square;
     lineSeries1.Title = "Net Lines";
     return lineSeries1;
 }
Exemple #58
0
        private void LoadData2(double[] valPortef, double[] valBenchmark)
        {
            var tmp = new PlotModel { Title = "Rendements du portefeuille vs Benchmark" };

            var series1 = new OxyPlot.Series.LineSeries { Title = "Portefeuille", MarkerType = MarkerType.None };
            int j = 0;
            while (Date[j] != TDebut)
            {
                j++;
            }
            TimeSpan diff;
            for (int i = 0; i < valPortef.Length; i++)
            {
                diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0);
                series1.Points.Add(new DataPoint(diff.TotalDays, valPortef[i]));
            }

            var series2 = new OxyPlot.Series.LineSeries { Title = "Benchmark", MarkerType = MarkerType.None };
            for (int i = 0; i < valBenchmark.Length; i++)
            {
                diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0);
                series2.Points.Add(new DataPoint(diff.TotalDays, valBenchmark[i]));
            }

            tmp.Series.Add(series1);
            tmp.Series.Add(series2);

            var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
            //dateAxis.Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(TDebut);
            //dateAxis.Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(TFin);
            dateAxis.IntervalType = DateTimeIntervalType.Months;
            tmp.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value", IntervalLength = 50 };
            tmp.Axes.Add(valueAxis);
            this.PlotModel2 = tmp;
        }
 public LineSeries tabToSeries(List<double> tabValue, List<DateTime> dateTab)
 {
     int i = 0;
     OxyPlot.Series.LineSeries courbe = new OxyPlot.Series.LineSeries();
     foreach (double value in tabValue)
     {
         DataPoint pointTmp = DateTimeAxis.CreateDataPoint(dateTab[i], value);
         courbe.Points.Add(pointTmp);
         i++;
     }
     return courbe;
 }
        public void A11_SmallRangeAxis()
        {
            var plot = new PlotModel("Small range axis") { PlotMargins = new OxyThickness(80, 60, 50, 50) };
            plot.Axes.Add(new LinearAxis(AxisPosition.Bottom, "X-axis"));
            plot.Axes.Add(new LinearAxis(AxisPosition.Left, "Y-axis"));

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(1e-40, 1e-38));
            ls.Points.Add(new DataPoint(1.2e-40, 1.9e-38));
            ls.Points.Add(new DataPoint(1.4e-40, 3.3e-38));
            ls.Points.Add(new DataPoint(1.6e-40, 2.5e-38));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "A11");
        }