Closed jon-rizzo closed 7 months ago
Hi @jon-rizzo, thanks for this question!
In console applications the easiest way to reset a Plot is like this:
ScottPlot.Plot plot = new();
plot.Dispose();
plot = new(); // a clean one!
In user controls the way to reset a plot is something like:
formsPlot1.Plot.Reset();
formsPlot1.Refresh();
I noticed that Reset()
isn't in IPlotControl
but if we think it should be, we could add it to ensure all controls have this feature.
EDIT: If we add Reset()
we should also add Reset(Plot newPlot)
too
Let me know if this doesn't do the trick!
Following-up, I misunderstood the original suggestion 😅
I agree that this is a good idea and I'll leave this issue open until someone (or me if no one takes it, lol) adds the following methods to IPlotControl
/// <summary>
/// Disposes the current Plot and creates a new one for the control
/// </summary>
void Reset();
/// <summary>
/// Loads the given Plot into the control
/// </summary>
void Reset(Plot plot);
These methods are already implemented in FormsPlot, and maybe other controls too....
I have add the following methods to IPlotControl :
/// <summary>
/// Disposes the current Plot and creates a new one for the control
/// </summary>
void Reset();
/// <summary>
/// Loads the given Plot into the control
/// </summary>
void Reset(Plot plot);
But PR check failed please check it out.
There is probably a technical reason that I am not aware of and this is very minor point for sure, but it seems to me that it would be helpful to have Reset() on IPlotControl, since it seems to be implemented separately on each control anyways. This would allow us to build controls that know how to "wipe the slate clean" regardless of which platform they are implemented on.