Example #1
0
        public static PlotModel MouseDownEventHitTestResult()
        {
            var model = new PlotModel {
                Title = "MouseDown HitTestResult", Subtitle = "Reports the index of the nearest point."
            };

            var s1 = new LineSeries();

            s1.Points.Add(new DataPoint(0, 10));
            s1.Points.Add(new DataPoint(10, 40));
            s1.Points.Add(new DataPoint(40, 20));
            s1.Points.Add(new DataPoint(60, 30));
            model.Series.Add(s1);
            s1.MouseDown += (s, e) =>
            {
                model.Subtitle = "Index of nearest point in LineSeries: " + Math.Round(e.HitTestResult.Index);
                model.InvalidatePlot(false);
            };

            var s2 = new ScatterSeries();

            s2.Points.Add(new ScatterPoint(0, 15));
            s2.Points.Add(new ScatterPoint(10, 45));
            s2.Points.Add(new ScatterPoint(40, 25));
            s2.Points.Add(new ScatterPoint(60, 35));
            model.Series.Add(s2);
            s2.MouseDown += (s, e) =>
            {
                model.Subtitle = "Index of nearest point in ScatterSeries: " + (int)e.HitTestResult.Index;
                model.InvalidatePlot(false);
            };

            return(model);
        }
        private void InitCircleCursorEvent()
        {
            ellipse.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }
                MousePressed            = true;
                ellipse.StrokeThickness = 1;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            ellipse.MouseMove += (s, e) =>
            {
                ellipse.X = ellipse.InverseTransform(e.Position).X;
                ellipse.Y = ellipse.InverseTransform(e.Position).Y;

                this.UpdateRadiusLine();
                if (this.CircleCursorParameterChanged != null)
                {
                    this.CircleCursorParameterChanged(this, null);
                }
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            ellipse.MouseUp += (s, e) =>
            {
                MousePressed            = false;
                ellipse.StrokeThickness = 3;
                e.Handled = false;
            };
        }
Example #3
0
        //Обновление графика
        private void SetupPlotMod()
        {
            ClearPlot();
            PlotMod.Title = "График зависимости давления от глубины выбранной скважины";

            PlotMod.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Title    = "Глубина скважины, м"
            });
            PlotMod.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Left,
                Title    = "Давление, Па"
            });

            LineSeries lineSeries = new LineSeries();

            foreach (var point in SelectedWellPressureList)
            {
                lineSeries.Points.Add(point);
            }

            PlotMod.Series.Add(lineSeries);
            PlotMod.InvalidatePlot(true);
        }
Example #4
0
        public static PlotModel Hover()
        {
            var model = new PlotModel {
                Title = "Hover"
            };
            LineSeries series = null;

            model.MouseEnter += (s, e) =>
            {
                model.Subtitle = "The mouse entered";
                series         = new LineSeries();
                model.Series.Add(series);
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.MouseMove += (s, e) =>
            {
                if (series != null && series.XAxis != null)
                {
                    series.Points.Add(series.InverseTransform(e.Position));
                    model.InvalidatePlot(false);
                }
            };

            model.MouseLeave += (s, e) =>
            {
                model.Subtitle = "The mouse left";
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            return(model);
        }
Example #5
0
        private void buildAllGraphs(int len, ref string lastChoice, ref int lastLine)
        {
            if (!currerntChoice.Equals(lastChoice))
            {
                correlatedChoice = correlatedProperty(currerntChoice);
            }
            // build current Graph
            LineSeries l = new LineSeries();

            buildOneGraph(plotModelCurrent, l, currerntChoice);

            if (!correlatedChoice.Equals(""))
            {
                // build correlatedChoice
                LineSeries line = new LineSeries();
                buildOneGraph(plotModelCurrentCorrelation, line, correlatedChoice);

                // build linearReg
                buildLinearRegressionGraph(len);
            }
            else
            {
                plotModelCurrentCorrelation.Series.Clear();
                plotModelRegression.Series.Clear();
                plotModelCurrentCorrelation.Title = "No correlated feature";
                plotModelCurrentCorrelation.InvalidatePlot(true);
                plotModelRegression.InvalidatePlot(true);
            }
            lastLine   = currentLine;
            lastChoice = currerntChoice;
        }
Example #6
0
        public void RunWorker2Completed(Object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Произошла ошибка");
            }
            else
            {
                var resultCurrencies = (CCurrencyPairTimePrint[])e.Result;

                var series1 = new LineSeries {
                    Title = "Series 1", MarkerType = MarkerType.Star
                };
                DateTime start = new DateTime(2000, 01, 01);
                series1.Points.Add(new DataPoint(0, 0));

                foreach (var t in resultCurrencies)
                {
                    Double x = (t.Time - start).TotalHours;
                    series1.Points.Add(new DataPoint(x, t.Rate));
                }

                _model.Series.Add(series1);
                _model.Axes.Add(new LinearAxis {
                    Position = OxyPlot.Axes.AxisPosition.Bottom, Minimum = 0, Maximum = 10000
                });
                _model.Axes.Add(new LinearAxis {
                    Position = OxyPlot.Axes.AxisPosition.Left, Minimum = 0, Maximum = 2
                });

                RaisePropertyChanged("Model");
                _model.InvalidatePlot(true);
            }
        }
Example #7
0
        private void ShowLimitConfigWindow()
        {
            LimitConfigViewModel limitVM = new LimitConfigViewModel(StartPoint, EndPoint, LimitLineSeries, CurrentLoadedSymbol, CurrentMinTradeSize);
            LimitCondig          lc      = new LimitCondig(limitVM);

            lc.ShowDialog();
            if (limitVM.LineOrder != null)
            {
                ActiveLineOrders.Insert(0, limitVM.LineOrder);
                OverrideAddingUpcoming();
                LimitLineSeries = limitVM.LineOrder.LimitLineSeries;
                plotmodel.InvalidatePlot(true);

                OnPropertyChanged("ActiveLineOrders");
            }
            else
            {
                if (plotmodel.Series.Any(l => l.Title == "Limit Line"))
                {
                    var match = plotmodel.Series.First(l => l.Title == "Limit Line");
                    plotmodel.Series.Remove(LimitLineSeries);
                }
                LimitLineSeries = null;
            }
        }
Example #8
0
        public static PlotModel TouchSeries()
        {
            var model = new PlotModel {
                Title = "Touch on a LineSeries"
            };
            var series = new LineSeries();

            series.Points.Add(new DataPoint(0, 0));
            series.Points.Add(new DataPoint(10, 10));
            model.Series.Add(series);

            series.TouchStarted += (s, e) =>
            {
                model.Subtitle = "The touch gesture started on the LineSeries";
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            series.TouchDelta += (s, e) =>
            {
                series.Points.Add(series.InverseTransform(e.Position));
                model.InvalidatePlot(false);
            };

            series.TouchCompleted += (s, e) =>
            {
                model.Subtitle = "The touch gesture completed";
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            return(model);
        }
Example #9
0
        public void LoadCharts()
        {
            if (SelectedRecipe == null)
            {
                return;
            }
            if (SelectedRecipe.SelectedLot == null)
            {
                return;
            }
            if (SelectedRecipe.SelectedLot.Rounds == null)
            {
                return;
            }
            if (SelectedRecipe.SelectedLot.Rounds.Count == 0)
            {
                return;
            }
            _PerformancePlot.Series.Clear();
            _PerformancePlot.Axes.Clear();
            _PerformancePlot.Annotations.Clear();
            double        lHspread = Math.Max(Math.Abs(SelectedRecipe.SelectedLot.HDmax), Math.Abs(SelectedRecipe.SelectedLot.HDmin));
            double        lVspread = Math.Max(Math.Abs(SelectedRecipe.SelectedLot.VDmax), Math.Abs(SelectedRecipe.SelectedLot.VDmin));
            double        lSpread  = Math.Max(lHspread, lVspread);
            ScatterSeries lPt      = new ScatterSeries();
            LinearAxis    lVert    = new LinearAxis();
            LinearAxis    lHoriz   = new LinearAxis();

            lHoriz.Position           = AxisPosition.Bottom;
            lHoriz.Minimum            = SelectedRecipe.SelectedLot.HDavg - (lSpread * 2);
            lHoriz.Maximum            = SelectedRecipe.SelectedLot.HDavg + (lSpread * 2);
            lHoriz.MajorGridlineColor = OxyColors.Black;
            lHoriz.MajorGridlineStyle = LineStyle.Dot;
            _PerformancePlot.Axes.Add(lHoriz);
            lVert.Key                = "Iloc";
            lVert.Position           = AxisPosition.Left;
            lVert.Minimum            = SelectedRecipe.SelectedLot.VDavg - (lSpread * 2);
            lVert.Maximum            = SelectedRecipe.SelectedLot.VDavg + (lSpread * 2);
            lVert.MajorGridlineColor = OxyColors.Black;
            lVert.MajorGridlineStyle = LineStyle.Dot;
            _PerformancePlot.Axes.Add(lVert);
            lPt.Title    = "Impact Location";
            lPt.YAxisKey = "Iloc";
            ScatterPoint lSP;

            foreach (Round lR in SelectedRecipe.SelectedLot.Rounds)
            {
                lSP = new ScatterPoint(lR.HD, lR.VD);
                var pointAnnotation1 = new PointAnnotation();
                pointAnnotation1.X    = lR.HD;
                pointAnnotation1.Y    = lR.VD;
                pointAnnotation1.Text = lR.HD.ToString() + ", " + lR.VD.ToString();
                _PerformancePlot.Annotations.Add(pointAnnotation1);
                lPt.Points.Add(lSP);
            }
            _PerformancePlot.Series.Add(lPt);
            _PerformancePlot.InvalidatePlot(true);
        }
Example #10
0
 public void SetXRange(double minX, double maxX)
 {
     if (Math.Abs(_range.MinimumX - minX) > 0 || Math.Abs(_range.MaximumX - maxX) > 0)
     {
         _range.MinimumX = minX;
         _range.MaximumX = maxX;
         _model.InvalidatePlot(true);
     }
 }
Example #11
0
 private void SelectAllPoints(HairLength hl)
 {
     mModel.Annotations.Clear();
     foreach (var selection in mController.GetSelectPoints(hl))
     {
         mModel.Annotations.Add(SetSelectPoint(selection));
     }
     mModel.InvalidatePlot(false);
 }
Example #12
0
        private void UpdateData()
        {
            bool refresh = false;

            lock (_pointsMx)
            {
                _pointsPsiX.AddRange(_pointsPsi);
                _pointsPsi.Clear();

                _pointsCas2X.AddRange(_pointsCas2);
                _pointsCas2.Clear();
            }

            if (_pointsPsiX.Count > 0)
            {
                foreach (var pt in _pointsPsiX)
                {
                    _dataPsi.Points.Add(new DataPoint(pt.x, pt.y));
                }
                var tail = _pointsPsiX[_pointsPsiX.Count - 1];
                if ((panXCheck.Checked) && (tail.x > _axisTime.ActualMaximum))
                {
                    var pan = ((tail.x - _axisTime.ActualMaximum) + (_axisTime.ActualMaximum - _axisTime.ActualMinimum) * 0.5f) * _axisTime.Scale * -1.0f;
                    _axisTime.Pan(pan);
                }
                _pointsPsiX.Clear();
                refresh = true;
            }

            if (_pointsCas2X.Count > 0)
            {
                foreach (var pt in _pointsCas2X)
                {
                    _dataCas2.Points.Add(new DataPoint(pt.x, pt.y));
                }
                _pointsCas2X.Clear();
                refresh = true;
            }

            if (refresh)
            {
                _oxyPlot.InvalidatePlot(false);
            }

            int curTicks = Environment.TickCount;
            int delta    = curTicks - _sampleTimer;

            if (delta >= 1000)
            {
                _sampleTimer   = curTicks;
                _sampleHz      = _sampleCounter;
                _sampleCounter = 0;
                _rxmax         = 0;
            }

            UpdateStatus();
        }
Example #13
0
        public static PlotModel MouseEvents()
        {
            var model = new PlotModel {
                Title = "Mouse events", Subtitle = "Left click and drag"
            };
            var yaxis = new LinearAxis {
                Position = AxisPosition.Left, Minimum = -1, Maximum = 1
            };
            var xaxis = new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -1, Maximum = 1
            };

            model.Axes.Add(yaxis);
            model.Axes.Add(xaxis);

            LineSeries s1 = null;

            // Subscribe to the mouse down event on the line series
            model.MouseDown += (s, e) =>
            {
                // only handle the left mouse button (right button can still be used to pan)
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    // Add a line series
                    s1 = new LineSeries
                    {
                        Title           = "LineSeries" + (model.Series.Count + 1),
                        MarkerType      = MarkerType.None,
                        StrokeThickness = 2
                    };
                    s1.Points.Add(xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis));
                    model.Series.Add(s1);
                    model.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            model.MouseMove += (s, e) =>
            {
                if (s1 != null)
                {
                    s1.Points.Add(xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis));
                    model.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            model.MouseUp += (s, e) =>
            {
                if (s1 != null)
                {
                    s1        = null;
                    e.Handled = true;
                }
            };
            return(model);
        }
Example #14
0
 public async void eulerChecked(Object sender, RoutedEventArgs e)
 {
     //resets euler graph y axis
     modelEuler.InvalidatePlot(true);
     modelEuler.Axes[0].Reset();
     modelEuler.Axes[0].Maximum = 180;
     modelEuler.Axes[0].Minimum = -180;
     modelEuler.Axes[0].Zoom(modelEuler.Axes[0].Minimum, modelEuler.Axes[0].Maximum);
 }
Example #15
0
        private void refresh_curve()
        {
            minTemp = maxTemp = data1;

            while (flag)
            {
                if (data1 > maxTemp)
                {
                    maxTemp = data1;
                    richTextBox1.AppendText("最大温度" + ((maxTemp - 5) * 20).ToString() + "\n");
                }



                var date = DateTime.Now;

                _myPlotModel.Axes[0].Maximum = DateTimeAxis.ToDouble(date.AddMilliseconds(1));

                var lineSer = plotView1.Model.Series[0] as LineSeries;
                lineSer.Points.Add(new DataPoint(DateTimeAxis.ToDouble(date), data1));
                if (!checkBox1.Checked)
                {
                    if (lineSer.Points.Count > 250)
                    {
                        lineSer.Points.RemoveAt(0);
                    }
                }
                else
                {
                    if (dataList[0].Count <= 50000)
                    {
                        dataList[0].Add(data1);
                    }
                }



                _myPlotModel.InvalidatePlot(true);

                if (dataList[0].Count == 50000)
                {
                    flag = false;

                    var axis = plotView1.Model.Axes;
                    foreach (var o in axis)
                    {
                        o.IsPanEnabled  = true;
                        o.IsZoomEnabled = true;
                    }
                }
                ready = false;
                Thread.Sleep(10);
            }
        }
        /// <summary>
        /// Update the plots with the measurement values.
        /// </summary>
        private void UpdatePlots()
        {
            NyquistPlotData.Points.Add(new DataPoint(RealImpedanceValues.Last(), -ImgImpedanceValues.Last()));           //Adds the last added measurement values as new data points
            NyquistPlotModel.InvalidatePlot(true);                                                                       //Updates the plot
            NyquistPlotModel.ResetAllAxes();

            BodePlotDataMagnitude.Points.Add(new DataPoint(FrequencyValues.Last(), ImpedanceMagnitudeValues.Last()));    //Adds new  data points
            BodePlotDataPhase.Points.Add(new DataPoint(FrequencyValues.Last(), -PhaseValues.Last()));                    //Adds new  data points
            BodePlotModel.InvalidatePlot(true);                                                                          //Updates the plot
            BodePlotModel.ResetAllAxes();
        }
Example #17
0
        void resetPlot()
        {
            series1.Points.Clear();
            series2.Points.Clear();
            series3.Points.Clear();
            series4.Points.Clear();

            axisX.Title = "";
            axisY.Title = "";

            model.InvalidatePlot(true);
        }
        public static Example ClickingOnAnAnnotation()
        {
            var plotModel = new PlotModel {
                Title = "Clicking on an annotation", Subtitle = "Click on the rectangles"
            };

            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });

            var annotation1 = new RectangleAnnotation {
                Fill = OxyColors.Green, Text = "RectangleAnnotation 1", MinimumX = 25, MaximumX = 75, MinimumY = 20, MaximumY = 40
            };

            plotModel.Annotations.Add(annotation1);

            var annotation2 = new RectangleAnnotation {
                Fill = OxyColors.SkyBlue, Text = "RectangleAnnotation 2", MinimumX = 25, MaximumX = 75, MinimumY = 60, MaximumY = 80
            };

            plotModel.Annotations.Add(annotation2);

            EventHandler <OxyMouseDownEventArgs> handleMouseClick = (s, e) =>
            {
                plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)s).Text;
                plotModel.InvalidatePlot(false);
            };

            annotation1.MouseDown += handleMouseClick;
            annotation2.MouseDown += handleMouseClick;

            var controller  = new PlotController();
            var handleClick = new DelegatePlotCommand <OxyMouseDownEventArgs>(
                (v, c, e) =>
            {
                var args     = new HitTestArguments(e.Position, 10);
                var firstHit = v.ActualModel.HitTest(args).FirstOrDefault(x => x.Element is RectangleAnnotation);
                if (firstHit != null)
                {
                    e.Handled          = true;
                    plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)firstHit.Element).Text;
                    plotModel.InvalidatePlot(false);
                }
            });

            controller.Bind(new OxyMouseDownGesture(OxyMouseButton.Left), handleClick);

            return(new Example(plotModel, controller));
        }
Example #19
0
 // Change axes to adjust for new maximum values.
 public void resetYAxis()
 {
     model.InvalidatePlot(true);
     model.Axes[0].Reset();
     if (angleSwitch.IsOn && (bool)wCheckbox.IsChecked)
     {
         model.Axes[0].Maximum = 180;
     }
     else
     {
         model.Axes[0].Maximum = 1;
     }
     model.Axes[0].Zoom(model.Axes[0].Minimum, model.Axes[0].Maximum);
 }
Example #20
0
        public void ShowLinearIntepolatedBlockGraphItems(bool setMinTime, BlockGraphItem <TimeSpan>[] array)
        {
            lock (_plotModel.SyncRoot)
            {
                ConfigureAxes(setMinTime, array);

                var series = PrepareSeries();
                for (int i = 0; i < array.Length; i++)
                {
                    series.Points.Add(new DataPoint(array[i].BlockNumber, TimeSpanAxis.ToDouble(array[i].Data)));
                }
            }
            _plotModel.InvalidatePlot(true);
        }
        /// <summary>
        /// Update the DMG PlotModel with the latest data.
        /// </summary>
        private void DisplayDmgPlogExecute()
        {
            try
            {
                // Process the all the data in the buffer
                while (!_DmgPlotBuffer.IsEmpty)
                {
                    // Set the flag
                    _isProcessDmgPlot = true;

                    // Remove the data from the buffer
                    DmgPlotData prt = null;
                    if (_DmgPlotBuffer.TryDequeue(out prt))
                    {
                        // Lock the plot for an update
                        lock (Plot.SyncRoot)
                        {
                            if (prt != null)
                            {
                                // GPS
                                // Verify points exist
                                if (prt.GpsLs.Points.Count > 0)
                                {
                                    _plot.Series[0] = prt.GpsLs;
                                }

                                // Bottom Track Earth
                                // Verify points exist
                                if (prt.BtEarthLs.Points.Count > 0)
                                {
                                    _plot.Series[1] = prt.BtEarthLs;
                                }
                            }
                        }

                        // Display plot
                        _plot.InvalidatePlot(true);
                    }
                }

                // Reset the flag
                _isProcessDmgPlot = false;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                log.Error("Error updating DMG plot.", e);
            }
        }
