-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Bar charts + box plots continued #863
Conversation
@EmbersArc what do you think? |
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.
Thanks so much for reviving this PR!
I'm still not sure about the ergonomics of the stacked bar charts, but I'd have to use it to be able to tell really. I think once the dead code (e.g. rulers
) is either removed or used in some way, we can merge this without issues.
egui/src/widgets/plot/transform.rs
Outdated
@@ -8,6 +8,7 @@ use crate::*; | |||
#[derive(Clone, Copy, PartialEq, Debug)] | |||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | |||
pub(crate) struct Bounds { | |||
/// [x, y] array |
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.
/// [x, y] array |
No it's not. You can just leave this function empty. We can try to think about how to extend the |
@EmbersArc the previous PR could highlight the closest bars on hovering, as well as display some associated information: This is currently disabled, but I could find a way to re-enable it, as it seems very useful. |
Also, any advice regarding the previous commits? Should I squash them, use |
If I remember correctly, the previous PR would have added something like an |
Signed-off-by: Jan Haller <[email protected]>
# Conflicts: # CHANGELOG.md # egui/src/widgets/plot/items.rs # egui/src/widgets/plot/mod.rs # egui_demo_lib/src/apps/demo/plot_demo.rs
I managed to find some time to overhaul the existing implementation and clean up a lot. Bar charts + box plots are now working, and the hovering logic is running as well. Unfortunately, during exactly that time #766 has landed, and #892 is on the way too, both could create significant merge conflicts. My implementation is not perfect yet, but I'd rather create a follow-up PR than diverging more and risking even more merge conflicts. |
Change box plot/bar chart examples to new PlotUi API # Conflicts: # egui/src/widgets/plot/mod.rs
Rename: * BoxplotDiagram -> BoxPlot * Boxplot -> BoxElem * boxplots() -> box_plot()
@EmbersArc Fixed the merge conflicts with current Worth mentioning: apart from the plots, I added the (private) I would like to express huge thanks to @niladic, who laid out the foundation and much of the work in his original PR. I made sure to attribute him as author of the original commit. 👍 |
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.
wrong account again, please ignore
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.
Gave it a quick look. Looks very good! Just a couple smaller comments.
Thanks for the feedback! Implemented two suggestions; only the |
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 really good to me! I agree there should be a demo of the "ruler" code.
@@ -0,0 +1,40 @@ | |||
//! Total order on floating point types, assuming absence of NaN. | |||
//! Can be used for sorting, min/max computation, and other collection algorithms. |
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.
I like this idea of having our own OrderedFloat
without having to pull in the much bigger ordered-float
crate. There already is an epaint::f32_hash
function in epaint/src/lib.rs
. Perhaps we should implement Hash
on OrderedFloat
and move it to epaint/src/util/ordered_float.rs
.
But let's make it support NaN
instead of panicing on them!
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.
I can also help with this refactor after merge
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.
Thanks! I'll gladly open a new PR after this one, but probably makes sense to keep it out of this (already big) changeset.
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.
Thanks for the feedback!
Not yet all points addressed, will continue tomorrow.
@@ -0,0 +1,40 @@ | |||
//! Total order on floating point types, assuming absence of NaN. | |||
//! Can be used for sorting, min/max computation, and other collection algorithms. |
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.
Thanks! I'll gladly open a new PR after this one, but probably makes sense to keep it out of this (already big) changeset.
Changes (non-exhaustive): * FloatOrd supports NaN * BoxElem combines 5 values in BoxSpread struct * Split bar/box-related functionality into multiple files * Pos2::distance_from_rect_sq() -> Rect::distance_sq_to_pos() * Consistent terminology (key -> argument)
# Conflicts: # egui/src/widgets/plot/items.rs # egui/src/widgets/plot/mod.rs # egui/src/widgets/plot/transform.rs
Merged latest master (some conflicts due to @emilk As you noted correctly, the file
What do you mean exactly? Also, if it's a feature, would it be possible to do it in another PR? I've just resolved the third big merge conflict due to branch divergence, and with the new file structure there's quite some risk for nasty conflicts 😀 Edit: I'm not sure about the merge policy, but it looks like you typically squash the commits to a single one. In case you do that, could you use the below commit message? That way, not only I receive credits, but the original author (niladic) as well. This commit message should be ready to copy/paste:
|
Changes: * Move implementation details of items under sub-modules in items * Outsource helper structs to 'values' module * Simplify stacking implementation, add f64::ord() impl * Rename HoverElem -> ClosestElem
Thanks a lot to both of you for review and feedback! It's good to have the initial implementation merged, there might be some API refinement once users get their hands on. In the meantime I moved ahead with OrderedFloat in #918. |
The addition of box/bar charts in #499 looks very valuable to me. Unfortunately the original PR seems to have been abandoned and has caused several merge conflicts in the meantime. This PR adds commits on top to update to egui's latest API. In case #499 is continued, I'm happy to close this and let my changes be integrated there 🙂
Now there are some open topics:
I didn't touch the existing commits to retain the author information; might be worth a squash. In case we rebase rather than merge latest
master
into the branch (as done now), we would probably require @niladic's and my changes to be combined into a single commit (if that's the case,Co-authored-by
could help).The "closest" algorithm is not yet integrated, as there wasn't yet any consensus on how to do it efficiently, so debug information for hovering over charts won't show. Also, is the idea that every plot type implements that algorithm on their own? Why not return something like an "outline shape" and compute close-ness based on that?
I wasn't sure about the
initialize()
methods. The trivial implementation would be the following, but is this meaningful?Naming: the original PR uses very mixed
BarChart
,barchart
,Boxplot
,boxplots
symbols. I would probably change this to usePascalCase
/snake_case
consistently.Generally, I'm quite new to egui, so let me know where things can be improved!