Example #1
0
        public void ExecuteRecipe(Plot plt)
        {
            double CustomSnapFunction(double value)
            {
                // multiple of 3 between 0 and 50
                if (value < 0)
                {
                    return(0);
                }
                else if (value > 50)
                {
                    return(50);
                }
                else
                {
                    return((int)Math.Round(value / 3) * 3);
                }
            }

            // different snap sytems can be created and customized
            var SnapDisabled = new ScottPlot.SnapLogic.NoSnap1D();
            var SnapCustom   = new SnapLogic.Custom1D(CustomSnapFunction);

            plt.AddSignal(DataGen.Sin(51, mult: 5));
            plt.AddSignal(DataGen.Cos(51, mult: 5));

            var vLine = plt.AddVerticalLine(30);

            vLine.DragEnabled = true;
            vLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(SnapCustom, SnapDisabled);
        }
Example #2
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51, mult: 5));
            plt.AddSignal(DataGen.Cos(51, mult: 5));
            double[] snapPositions = DataGen.Consecutive(11, 5);

            // different snap sytems can be created and customized
            var SnapDisabled      = new ScottPlot.SnapLogic.NoSnap1D();
            var SnapNearestInt    = new ScottPlot.SnapLogic.Integer1D();
            var SnapNearestInList = new ScottPlot.SnapLogic.Nearest1D(snapPositions);

            var hLine = plt.AddHorizontalLine(2);

            hLine.DragEnabled = true;
            hLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(x: SnapDisabled, y: SnapNearestInt);

            var vLine = plt.AddVerticalLine(30);

            vLine.DragEnabled = true;
            vLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(x: SnapNearestInList, y: SnapDisabled);
        }