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(legend): public API for overriding hidden items #3533

Closed
jayzhudev opened this issue Nov 6, 2023 · 0 comments · Fixed by #3534
Closed

plot(legend): public API for overriding hidden items #3533

jayzhudev opened this issue Nov 6, 2023 · 0 comments · Fixed by #3534

Comments

@jayzhudev
Copy link
Contributor

Hi!

First of all, thank you so much for building and sharing this amazing and high quality crate. I've found many use cases of egui and have been using it in a few projects.

Is your feature request related to a problem? Please describe.
I was trying to find a way to control the traces' visibilities in a batch (e.g.: all on, all off) in the plots from the application code, but I couldn't find a public API in egui_plot to support this.

Describe the solution you'd like
Add a public API to allow the hidden_items (PlotMemory) to be overridden from the application code, similar to using APIs like custom_x_axes to add customizations.

Describe alternatives you've considered
I have not considered other alternatives. I hope this solution fully respects the design choices made to egui_plot.

emilk added a commit that referenced this issue Jan 6, 2024
Added a public API in `egui_plot -> legend` to allow `hidden_items` to
be overridden in the plot legend widget. This allows convenient control
of traces' visibilities the selection of traces from the application
code.

### Example
```rust
    let legend_config = if plot_selection_changed {
        let hidden_items = match plot_selection {
            PlotSelection::SelectAll => Vec::new(),
            PlotSelection::DeselectAll => all_trace_names,
        };

        Legend::default()
            .position(Corner::RightTop)
            .hidden_items(hidden_items) // Overrides `hidden_items`
    } else {
        Legend::default().position(Corner::RightTop)
    };

    Plot::new(id)
        .legend(legend_config)
        .show(ui, draw_plot);
```

Closes <#3533>.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
emilk added a commit to emilk/egui_plot that referenced this issue Jul 15, 2024
Added a public API in `egui_plot -> legend` to allow `hidden_items` to
be overridden in the plot legend widget. This allows convenient control
of traces' visibilities the selection of traces from the application
code.

### Example
```rust
    let legend_config = if plot_selection_changed {
        let hidden_items = match plot_selection {
            PlotSelection::SelectAll => Vec::new(),
            PlotSelection::DeselectAll => all_trace_names,
        };

        Legend::default()
            .position(Corner::RightTop)
            .hidden_items(hidden_items) // Overrides `hidden_items`
    } else {
        Legend::default().position(Corner::RightTop)
    };

    Plot::new(id)
        .legend(legend_config)
        .show(ui, draw_plot);
```

Closes <emilk/egui#3533>.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant