Provides an IPlotController with a default set of plot bindings.
Inheritance: OxyPlot.ControllerBase, IPlotController
        public static Example LargeDataSetNarrow()
        {
            var pm = new PlotModel { Title = "Large Data Set (narrow window)" };

            var timeSpanAxis1 = new DateTimeAxis { Position = AxisPosition.Bottom };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var n = 1000000;
            var items = HighLowItemGenerator.MRProcess(n).ToArray();
            var series = new CandleStickSeries
                             {
                                 Color = OxyColors.Black,
                                 IncreasingColor = OxyColors.DarkGreen,
                                 DecreasingColor = OxyColors.Red,
                                 TrackerFormatString =
                                     "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                                 ItemsSource = items
                             };

            timeSpanAxis1.Minimum = items[0].X;
            timeSpanAxis1.Maximum = items[29].X;

            linearAxis1.Minimum = items.Take(30).Select(x => x.Low).Min();
            linearAxis1.Maximum = items.Take(30).Select(x => x.High).Max();

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return new Example(pm, controller);
        }
Esempio n. 2
0
 public static Example BasicExample()
 {
     var model = new PlotModel { Title = "Basic Controller example", Subtitle = "Panning with left mouse button" };
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
     var controller = new PlotController();
     controller.InputCommandBindings.Clear();
     controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
     return new Example(model, controller);
 }
Esempio n. 3
0
        public MainWindowViewModel()
        {
            this.Controller = new PlotController();
            myPlotModel = new PlotModel { Title = "Example 1" };
            myPlotModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            var arrowAnnotation = new ArrowAnnotation
            {
                StartPoint = new DataPoint(0, 0),
                EndPoint = new DataPoint(3, 1)
            };
            myPlotModel.Annotations.Add(arrowAnnotation);
        }
Esempio n. 4
0
        public static Example HoverTracking()
        {
            var model = new PlotModel { Title = "Show tracker without clicking" };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
            model.Series.Add(new FunctionSeries(t => (Math.Cos(t) * 5) + Math.Cos(t * 50), t => (Math.Sin(t) * 5) + Math.Sin(t * 50), 0, Math.PI * 2, 20000));

            // create a new plot controller with default bindings
            var controller = new PlotController();

            // add a tracker command to the mouse enter event
            controller.BindMouseEnter(PlotCommands.HoverPointsOnlyTrack);

            return new Example(model, controller);
        }
        public MyViewModel()
        {
            var customController = new PlotController();
            customController.UnbindMouseWheel();

            this.Controller = customController;

            loadFile = new RelayCommand(() => datRead(), () => true);

            Model1 = new PlotModel();
            Model2 = new PlotModel();
            var tmp1 = new PlotModel { Title = "First series" };
            var tmp2 = new PlotModel { Title = "Second series" };
            var series1 = new LineSeries { MarkerType = MarkerType.None };
            var series2 = new LineSeries { MarkerType = MarkerType.None };
            for (int i = 0; i < 650000; i++)
            {
                series1.Points.Add(new DataPoint(i, 0));
                series2.Points.Add(new DataPoint(i, 0));
            }

            tmp1.Series.Add(series1);
            tmp2.Series.Add(series2);

            tmp1.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                AbsoluteMinimum = 0,
                Minimum = 0,
                AbsoluteMaximum = 650000,
                Maximum = 650000,

            });
            tmp2.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                AbsoluteMinimum = 0,
                Minimum = 0,
                AbsoluteMaximum = 650000,
                Maximum = 650000,
            });

            this.Model1 = tmp1;
            this.Model2 = tmp2;
        }
Esempio n. 6
0
        public static Example MouseHandlingExample()
        {
            var model = new PlotModel { Title = "Mouse handling example" };
            var series = new ScatterSeries();
            model.Series.Add(series);

            // Create a command that adds points to the scatter series
            var command = new DelegatePlotCommand<OxyMouseEventArgs>(
                (v, c, a) =>
                {
                    var point = series.InverseTransform(a.Position);
                    series.Points.Add(new ScatterPoint(point.X, point.Y));
                    model.InvalidatePlot(true);
                });

            var controller = new PlotController();
            controller.BindMouseDown(OxyMouseButton.Left, command);

            return new Example(model, controller);
        }
        private static IEnumerable<Model> CreateModels()
        {
            for (var i = 0; i < 3; i++)
            {
                var pm = new PlotModel { Title = string.Format("Plot {0}", i + 1) };

                var series = new LineSeries();
                for (var j = 0; j < 10; j++)
                {
                    series.Points.Add(new DataPoint(j, r.NextDouble()));
                }

                pm.Series.Add(series);

                var pc = new PlotController();
                pc.UnbindAll();
                pc.BindKeyDown(OxyKey.Left, PlotCommands.PanRight);
                pc.BindKeyDown(OxyKey.Right, PlotCommands.PanLeft);

                yield return new Model { PlotModel = pm, PlotController = pc };
            }
        }
        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);
        }
        public static Example SmallDataSet()
        {
            var pm = new PlotModel { Title = "Small Data Set" };

            var timeSpanAxis1 = new DateTimeAxis { Position = AxisPosition.Bottom };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var n = 100;
            var items = HighLowItemGenerator.MRProcess(n).ToArray();
            var series = new CandleStickSeries
                             {
                                 Color = OxyColors.Black,
                                 IncreasingColor = OxyColors.DarkGreen,
                                 DecreasingColor = OxyColors.Red,
                                 DataFieldX = "X",
                                 DataFieldHigh = "High",
                                 DataFieldLow = "Low",
                                 DataFieldOpen = "Open",
                                 DataFieldClose = "Close",
                                 TrackerFormatString =
                                     "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                                 ItemsSource = items
                             };

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return new Example(pm, controller);
        }
        /// <summary>
        /// Creates the candle stick and volume series example.
        /// </summary>
        /// <returns>The candle stick and volume series example.</returns>
        /// <param name="title">Title.</param>
        /// <param name="style">Style.</param>
        /// <param name="n">N.</param>
        /// <param name="naturalY">If set to <c>true</c> natural y.</param>
        /// <param name="naturalV">If set to <c>true</c> natural v.</param>
        private static Example CreateCandleStickAndVolumeSeriesExample(
            string title, 
            VolumeStyle style, 
            int n = 10000,
            bool naturalY = false,
            bool naturalV = false)
        {
            var pm = new PlotModel { Title = title };

            var series = new CandleStickAndVolumeSeries
            {
                PositiveColor = OxyColors.DarkGreen,
                NegativeColor = OxyColors.Red,
                PositiveHollow = false,
                NegativeHollow = false,
                SeparatorColor = OxyColors.Gray,
                SeparatorLineStyle = LineStyle.Dash,
                VolumeStyle = style
            };

            // create bars
            foreach (var bar in OhlcvItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            // create visible window
            var Istart = n - 200;
            var Iend = n - 120;
            var Ymin = series.Items.Skip(Istart).Take(Iend - Istart + 1).Select(x => x.Low).Min();
            var Ymax = series.Items.Skip(Istart).Take(Iend - Istart + 1).Select(x => x.High).Max();
            var Xmin = series.Items[Istart].X;
            var Xmax = series.Items[Iend].X;

            // setup axes
            var timeAxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum = Xmin,
                Maximum = Xmax
            };
            var barAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                Key = series.BarAxisKey,
                StartPosition = 0.25,
                EndPosition = 1.0,
                Minimum = naturalY ? double.NaN : Ymin,
                Maximum = naturalY ? double.NaN : Ymax
            };
            var volAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                Key = series.VolumeAxisKey,
                StartPosition = 0.0,
                EndPosition = 0.22,
                Minimum = naturalV ? double.NaN : 0,
                Maximum = naturalV ? double.NaN : 5000
            };

            switch (style)
            {
                case VolumeStyle.None:
                    barAxis.Key = null;
                    barAxis.StartPosition = 0.0;
                    pm.Axes.Add(timeAxis);
                    pm.Axes.Add(barAxis);
                    break;

                case VolumeStyle.Combined:
                case VolumeStyle.Stacked:
                    pm.Axes.Add(timeAxis);
                    pm.Axes.Add(barAxis);
                    pm.Axes.Add(volAxis);
                    break;

                case VolumeStyle.PositiveNegative:
                    volAxis.Minimum = naturalV ? double.NaN : -5000;
                    pm.Axes.Add(timeAxis);
                    pm.Axes.Add(barAxis);
                    pm.Axes.Add(volAxis);
                    break;
            }

            pm.Series.Add(series);

            if (naturalY == false)
            {
                timeAxis.AxisChanged += (sender, e) => AdjustYExtent(series, timeAxis, barAxis);
            }

            var controller = new PlotController();
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return new Example(pm, controller);
        }
Esempio n. 11
0
 private PlotController CreateDefaultController(){
     var c = new PlotController ();
     c.UnbindMouseDown (OxyMouseButton.Left);
     c.BindMouseDown (OxyMouseButton.Left, PlotCommands.PanAt);
     return c;
 }
Esempio n. 12
0
        /// <summary>
        /// Creates the volume series.
        /// </summary>
        /// <returns>The volume series.</returns>
        /// <param name="title">Title.</param>
        /// <param name="style">Style.</param>
        /// <param name="n">N.</param>
        /// <param name="natural">If set to <c>true</c> natural.</param>
        private static Example CreateVolumeSeries(
            string title, 
            VolumeStyle style, 
            int n = 10000,
            bool natural = false)
        {
            var pm = new PlotModel { Title = title };

            var series = new VolumeSeries
            {
                PositiveColor = OxyColors.DarkGreen,
                NegativeColor = OxyColors.Red,
                PositiveHollow = false,
                NegativeHollow = false,
                VolumeStyle = style
            };

            // create bars
            foreach (var bar in OhlcvItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            // create visible window
            var Istart = n - 200;
            var Iend = n - 120;
            var Xmin = series.Items[Istart].X;
            var Xmax = series.Items[Iend].X;

            // setup axes
            var timeAxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum = Xmin,
                Maximum = Xmax
            };
            var volAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                Key = "Volume",
                StartPosition = 0.0,
                EndPosition = 1.0,
                Minimum = natural ? double.NaN : 0,
                Maximum = natural ? double.NaN : 10000
            };

            switch (style)
            {
                case VolumeStyle.Combined:
                case VolumeStyle.Stacked:
                    pm.Axes.Add(timeAxis);
                    pm.Axes.Add(volAxis);
                    break;

                case VolumeStyle.PositiveNegative:
                    volAxis.Minimum = natural ? double.NaN : -10000;
                    pm.Axes.Add(timeAxis);
                    pm.Axes.Add(volAxis);
                    break;
            }

            pm.Series.Add(series);

            var controller = new PlotController();
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return new Example(pm, controller);
        }
Esempio n. 13
0
		/// <summary>
		/// Builds the realtime plot.
		/// </summary>
		private void BuildRealTimePlot ()
		{
			RealTimeXAxis = new DateTimeAxis {
				Key = "RealTimeXAxis",
				Position = AxisPosition.Bottom,
				MajorGridlineThickness = 1,
				MajorGridlineStyle = OxyPlot.LineStyle.Solid,
				MinorGridlineColor = OxyColors.LightGray,
				MinorGridlineStyle = OxyPlot.LineStyle.Dot,
				MinorGridlineThickness = .5,
				MinorStep = TimeSpan.FromSeconds (1).Ticks,
			};

			var YAxis = new LinearAxis {
				Position = AxisPosition.Left,
				IsPanEnabled = false,
				IsZoomEnabled = false,
				MajorGridlineThickness = 1,
				MajorGridlineStyle = OxyPlot.LineStyle.Solid,
				MinorGridlineColor = OxyColors.LightGray,
				MinorGridlineStyle = OxyPlot.LineStyle.Dot,
				MinorGridlineThickness = .5,
			};

			RealTimePlotModel = new PlotModel {
				PlotType = PlotType.XY,
				Background = OxyPlot.OxyColors.White,
				IsLegendVisible = true,
				LegendOrientation = LegendOrientation.Horizontal,
				LegendPlacement = LegendPlacement.Outside,
				LegendPosition = LegendPosition.RightMiddle,
			};

			RealTimePlotController = new PlotController ();

			RealTimePlotModel.Axes.Add (YAxis);
			RealTimePlotModel.Axes.Add (RealTimeXAxis);

			//Enable double buffered to prevent flickering
			RealTimePlotView = new PlotView (){ Name = "", Model = RealTimePlotModel, DoubleBuffered = true  };

			vboxRealTimePlot.PackStart (RealTimePlotView, true, true, 0);
			(vboxRealTimePlot [RealTimePlotView] as Box.BoxChild).Position = 0;

			RealTimePlotView.SetSizeRequest (hbSequences.Allocation.Width, fSequences.Allocation.Height / 2);
			vpanedSequences.Position = fSequences.Allocation.Height / 2;

			RealTimePlotView.ShowAll ();

			cbtnRealTimePlotSmoothValues.Toggled += OnCbtnRealTimePlotSmoothValues;
			cbtnRealTimePlotShowMarker.Toggled += OnCbtnRealTimePlotShowMarkerToggled;
			btnRealTimePlotJumpStart.Clicked += OnBtnRealTimePlotJumpStartClicked;
			btnRealTimePlotJumpLatest.Clicked += OnBtnRealTimePlotJumpLatestClicked;
			btnRealTimePlotSnapshot.Clicked += OnBtnRealTimePlotSnapshotClicked;
			btnRealTimePlotPause.Clicked += OnBtnRealTimePlotPauseClicked;
			btnRealTimePlotResetZoom.Clicked += OnBtnRealTimePlotResetZoomClicked;
			btnRealTimePlotFitData.Clicked += OnBtnRealTimePlotFitDataClicked;
			cbtnRealTimePlotLimitPoints.Active = Frontend.Settings.Default.LimitPlotPoints;
			cbtnRealTimePlotLimitPoints.Toggled += OnCbtnRealTimePlotLimitPoints;
		}