MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / autoscale

Method autoscale

src/plot_state.rs:350–384  ·  view source on GitHub ↗
(&mut self, update_axis_links: bool)

Source from the content-addressed store, hash-verified

348 self.x_axis_link = widget.x_axis_link.clone();
349 self.y_axis_link = widget.y_axis_link.clone();
350
351 // highlighted_points
352 self.sync_highlighted_points_from_widget(widget);
353
354 // Copy formatters
355 self.x_axis_formatter = widget.x_axis_formatter.clone();
356 self.y_axis_formatter = widget.y_axis_formatter.clone();
357
358 // Force GPU buffers to rebuild only when data actually changes
359 // (not when only hover/pick changes - that's tracked by highlight_version)
360 self.markers_version = self.markers_version.wrapping_add(1);
361 self.lines_version = self.lines_version.wrapping_add(1);
362 self.fills_version = self.fills_version.wrapping_add(1);
363 }
364
365 pub(crate) fn autoscale(&mut self, update_axis_links: bool) {
366 // Use user-specified limits if available, otherwise use data bounds
367 let mut min_v = DVec2::new(-1.0, -1.0);
368 let mut max_v = DVec2::new(1.0, 1.0);
369
370 if let (Some(data_min), Some(data_max)) = (self.data_min, self.data_max) {
371 min_v = data_min;
372 max_v = data_max;
373 }
374
375 if let Some((y_min, y_max)) = self.y_lim
376 && let (Some(y_min), Some(y_max)) = (
377 self.y_axis_scale.data_to_plot(y_min),
378 self.y_axis_scale.data_to_plot(y_max),
379 )
380 {
381 min_v.y = y_min;
382 max_v.y = y_max;
383 }
384
385 if let Some((x_min, x_max)) = self.x_lim
386 && let (Some(x_min), Some(x_max)) = (
387 self.x_axis_scale.data_to_plot(x_min),

Callers 3

handle_keyboard_eventMethod · 0.80
apply_click_actionMethod · 0.80
update_plot_programFunction · 0.80

Calls 4

data_to_plotMethod · 0.80
update_axis_linksMethod · 0.80
newFunction · 0.50
set_boundsMethod · 0.45

Tested by

no test coverage detected