예제 #1
0
 private void EqualAxisLock(object sender, RoutedEventArgs e)
 {
     if (avaPlot1 is null)
     {
         return;
     }
     avaPlot1.Plot.AxisScaleLock(true); avaPlot1.Refresh();
 }
예제 #2
0
        private void AddSine()
        {
            Random rand = new Random();

            avaPlot1.Plot.AddSignal(DataGen.Sin(51, phase: rand.NextDouble() * 1000));
            avaPlot1.Plot.AxisAuto();
            avaPlot1.Refresh();
        }
예제 #3
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.X         = pointX;
            HighlightedPoint.Y         = pointY;
            HighlightedPoint.IsVisible = true;

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

            // 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})";
        }
예제 #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.Plot.AddScatter(dataXs, dataSin);
            cosPlot = avaPlot1.Plot.AddScatter(dataXs, dataCos);
            vline1  = avaPlot1.Plot.AddVerticalLine(0);
            vline2  = avaPlot1.Plot.AddVerticalLine(50);

            avaPlot1.Refresh();

            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 ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var style   = (ScottPlot.Styles.IStyle)listBoxStyle.SelectedItem;
            var palette = (ScottPlot.Drawing.Palette)listBoxPalette.SelectedItem;

            if (style is null || palette is null)
            {
                return;
            }

            avaPlot.Plot.Style(style);
            avaPlot.Plot.Palette = palette;
            avaPlot.Plot.Title($"Style: {style}\nPalette: {palette}");
            avaPlot.Plot.Clear();

            for (int i = 0; i < palette.Count(); i++)
            {
                double   offset = 1 + i * 1.1;
                double   mult   = 10 + i;
                double   phase  = i * .3 / palette.Count();
                double[] ys     = DataGen.Sin(51, 1, offset, mult, phase);
                var      sig    = avaPlot.Plot.AddSignal(ys);
                sig.LineWidth  = 3;
                sig.MarkerSize = 0;
            }

            avaPlot.Plot.AxisAuto(horizontalMargin: 0);
            avaPlot.Refresh();
        }
예제 #6
0
        public RightClickMenu()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Plot.AddSignal(DataGen.Sin(51));
            avaPlot1.Plot.AddSignal(DataGen.Cos(51));
            avaPlot1.Refresh();

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

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

            //avaPlot1.SetContextMenu(contextMenu);
        }
예제 #7
0
 void Render(object sender, EventArgs e)
 {
     if (AutoAxisCheckbox.IsChecked == true)
     {
         avaPlot1.Plot.AxisAuto();
     }
     avaPlot1.Refresh();
 }
예제 #8
0
        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.Refresh();
        }
예제 #9
0
        private void UpdateChildPlots()
        {
            lowerPlot.Plot.MatchAxis(mainPlot.Plot, horizontal: true, vertical: false);
            rightPlot.Plot.MatchAxis(mainPlot.Plot, horizontal: false, vertical: true);

            lowerPlot.Plot.MatchLayout(mainPlot.Plot, horizontal: true, vertical: false);
            rightPlot.Plot.MatchLayout(mainPlot.Plot, horizontal: false, vertical: true);

            lowerPlot.Refresh();
            rightPlot.Refresh();
        }
예제 #10
0
        public AxisLimits()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            AvaPlot wpfPlot1 = this.Find <AvaPlot>("avaPlot1");

            wpfPlot1.Plot.AddSignal(DataGen.Sin(51));
            wpfPlot1.Plot.AddSignal(DataGen.Cos(51));
            wpfPlot1.Plot.AxisAuto();
            wpfPlot1.Plot.SetOuterViewLimits(0, 50, -1, 1);
            wpfPlot1.Refresh();
        }
예제 #11
0
 private void SinHide(object sender, RoutedEventArgs e)
 {
     if (avaPlot1 is null)
     {
         return;
     }
     sinPlot.IsVisible = false;
     avaPlot1.Refresh();
 }
예제 #12
0
        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.Refresh();

            avaPlot1.PointerMoved += OnMouseMove;
            avaPlot1.PointerLeave += OnMouseLeave;
            avaPlot1.PointerEnter += OnMouseEnter;
        }
예제 #13
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.Plot.AddScatter(dataXs, dataSin);
            avaPlot1.Plot.AddScatter(dataXs, dataCos);
            avaPlot1.Refresh();
        }
예제 #14
0
        public Layout()
        {
            AvaloniaXamlLoader.Load(this);
#if DEBUG
            this.AttachDevTools();
#endif
            mainPlot  = this.Find <AvaPlot>("mainPlot");
            rightPlot = this.Find <AvaPlot>("rightPlot");
            lowerPlot = this.Find <AvaPlot>("lowerPlot");

            // generate sample data
            Random rand = new Random(0);
            int[]  xs   = DataGen.RandomNormal(rand, 3000, 20, 10).Select(x => (int)x).ToArray();
            int[]  ys   = DataGen.RandomNormal(rand, 3000, 20, 10).Select(y => (int)y).ToArray();
            double[,] intensities = Tools.XYToIntensities(mode: IntensityMode.Gaussian,
                                                          xs: xs, ys: ys, width: 100, height: 70, sampleWidth: 4);

            // main plot
            var hmc = mainPlot.Plot.AddHeatmap(intensities, lockScales: false);
            var cb  = mainPlot.Plot.AddColorbar(hmc);
            mainPlot.Plot.Margins(0, 0);
            mainPlot.Plot.Title("Control Rod\nTemperature");
            mainPlot.Plot.XLabel("Horizontal Position");
            mainPlot.Plot.YLabel("Vertical Position");
            mainPlot.Refresh();

            // right plot
            double[] rowSums   = SumHorizontally(intensities).Reverse().ToArray();
            var      rightBars = rightPlot.Plot.AddBar(rowSums);
            rightBars.Orientation    = Orientation.Horizontal;
            rightBars.PositionOffset = .5;
            rightPlot.Plot.Margins(0, 0);
            rightPlot.Refresh();

            // lower plot
            double[] colSums   = SumVertically(intensities);
            var      lowerBars = lowerPlot.Plot.AddBar(colSums);
            lowerBars.PositionOffset = .5;
            lowerPlot.Plot.Margins(0, 0);
            lowerPlot.Refresh();

            UpdateChildPlots();

            mainPlot.AxesChanged += MainPlot_AxesChanged;
        }
        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.Refresh();
        }
예제 #16
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.Refresh();

            avaPlot2.Plot.AddScatter(dataXs, dataCos);
            avaPlot2.Refresh();
        }
예제 #17
0
        public RightClickMenu()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Plot.AddSignal(DataGen.Sin(51));
            avaPlot1.Plot.AddSignal(DataGen.Cos(51));
            avaPlot1.Refresh();

            ContextMenu contextMenu = new ContextMenu
            {
                Items = new[] {
                    MakeMenuItem("Add Sine Wave", AddSine),
                    MakeMenuItem("Clear Plot", ClearPlot)
                }
            };

            avaPlot1.ContextMenu = contextMenu;
        }
예제 #18
0
 void Render(object sender, EventArgs e)
 {
     avaPlot1.Refresh();
 }