Skip to content

SP4: SignalPlotBase.FillDisable() is broken #2436

@szescxz

Description

@szescxz

Bug Report

Issue:
SignalPlotBase.FillDisable() causes an InvalidOperationException in certain cases:

if (_FillColor1 is null && _FillType != FillType.NoFill)
throw new InvalidOperationException($"A Color must be assigned to FillColor1 to use fill type '{_FillType}'");

Reproducing:

var plt = new ScottPlot.Plot(600, 400);

var rand = new Random(0);
double[] values = DataGen.RandomWalk(rand, 100_000);
int sampleRate = 20_000;

var sig = plt.AddSignal(values, sampleRate);
//sig.FillAboveAndBelow(plt.GetSettings().GetNextColor(), plt.GetSettings().GetNextColor()); // <- uncommenting this line will not throw the exception but next line won't actually disable fill either
sig.FillDisable();

plt.SaveFig("example.png");

I guess the cause is obvious:

public void FillDisable()
{
_FillType = FillType.FillBelow;
_GradientFillColor1 = null;
_GradientFillColor2 = null;
}

System Details

  • ScottPlot Version: 4.1.61
  • Operating System: Windows 11
  • Application Type: WPF
  • .NET Version: .NET Framework 4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behaviorGood First IssueThis issue has limited complexity and may be a good start for new contributorsHelp WantedScott won't do this soon, but PRs from the community are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions