コード例 #1
0
 private void AddSine()
 {
     Random rand = new Random();
     avaPlot1.Plot.AddSignal(DataGen.Sin(51, phase: rand.NextDouble() * 1000));
     avaPlot1.Plot.AxisAuto();
     avaPlot1.Render();
 }
コード例 #2
0
 private void EqualAxisLock(object sender, RoutedEventArgs e)
 {
     if (avaPlot1 is null)
     {
         return;
     }
     avaPlot1.Plot.AxisScaleLock(true); avaPlot1.Render();
 }
コード例 #3
0
        public RightClickMenu()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.plt.PlotSignal(DataGen.Sin(51));
            avaPlot1.plt.PlotSignal(DataGen.Cos(51));
            avaPlot1.Render();

            List <ContextMenuItem> contextMenu = new List <ContextMenuItem>();
            contextMenu.Add(new ContextMenuItem()
            {
                itemName = "Add Sine Wave",
                onClick  = AddSine
            });

            contextMenu.Add(new ContextMenuItem()
            {
                itemName = "Clear Plot",
                onClick  = ClearPlot
            });

            avaPlot1.SetContextMenu(contextMenu);
        }
コード例 #4
0
        public ToggleVisibility()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            int      pointCount = 51;
            double[] dataXs     = DataGen.Consecutive(pointCount);
            double[] dataSin    = DataGen.Sin(pointCount);
            double[] dataCos    = DataGen.Cos(pointCount);

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            sinPlot = avaPlot1.plt.PlotScatter(dataXs, dataSin);
            cosPlot = avaPlot1.plt.PlotScatter(dataXs, dataCos);
            vline1  = avaPlot1.plt.PlotVLine(0);
            vline2  = avaPlot1.plt.PlotVLine(50);

            avaPlot1.Render();

            this.Find <CheckBox>("sineCheckbox").Checked   += SinShow;
            this.Find <CheckBox>("sineCheckbox").Unchecked += SinHide;

            this.Find <CheckBox>("cosineCheckbox").Checked   += CosShow;
            this.Find <CheckBox>("cosineCheckbox").Unchecked += CosHide;

            this.Find <CheckBox>("linesCheckbox").Checked   += LinesShow;
            this.Find <CheckBox>("linesCheckbox").Unchecked += LinesHide;
        }
コード例 #5
0
        private void MouseMove(object sender, PointerEventArgs e)
        {
            // determine point nearest the cursor
            (double mouseCoordX, double mouseCoordY) = avaPlot1.GetMouseCoordinates();
            double xyRatio = avaPlot1.Plot.XAxis.Dims.PxPerUnit / avaPlot1.Plot.YAxis.Dims.PxPerUnit;

            (double pointX, double pointY, int pointIndex) = MyScatterPlot.GetPointNearest(mouseCoordX, mouseCoordY, xyRatio);

            // place the highlight over the point of interest
            HighlightedPoint.Xs[0]     = pointX;
            HighlightedPoint.Ys[0]     = pointY;
            HighlightedPoint.IsVisible = true;

            // render if the highlighted point chnaged
            if (LastHighlightedIndex != pointIndex)
            {
                LastHighlightedIndex = pointIndex;
                avaPlot1.Render();
            }

            // update the GUI to describe the highlighted point
            (double mouseX, double mouseY)       = avaPlot1.GetMouseCoordinates();
            this.Find <TextBlock>("label1").Text = $"Closest point to ({mouseX:N0}, {mouseY:N0}) " +
                                                   $"is index {pointIndex} ({pointX:N2}, {pointY:N2})";
        }
コード例 #6
0
 void Render(object sender, EventArgs e)
 {
     if (AutoAxisCheckbox.IsChecked == true)
     {
         avaPlot1.Plot.AxisAuto();
     }
     avaPlot1.Render();
 }
コード例 #7
0
ファイル: MouseTracker.axaml.cs プロジェクト: whble/ScottPlot
        private void OnMouseMove(object sender, PointerEventArgs e)
        {
            int pixelX = (int)e.GetPosition(avaPlot1).X;
            int pixelY = (int)e.GetPosition(avaPlot1).Y;

            (double coordinateX, double coordinateY) = avaPlot1.GetMouseCoordinates();

            this.Find <TextBlock>("XPixelLabel").Text = $"{pixelX:0.000}";
            this.Find <TextBlock>("YPixelLabel").Text = $"{pixelY:0.000}";

            this.Find <TextBlock>("XCoordinateLabel").Text = $"{avaPlot1.Plot.GetCoordinateX(pixelX):0.00000000}";
            this.Find <TextBlock>("YCoordinateLabel").Text = $"{avaPlot1.Plot.GetCoordinateY(pixelY):0.00000000}";

            Crosshair.X = coordinateX;
            Crosshair.Y = coordinateY;

            avaPlot1.Render();
        }
コード例 #8
0
        private void MouseMove(object sender, PointerEventArgs e)
        {
            (double mouseX, double mouseY) = avaPlot1.GetMouseCoordinates();

            sph.HighlightClear();
            var(x, y, index) = sph.HighlightPointNearest(mouseX, mouseY);
            avaPlot1.Render();

            this.Find <TextBlock>("label1").Text = $"Closest point to ({mouseX:N2}, {mouseY:N2}) " +
                                                   $"is index {index} ({x:N2}, {y:N2})";
        }
コード例 #9
0
        public AxisLimits()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            AvaPlot wpfPlot1 = this.Find <AvaPlot>("avaPlot1");

            wpfPlot1.plt.PlotSignal(DataGen.Sin(51));
            wpfPlot1.plt.PlotSignal(DataGen.Cos(51));
            wpfPlot1.plt.AxisAuto();
            wpfPlot1.plt.AxisBounds(0, 50, -1, 1);
            wpfPlot1.Render();
        }
コード例 #10
0
 private void SinHide(object sender, RoutedEventArgs e)
 {
     if (avaPlot1 is null)
     {
         return;
     }
     sinPlot.visible = false;
     avaPlot1.Render();
 }
コード例 #11
0
        public MouseTracker()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.plt.PlotSignal(DataGen.RandomWalk(null, 100));
            vLine = avaPlot1.plt.PlotVLine(0, color: System.Drawing.Color.Red, lineStyle: LineStyle.Dash);
            hLine = avaPlot1.plt.PlotHLine(0, color: System.Drawing.Color.Red, lineStyle: LineStyle.Dash);
            avaPlot1.Render();

            avaPlot1.PointerMoved += OnMouseMove;
        }
コード例 #12
0
        public AvaloniaConfig()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            int      pointCount = 51;
            double[] dataXs     = DataGen.Consecutive(pointCount);
            double[] dataSin    = DataGen.Sin(pointCount);
            double[] dataCos    = DataGen.Cos(pointCount);

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.plt.PlotScatter(dataXs, dataSin);
            avaPlot1.plt.PlotScatter(dataXs, dataCos);
            avaPlot1.Render();
        }
コード例 #13
0
ファイル: MouseTracker.axaml.cs プロジェクト: whble/ScottPlot
        public MouseTracker()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Plot.AddSignal(DataGen.RandomWalk(null, 100));
            Crosshair = avaPlot1.Plot.AddCrosshair(0, 0);
            avaPlot1.Render();

            avaPlot1.PointerMoved += OnMouseMove;
            avaPlot1.PointerLeave += OnMouseLeave;
            avaPlot1.PointerEnter += OnMouseEnter;
        }
コード例 #14
0
        public ShowValueOnHover()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            int      pointCount = 100;
            Random   rand       = new Random(0);
            double[] xs         = DataGen.Consecutive(pointCount, 0.1);
            double[] ys         = DataGen.NoisySin(rand, pointCount);

            sph = avaPlot1.Plot.PlotScatterHighlight(xs, ys);
            avaPlot1.Render();

            avaPlot1.PointerMoved += MouseMove;
        }
