-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Formatter for plot axis labels #1130
Conversation
One open question is positioning of the labels. In the screenshot above I had to "hide" the Y=0 value Problems like these could be solved by specifying the alignment (left/right/center) and orientation (horizontal/vertical) of the text along the axis. But I think it's an orthogonal problem to text formatting (no pun intended), so it should be possible to do it in a separate PR. |
# Conflicts: # CHANGELOG.md # egui/src/widgets/plot/mod.rs
Fixed merge conflicts. |
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! Just left a couple of nits
Applied the suggestions. Sorry for the many CI runs, wasn't aware that previous runs would complete. In case you're interested, it's possible to abort previous runs as done here: # If a new commit is pushed before the old one's CI has completed (on the same branch), abort previous run
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true This might only work for the |
Adds two methods
Plot::x_axis_formatter
andPlot::y_axis_formatter()
.Also fixes the bug where
Orientation
was used in public fields, but wasn't public itself.With them, it's possible to customize the displayed labels along the axes.
It's also possible to return the empty string, in order to not display a label. This can be useful for discrete X/Y domains, when there isn't a meaningful label beyond certain resolution or zoom level. An example can be dates, with only full days.
Here's a screenshot of the stacked bar-chart, with X axis labeled as days and Y axis as percentage.
This example is now implemented in the plot demo.
Closes #725.