Пример #1
0
        public HSpan PlotHSpan(
            double x1,
            double x2,
            Color?color           = null,
            double alpha          = .5,
            string label          = null,
            bool draggable        = false,
            bool dragFixedSize    = false,
            double dragLimitLower = double.NegativeInfinity,
            double dragLimitUpper = double.PositiveInfinity
            )
        {
            var axisSpan = new HSpan()
            {
                X1            = x1,
                X2            = x2,
                Color         = color ?? GetNextColor(alpha),
                Label         = label,
                DragEnabled   = draggable,
                DragFixedSize = dragFixedSize,
                DragLimitMin  = dragLimitLower,
                DragLimitMax  = dragLimitUpper,
            };

            Add(axisSpan);
            return(axisSpan);
        }
Пример #2
0
        public void Test_AxisSpan_Alpha()
        {
            var plt = new ScottPlot.Plot();

            // start with default settings
            var axSpan = new HSpan()
            {
                position1 = 1.23, position2 = 2.34
            };

            plt.Add(axSpan);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // change the plottable
            axSpan.alpha /= 2;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsLighterThan(before));
        }
Пример #3
0
        public void AxisHSpan_ExtremeZoomIn_FullScreenIsSpanColor()
        {
            var plt    = new ScottPlot.Plot();
            var axSpan = new HSpan()
            {
                X1 = 1, X2 = 10, Color = System.Drawing.Color.Green
            };

            plt.Add(axSpan);

            // Initial zoom to fill full plot with span color
            plt.AxisZoom(10);

            var smallZoomBmp = TestTools.GetLowQualityBitmap(plt);
            var smallZoom    = new MeanPixel(smallZoomBmp);

            // Extreme zoom to prove that full plot filled with span Color
            plt.AxisZoom(10_000_000);

            var extremeZoomBmp = TestTools.GetLowQualityBitmap(plt);
            var extremeZoom    = new MeanPixel(extremeZoomBmp);

            // Compare mean pixel with delta, because different ticks
            Assert.AreEqual(smallZoom.RGB, extremeZoom.RGB, 1.0);
        }
Пример #4
0
        public void Test_AxisSpan_Color()
        {
            var plt = new ScottPlot.Plot();

            // start with default settings
            var axSpan = new HSpan()
            {
                X1 = 1.23, X2 = 2.34, Color = System.Drawing.Color.Gray
            };

            plt.Add(axSpan);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // change the plottable
            axSpan.Color = System.Drawing.Color.Black;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsDarkerThan(before));
        }
Пример #5
0
        public HSpan PlotHSpan(
            double x1,
            double x2,
            Color?color           = null,
            double alpha          = .5,
            string label          = null,
            bool draggable        = false,
            bool dragFixedSize    = false,
            double dragLimitLower = double.NegativeInfinity,
            double dragLimitUpper = double.PositiveInfinity
            )
        {
            var axisSpan = new HSpan()
            {
                position1     = x1,
                position2     = x2,
                color         = color ?? settings.GetNextColor(),
                alpha         = alpha,
                label         = label,
                DragEnabled   = draggable,
                DragFixedSize = dragFixedSize
            };

            axisSpan.SetLimits(dragLimitLower, dragLimitUpper, null, null);

            Add(axisSpan);
            return(axisSpan);
        }
Пример #6
0
        /// <summary>
        /// Add a horizontal span (shades the region between two X positions)
        /// </summary>
        public HSpan AddHorizontalSpan(double xMin, double xMax, Color?color = null, string label = null)
        {
            var plottable = new HSpan()
            {
                X1    = xMin,
                X2    = xMax,
                Color = color ?? GetNextColor(.5),
                Label = label,
            };

            Add(plottable);
            return(plottable);
        }