コード例 #15
0
ファイル: MouseTracker.axaml.cs プロジェクト: Wyrus/ScottPlot
        public MouseTracker()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Plot.AddSignal(DataGen.RandomWalk(null, 100));
            vLine = avaPlot1.Plot.AddVerticalLine(0, color: System.Drawing.Color.Red, style: LineStyle.Dash);
            hLine = avaPlot1.Plot.AddHorizontalLine(0, color: System.Drawing.Color.Red, style: LineStyle.Dash);
            avaPlot1.Render();

            avaPlot1.PointerMoved += OnMouseMove;
            avaPlot1.PointerLeave += OnMouseLeave;
            avaPlot1.PointerEnter += OnMouseEnter;
        }
コード例 #16
0
        public TransparentBackground()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            AvaPlot avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            int      pointCount = 51;
            double[] x          = DataGen.Consecutive(pointCount);
            double[] sin        = DataGen.Sin(pointCount);
            double[] cos        = DataGen.Cos(pointCount);

            avaPlot1.Plot.AddScatter(x, sin);
            avaPlot1.Plot.AddScatter(x, cos);

            avaPlot1.Plot.Style(figureBackground: System.Drawing.Color.Transparent);
            avaPlot1.Plot.Style(dataBackground: System.Drawing.Color.Transparent);
            avaPlot1.Render();
        }
コード例 #17
0
        public LinkedPlots()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            int      pointCount = 51;
            double[] dataXs     = DataGen.Consecutive(pointCount);
            double[] dataSin    = DataGen.Sin(pointCount);
            double[] dataCos    = DataGen.Cos(pointCount);

            AvaPlot avaPlot1 = this.Find <AvaPlot>("avaPlot1");
            AvaPlot avaPlot2 = this.Find <AvaPlot>("avaPlot2");
            AvaPlots = new AvaPlot[] { avaPlot1, avaPlot2 };

            avaPlot1.Plot.AddScatter(dataXs, dataSin);
            avaPlot1.Render();

            avaPlot2.Plot.AddScatter(dataXs, dataCos);
            avaPlot2.Render();
        }
コード例 #18
0
        private void PlotRandomData(object sender, RoutedEventArgs e)
        {
            avaPlot1.Reset();

            int    pointCount = 5;
            Random rand       = new Random();

            double[] dataX  = DataGen.Consecutive(pointCount);
            double[] dataY  = DataGen.Random(rand, pointCount);
            string[] labels = { "One", "Two", "Three", "Four", "Five" };

            avaPlot1.plt.PlotScatter(dataX, dataY, label: "series 1");
            avaPlot1.plt.Title("Plot Title");
            avaPlot1.plt.XLabel("Horizontal Axis");
            avaPlot1.plt.YLabel("Vertical Axis");

            avaPlot1.plt.XTicks(dataX, labels);
            avaPlot1.plt.XAxis.TickLabelStyle(rotation: 90);
            avaPlot1.plt.AxisAuto();
            avaPlot1.plt.Layout(left: 20, top: 50, bottom: 100, right: 20);
            avaPlot1.Configure(recalculateLayoutOnMouseUp: false);

            avaPlot1.Render();
        }
コード例 #19
0
 private void axisChanged2(object sender, EventArgs e)
 {
     avaPlot1.Plot.SetAxisLimits(avaPlot2.Plot.GetAxisLimits());
     avaPlot1.Render();
 }
コード例 #20
0
 private void axisChanged2(object sender, EventArgs e)
 {
     avaPlot1.plt.MatchAxis(avaPlot2.plt);
     avaPlot1.Render();
 }
コード例 #21
0
 void Render(object sender, EventArgs e)
 {
     avaPlot1.Render();
 }
コード例 #22
0
 private void EqualAxisLock(object sender, RoutedEventArgs e)
 {
     avaPlot1?.Configure(equalAxes: true); avaPlot1.Render();
 }