Example #22
0
        public static PlotModel AnnotationLayers()
        {
            var model = new PlotModel {
                Title = "AnnotationLayers"
            };

            var a1 = new RectangleAnnotation {
                MinimumX = 10, MaximumX = 20, MinimumY = -1, MaximumY = 1, Layer = AnnotationLayer.BelowAxes
            };
            var a2 = new RectangleAnnotation {
                MinimumX = 30, MaximumX = 40, MinimumY = -1, MaximumY = 1, Layer = AnnotationLayer.BelowSeries
            };
            var a3 = new RectangleAnnotation {
                MinimumX = 50, MaximumX = 60, MinimumY = -1, MaximumY = 1, Layer = AnnotationLayer.AboveSeries
            };

            model.Annotations.Add(a1);
            model.Annotations.Add(a2);
            model.Annotations.Add(a3);
            var s1 = new FunctionSeries(Math.Sin, 0, 100, 0.01);

            model.Series.Add(s1);
            a1.MouseDown += (s, e) =>
            {
                model.Subtitle = "Clicked annotation below axes";
                model.InvalidatePlot(true);
                e.Handled = true;
            };
            a2.MouseDown += (s, e) =>
            {
                model.Subtitle = "Clicked annotation below series";
                model.InvalidatePlot(true);
                e.Handled = true;
            };
            a3.MouseDown += (s, e) =>
            {
                model.Subtitle = "Clicked annotation above series";
                model.InvalidatePlot(true);
                e.Handled = true;
            };
            s1.MouseDown += (s, e) =>
            {
                model.Subtitle = "Clicked series";
                model.InvalidatePlot(true);
                e.Handled = true;
            };

            return(model);
        }
        public void UpdateChart(double avgA, double errA, double avgB, double errB)
        {
            series.Items.Clear();

            series.Items.Add(new ErrorColumnItem(avgA, errA)
            {
                Color = OxyColors.Aqua
            });
            series.Items.Add(new ErrorColumnItem(avgB, errB)
            {
                Color = OxyColors.Aqua
            });

            model.InvalidatePlot(true);
        }
