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

egui_plot 0.25.0 - No auto_bounds + include_X/Y does not render anything until double click #25

Open
rnd-ash opened this issue Jan 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@rnd-ash
Copy link

rnd-ash commented Jan 26, 2024

Describe the bug

When trying to manually set the data view port with Include X/Y, the plot will show nothing until double clicked.

This is being done to hide the most recent plot point of data in a historic time series (Which is retrieved every 100ms or so), in order to avoid the appearance of stuttering when data comes in. (Stuttering will appear as soon as plot.auto_bounds([true, true].into()) is used.

To Reproduce

  1. Create a thread which adds a plot point every 100ms or so
let mut plot = Plot::new(d.group_name.clone())
                          .height(space_per_chart)
                          .allow_drag(false)
                          .include_x(disp_now as f64) // Timestamp now - 100.0ms to hide the most recent plot point (To look smooth)
                          .include_x(last_bound) // Timestamp now - 20 seconds
                          .legend(legend.clone());
                      if let Some((min, max)) = &d.bounds {// Data has finite range in Y dir, restrict it
                          plot = plot.include_y(*min);
                          if *max > 0.1 {
                              // 0.0 check
                              plot = plot.include_y(*max);
                          }
                      }
                     // False False - User has to double click to show the chart, and it looks smooth
                    //  True True - Plot stutters as the infrequent data will show
                      plot = plot.auto_bounds([false, false].into());
                      plot.show(col, |f| {
                          for line in lines {
                              f.line(line);
                          }
                      });

Expected behavior
Plot should show the requested area immediately, rather than wait for user input.

Screenshots
With plot = plot.auto_bounds([false, false].into()); (Buggy)
Kooha-2024-01-26-10-09-39.webm

With plot = plot.auto_bounds([true, true].into()); (Stutters, but expected behaviour, hence why no autobounds is being used)
Kooha-2024-01-26-10-10-42.webm

@rnd-ash rnd-ash added the bug Something isn't working label Jan 26, 2024
@aholtzma-am
Copy link

This problem seems to be that the bounds set by include_x()/include_y() will not be used except on the first call. These methods set min_auto_bounds, which is only used to initially set the bounds memory or to restore the initial bounds by double clicking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants