Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public LiveDataFixed()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Configuration.MiddleClickAutoAxisMarginX = 0;

            // plot the data array only once
            avaPlot1.plt.PlotSignal(liveData);
            avaPlot1.plt.AxisAutoX(margin: 0);
            avaPlot1.plt.SetAxisLimits(yMin: -1, yMax: 2.5);

            // create a traditional timer to update the data
            _updateDataTimer = new Timer(_ => UpdateData(), null, 0, 5);

            // create a separate timer to update the GUI
            _renderTimer          = new DispatcherTimer();
            _renderTimer.Interval = TimeSpan.FromMilliseconds(10);
            _renderTimer.Tick    += Render;
            _renderTimer.Start();

            Closed += (sender, args) =>
            {
                _updateDataTimer?.Dispose();
                _renderTimer?.Stop();
            };
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public LiveDataGrowing()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1           = this.Find <AvaPlot>("avaPlot1");
            ReadingsTextbox    = this.Find <TextBox>("ReadingsTextbox");
            LatestValueTextbox = this.Find <TextBox>("LatestValueTextbox");
            AutoAxisCheckbox   = this.Find <CheckBox>("AutoAxisCheckbox");

            // plot the data array only once
            signalPlot = avaPlot1.Plot.AddSignal(data);
            avaPlot1.Plot.YLabel("Value");
            avaPlot1.Plot.XLabel("Sample Number");

            // create a timer to modify the data
            _updateDataTimer          = new DispatcherTimer();
            _updateDataTimer.Interval = TimeSpan.FromMilliseconds(1);
            _updateDataTimer.Tick    += UpdateData;
            _updateDataTimer.Start();

            // create a timer to update the GUI
            _renderTimer          = new DispatcherTimer();
            _renderTimer.Interval = TimeSpan.FromMilliseconds(20);
            _renderTimer.Tick    += Render;
            _renderTimer.Start();

            Closed += (sender, args) =>
            {
                _updateDataTimer?.Stop();
                _renderTimer?.Stop();
            };
        }
Exemplo n.º 5
0
        public Layout()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");
            this.Find <Button>("PlotButton").Click += PlotRandomData;
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
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.Render();

            avaPlot1.PointerMoved += OnMouseMove;
            avaPlot1.PointerLeave += OnMouseLeave;
            avaPlot1.PointerEnter += OnMouseEnter;
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
        private void AxesChanged(object sender, EventArgs e)
        {
            AvaPlot changedPlot   = (AvaPlot)sender;
            var     newAxisLimits = changedPlot.Plot.GetAxisLimits();

            foreach (AvaPlot ap in AvaPlots)
            {
                if (ap == changedPlot)
                {
                    continue;
                }

                // disable this briefly to avoid infinite loop
                ap.Configuration.AxesChangedEventEnabled = false;
                ap.Plot.SetAxisLimits(newAxisLimits);
                ap.Render();
                ap.Configuration.AxesChangedEventEnabled = true;
            }
        }
Exemplo n.º 15
0
        public StyleBrowser()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot        = this.Find <AvaPlot>("AvaPlot1");
            listBoxStyle   = this.Find <ListBox>("ListBoxStyle");
            listBoxPalette = this.Find <ListBox>("ListBoxPalette");

            listBoxStyle.Items   = ScottPlot.Style.GetStyles();
            listBoxPalette.Items = ScottPlot.Palette.GetPalettes();

            avaPlot.Plot.XLabel("Horizontal Axis");
            avaPlot.Plot.YLabel("Vertical Axis");

            listBoxPalette.SelectedIndex = 0;
            listBoxStyle.SelectedIndex   = 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.Refresh();
        }
Exemplo n.º 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();
        }
Exemplo n.º 18
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;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Prepares the chart with the RAM usage
        /// </summary>
        /// <param name="data"></param>
        /// <param name="axisXData"></param>
        private void PrepareRamChart(ChartDataModel data, double[] axisXData)
        {
            AvaPlot ramUsagePlot = this.Find <AvaPlot>("RamUsagePlot");

            // add series
            double[] ramAxisYData        = data.ResourceUsages.Select(u => Convert.ToDouble(SizeHelper.SizeValue(u.RamUsage, _displaySize))).ToArray();
            double[] maxRamAxisYData     = data.ResourceUsages.Select(u => Convert.ToDouble(SizeHelper.SizeValue(u.MaxRamAvailable, _displaySize))).ToArray();
            double[] ramPercentAxisYData = data.ResourceUsages.Select(u => Convert.ToDouble(u.RamPercentUsage)).ToArray();
            ramUsagePlot.Plot.AddScatter(axisXData, ramAxisYData, Color.Blue, 2F, label: "RAM usage");
            ramUsagePlot.Plot.AddScatter(axisXData, maxRamAxisYData, Color.Red, 2F, label: "Max RAM avaliable");
            // % ram series
            var ramScatter = ramUsagePlot.Plot.AddScatter(axisXData, ramPercentAxisYData, Color.Green, 2F, label: "% RAM usage");
            // secondary axis
            var secAxis = ramUsagePlot.Plot.AddAxis(Edge.Right, axisIndex: 2);

            secAxis.Label("% RAM usage");
            // set series to secondary axis
            ramScatter.YAxisIndex = 2;
            StylePlot(ramUsagePlot.Plot, ChartType.Ram);

            ramUsagePlot.Plot.Legend(true, Alignment.UpperLeft);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Prepares the chart with the CPU and GPU usage
        /// </summary>
        /// <param name="dataModel"></param>
        /// <param name="axisXData"></param>
        private void PrepareCpuChart(ChartDataModel dataModel, double[] axisXData)
        {
            AvaPlot cpuUsagePlot = this.Find <AvaPlot>("CpuUsagePlot");

            cpuUsagePlot.Plot.Legend(true, Alignment.UpperLeft);

            double[] cpuAxisYData        = dataModel.ResourceUsages.Select(u => Convert.ToDouble(u.ProcUsage)).ToArray();
            double[] gpuPercentAxisYData = dataModel.ResourceUsages.Select(u => Convert.ToDouble(u.GPUUsage)).ToArray();
            // cpu series
            var cpuScatter = cpuUsagePlot.Plot.AddScatter(axisXData, cpuAxisYData, Color.Blue, 2F, label: "% CPU usage");

            cpuScatter.YAxisIndex = cpuScatter.XAxisIndex = 0;
            // gpu series
            var gpuScatter = cpuUsagePlot.Plot.AddScatter(axisXData, gpuPercentAxisYData, Color.Green, 2F, label: "% GPU usage");
            // secondary axis
            var secAxis = cpuUsagePlot.Plot.AddAxis(Edge.Right, axisIndex: 2);

            //secAxis.Color(ramScatter.Color);
            secAxis.Label("% GPU usage");
            // set series to secondary axis
            gpuScatter.YAxisIndex = 2;
            // set labels
            StylePlot(cpuUsagePlot.Plot, ChartType.Cpu);
        }
Exemplo n.º 21
0
        public ShowValueOnHover()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            // create a scatter plot from some random data and save it
            Random   rand       = new Random(0);
            int      pointCount = 20;
            double[] xs         = DataGen.Random(rand, pointCount);
            double[] ys         = DataGen.Random(rand, pointCount, multiplier: 1_000);
            MyScatterPlot = avaPlot1.Plot.AddScatterPoints(xs, ys);

            // Add a red circle we can move around later as a highlighted point indicator
            HighlightedPoint             = avaPlot1.Plot.AddPoint(0, 0);
            HighlightedPoint.Color       = System.Drawing.Color.Red;
            HighlightedPoint.MarkerSize  = 10;
            HighlightedPoint.MarkerShape = ScottPlot.MarkerShape.openCircle;
            HighlightedPoint.IsVisible   = false;

            avaPlot1.PointerMoved += MouseMove;
        }
Exemplo n.º 22
0
        public LiveDataFixed()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Configure(middleClickMarginX: 0);

            // plot the data array only once
            avaPlot1.plt.PlotSignal(liveData);
            avaPlot1.plt.AxisAutoX(margin: 0);
            avaPlot1.plt.Axis(y1: -1, y2: 2.5);

            // create a traditional timer to update the data
            _timer = new Timer(_ => UpdateData(), null, 0, 5);

            // create a separate timer to update the GUI
            DispatcherTimer renderTimer = new DispatcherTimer();
            renderTimer.Interval = TimeSpan.FromMilliseconds(10);
            renderTimer.Tick    += Render;
            renderTimer.Start();
        }