Example #24
0
        public void ShowBlockTime(VotingResults votingResults)
        {
            lock (_plotModel.SyncRoot)
            {
                var xAxis = _plotModel.Axes.Where(x => x.Key == XAxisKey).Single();
                xAxis.SetMinMaxBlocksToXAxis(votingResults);

                var series = PrepareSeries();

                var maxTime = BlockTimeVisualHelper.LoadBlockTimesToSeries(votingResults, series, null);
                var yAxis   = _plotModel.Axes.Where(x => x.Key == "y_axis").Single();
                yAxis.SetAxisMax(TimeSpanAxis.ToDouble(maxTime));
            }
            _plotModel.InvalidatePlot(true);
        }
        private void updateIterationsPlot(LineSeries series, IEnumerable <IterationResults> iterations, Func <IterationResults, double> selector)
        {
            if (iterations != null)
            {
                series.Points.Clear();
                int index = iterations.First().Iteration;
                foreach (var iteration in iterations)
                {
                    series.Points.Add(new DataPoint(index, selector(iteration)));
                    ++index;
                }

                model.InvalidatePlot(true);
            }
        }
Example #26
0
        private void CreateDataSeries(PlotModel model, string title)
        {
            if (!lineSeriesTable.ContainsKey(title))
            {
                LineSeries ls = new LineSeries {
                    Title = title, MarkerType = MarkerType.None
                };

                model.Series.Add(ls);

                oxPlot.Invalidate();
                lineSeriesTable.Add(title, ls);
                plotModel.InvalidatePlot(true);
            }
        }
Example #27
0
        public void Show(VotingResults votingResults, Func <Vote, bool> filter)
        {
            lock (_plotModel.SyncRoot)
            {
                _xAxis.SetAxisMinMax(TimeSpanAxis.ToDouble(votingResults.StartTime), TimeSpanAxis.ToDouble(votingResults.EndTime));

                _plotModel.Series.Clear();

                LineSeries series = TotalCumulativeVotedByTimeUtils.CreateSeries(votingResults, filter, out var max);
                series.Title = "Всего проголосовало";
                _yAxis.SetAxisMax(max);
                _plotModel.Series.Add(series);
            }
            _plotModel.InvalidatePlot(true);
        }
Example #28
0
        public static PlotModel SelectRange()
        {
            var model = new PlotModel {
                Title = "Select range", Subtitle = "Left click and drag to select a range."
            };

            model.Series.Add(new FunctionSeries(Math.Cos, 0, 40, 0.1));

            var range = new RectangleAnnotation {
                Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue), MinimumX = 0, MaximumX = 0
            };

            model.Annotations.Add(range);

            double startx = double.NaN;

            model.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    startx         = range.InverseTransform(e.Position).X;
                    range.MinimumX = startx;
                    range.MaximumX = startx;
                    model.InvalidatePlot(true);
                    e.Handled = true;
                }
            };
            model.MouseMove += (s, e) =>
            {
                if (!double.IsNaN(startx))
                {
                    var x = range.InverseTransform(e.Position).X;
                    range.MinimumX = Math.Min(x, startx);
                    range.MaximumX = Math.Max(x, startx);
                    range.Text     = string.Format("∫ cos(x) dx =  {0:0.00}", Math.Sin(range.MaximumX) - Math.Sin(range.MinimumX));
                    model.Subtitle = string.Format("Integrating from {0:0.00} to {1:0.00}", range.MinimumX, range.MaximumX);
                    model.InvalidatePlot(true);
                    e.Handled = true;
                }
            };

            model.MouseUp += (s, e) =>
            {
                startx = double.NaN;
            };

            return(model);
        }
        public static PlotModel IsVisibleFalse()
        {
            var model = new PlotModel {
                Title = "LineSeries with IsVisible = false", Subtitle = "Click to change the IsVisible property for LineSeries 2"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = 0, Maximum = 50
            });

            var s1 = CreateExampleLineSeries(38);

            s1.Title = "LineSeries 1";
            model.Series.Add(s1);

            var s2 = CreateExampleLineSeries(39);

            s2.Title     = "LineSeries 2";
            s2.IsVisible = false;
            model.Series.Add(s2);

            // handle mouse clicks to change visibility
            model.MouseDown += (s, e) => { s2.IsVisible = !s2.IsVisible; model.InvalidatePlot(true); };

            return(model);
        }
        protected override void RemoveSignal(OxyPlot.Series.Series series)
        {
            if (series == null)
            {
                return;
            }

            PlotSignalModel signal = (PlotSignalModel)series.Tag;

            //this.paneModel.Signals.Remove(signal);

            PlotModel.Series.Remove(series);

            OxyPlot.Series.LineSeries lax = series as OxyPlot.Series.LineSeries;
            if (lax != null)
            {
                PlotModel.Axes.Remove(lax.YAxis);
            }

            if (SelectedSeries == series)
            {
                SelectedSeries = null;
            }

            PlotModel.InvalidatePlot(false);
        }