Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot: Create Clear<T>() as an alias for Remove<T>() #3804

Closed
swharden opened this issue May 7, 2024 · 4 comments
Closed

Plot: Create Clear<T>() as an alias for Remove<T>() #3804

swharden opened this issue May 7, 2024 · 4 comments
Labels
Good First Issue This issue has limited complexity and may be a good start for new contributors Help Wanted Scott won't do this soon, but PRs from the community are welcome! ⚠️ HIGH PRIORITY

Comments

@swharden
Copy link
Member

swharden commented May 7, 2024

The same way that GetPlottables() works

public IEnumerable<IPlottable> GetPlottables()
{
return PlottableList;
}

@swharden swharden added ⚠️ HIGH PRIORITY Good First Issue This issue has limited complexity and may be a good start for new contributors Help Wanted Scott won't do this soon, but PRs from the community are welcome! labels May 7, 2024
@UrbaLaba7
Copy link

UrbaLaba7 commented May 9, 2024

Might be useful, from my code where need to remove dashed lines and repaint.

        // Iterate through plot's elements and remove dashed lines
        void RemoveDashedLines(Plot plot)
        {
            for (int i = plot.PlottableList.Count - 1; i >= 0; i--)
            {
                if (plot.PlottableList[i] is Scatter scatter && scatter.LineStyle.Pattern == LinePattern.Dashed)
                    plot.Remove(scatter);
            }
        }

@CoderPM2011
Copy link
Contributor

It seems the same as Remove<T>().

/// <summary>
/// Remove a all instances of a specific type from the <see cref="PlottableList"/>.
/// </summary>
/// <typeparam name="T">Type of <see cref="IPlottable"/> to be removed</typeparam>
public void Remove<T>() where T : IPlottable
{
PlottableList.RemoveAll(x => x is T);
}

@swharden
Copy link
Member Author

It seems the same as Remove<T>()

Good find! That's the exact function I was looking for and I forgot it was there 😅

I instinctively reached for Clear<T>() so maybe we should add it as an alias to Remove<T>() to make it more discoverable

@swharden swharden changed the title Plot.Clear() should have a generic version that only removes one type of plottable Plot: Create Clear<T>() as an alias for Remove<T>() May 10, 2024
@swharden
Copy link
Member Author

resolved in #3820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue This issue has limited complexity and may be a good start for new contributors Help Wanted Scott won't do this soon, but PRs from the community are welcome! ⚠️ HIGH PRIORITY
Projects
None yet
Development

No branches or pull requests

3 participants