Skip to content

Grid line colors alternate with ViewSlide() enabled in DataLogger #4302

@bradcb212

Description

@bradcb212

When using ViewSlide() in DataLogger() with custom styled gridlines the colors of the grid lines alternate each time a major grid distance scrolls by.

Alternating Grid Colors
Alternating Grid Colors mp4

ScottPlot Version: ScottPlot.WPF 5.0.39

Code Sample: See http://scottplot.net/faq/repro/ for tips about creating reproducible code samples

            Logger1 = WpfPlot1.Plot.Add.DataLogger();
            Logger2 = WpfPlot1.Plot.Add.DataLogger();

            //Make it green
            Logger1.LineWidth = 3;
            Logger1.Color = new("#2b9433");
            //sig.AlwaysUseLowDensityMode = true;

            Logger2.LineWidth = 3;
            Logger2.Color = new("#f59a11");

            //Dark background with light text
            WpfPlot1.Plot.FigureBackground.Color = new("#1c1c1e");
            WpfPlot1.Plot.Axes.Color(new("#888888"));

            // shade regions between major grid lines
            WpfPlot1.Plot.Grid.XAxisStyle.FillColor1 = new ScottPlot.Color("#888888").WithAlpha(10);
            WpfPlot1.Plot.Grid.YAxisStyle.FillColor1 = new ScottPlot.Color("#888888").WithAlpha(10);

            // set grid line colors
            WpfPlot1.Plot.Grid.XAxisStyle.MajorLineStyle.Color = ScottPlot.Colors.White.WithAlpha(15);
            WpfPlot1.Plot.Grid.YAxisStyle.MajorLineStyle.Color = ScottPlot.Colors.White.WithAlpha(15);
            WpfPlot1.Plot.Grid.XAxisStyle.MinorLineStyle.Color = ScottPlot.Colors.White.WithAlpha(5);
            WpfPlot1.Plot.Grid.YAxisStyle.MinorLineStyle.Color = ScottPlot.Colors.White.WithAlpha(5);

            // enable minor grid lines by defining a positive width
            WpfPlot1.Plot.Grid.XAxisStyle.MinorLineStyle.Width = 1;
            WpfPlot1.Plot.Grid.YAxisStyle.MinorLineStyle.Width = 1;

            //Refresh
            WpfPlot1.Plot.Axes.AutoScale(false, false);
            WpfPlot1.Refresh();

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += dispatchTimer_addData;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0,1);
            dispatcherTimer.Start();

            System.Windows.Threading.DispatcherTimer dispatcherTimer2 = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer2.Tick += dispatchTimer_drawData;
            dispatcherTimer2.Interval = new TimeSpan(0, 0, 0,0,10);
            dispatcherTimer2.Start();

            WpfPlot1.Refresh();
        }

        private void dispatchTimer_addData(object sender, EventArgs e)
        {
            Logger1.Add(Walker1.Next(5));
            Logger2.Add(Walker2.Next(5));
        }
        private void dispatchTimer_drawData(object sender, EventArgs e)
        {
            if (Logger1.HasNewData || Logger2.HasNewData)
                WpfPlot1.Refresh();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions