-
Notifications
You must be signed in to change notification settings - Fork 90
Add optional legend title #105
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
Conversation
emilk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but the title should always be on top
| pub text_style: TextStyle, | ||
| pub background_alpha: f32, | ||
| pub position: Corner, | ||
| pub title: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use WidgetText instead for more customizability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't work as WidgetText does not implement serde - we could do this here too but i dont know if that is good
|
when we update to the newer egui main we can use PixelThreshold so these tests dont fail anymore |
# Conflicts: # demo/tests/snapshots/demos/Items.png # demo/tests/snapshots/demos/Lines.png # demo/tests/snapshots/demos/Markers.png # demo/tests/snapshots/light_mode.png # demo/tests/snapshots/scale_0.50.png # demo/tests/snapshots/scale_1.00.png # demo/tests/snapshots/scale_1.39.png # demo/tests/snapshots/scale_2.00.png
This pull request introduces enhancements to the `Legend` functionality
in the `egui_plot` library, updates the plot demos to include legend
titles, and modifies related tests and snapshots to reflect these
changes. The most significant changes include adding a `title` property
to the `Legend` struct, updating plot demos to utilize this new feature,
and adjusting test infrastructure and snapshots accordingly.
### Enhancements to `Legend` functionality:
*
[`egui_plot/src/legend.rs`](diffhunk://#diff-41de195c6ebce678a328dcb6d36642dcccd13eb73aa023e13590b61e2f74f1cfR49):
Added a `title` property to the `Legend` struct, with a default value of
`None`. Introduced a new `title` method to set the legend title and
updated the `LegendWidget` to display the title if it is set.
[[1]](diffhunk://#diff-41de195c6ebce678a328dcb6d36642dcccd13eb73aa023e13590b61e2f74f1cfR49)
[[2]](diffhunk://#diff-41de195c6ebce678a328dcb6d36642dcccd13eb73aa023e13590b61e2f74f1cfR64)
[[3]](diffhunk://#diff-41de195c6ebce678a328dcb6d36642dcccd13eb73aa023e13590b61e2f74f1cfR94-R100)
[[4]](diffhunk://#diff-41de195c6ebce678a328dcb6d36642dcccd13eb73aa023e13590b61e2f74f1cfR340-R342)
### Updates to plot demos:
*
[`demo/src/plot_demo.rs`](diffhunk://#diff-5a1025d5dd6c016d4b4017e33bb3322bd767ab0591195efa41a2a41da09efc9eL286-R286):
Updated the `Legend` configuration in `LineDemo`, `MarkerDemo`, and
`ItemsDemo` to include titles ("Lines", "Markers", and "Items",
respectively).
[[1]](diffhunk://#diff-5a1025d5dd6c016d4b4017e33bb3322bd767ab0591195efa41a2a41da09efc9eL286-R286)
[[2]](diffhunk://#diff-5a1025d5dd6c016d4b4017e33bb3322bd767ab0591195efa41a2a41da09efc9eL376-R376)
[[3]](diffhunk://#diff-5a1025d5dd6c016d4b4017e33bb3322bd767ab0591195efa41a2a41da09efc9eL764-R768)
* Closes <#98>
* [x] I have followed the instructions in the PR template
---------
Co-authored-by: lucasmerlin <hi@lucasmerlin.me>
This pull request introduces enhancements to the
Legendfunctionality in theegui_plotlibrary, updates the plot demos to include legend titles, and modifies related tests and snapshots to reflect these changes. The most significant changes include adding atitleproperty to theLegendstruct, updating plot demos to utilize this new feature, and adjusting test infrastructure and snapshots accordingly.Enhancements to
Legendfunctionality:egui_plot/src/legend.rs: Added atitleproperty to theLegendstruct, with a default value ofNone. Introduced a newtitlemethod to set the legend title and updated theLegendWidgetto display the title if it is set. [1] [2] [3] [4]Updates to plot demos:
demo/src/plot_demo.rs: Updated theLegendconfiguration inLineDemo,MarkerDemo, andItemsDemoto include titles ("Lines", "Markers", and "Items", respectively). [1] [2] [3]Closes Title (or label) for legend. #98
I have followed the instructions in the PR template