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

Method build

src/plot_widget_builder.rs:365–492  ·  view source on GitHub ↗

Build the PlotWidget; validates series and duplicate labels via PlotWidget::add_series.

(self)

Source from the content-addressed store, hash-verified

363 point.display_y()
364 ))
365 }
366 }
367
368 /// Build the PlotWidget; validates series and duplicate labels via PlotWidget::add_series.
369 pub fn build(self) -> Result<PlotWidget, SeriesError> {
370 let x_axis_scale = self.x_axis_scale.unwrap_or_default();
371 let y_axis_scale = self.y_axis_scale.unwrap_or_default();
372
373 for scale in [x_axis_scale, y_axis_scale] {
374 if let AxisScale::Log { base } = scale
375 && !(base.is_finite() && base > 1.0)
376 {
377 return Err(SeriesError::InvalidAxisScale);
378 }
379 }
380
381 if let Some((x_min, x_max)) = self.x_lim
382 && x_min >= x_max
383 {
384 return Err(SeriesError::InvalidAxisLimits);
385 }
386 if let Some((y_min, y_max)) = self.y_lim
387 && y_min >= y_max
388 {
389 return Err(SeriesError::InvalidAxisLimits);
390 }
391
392 let mut w = PlotWidget::new();
393 w.set_x_axis_scale(x_axis_scale);
394 w.set_y_axis_scale(y_axis_scale);
395 if let Some(controls) = self.controls {
396 w.set_controls(controls);
397 }
398 if let Some(enabled) = self.controls_help {
399 w.set_controls_help(enabled);
400 }
401 if self.disable_legend {
402 w.legend_enabled = false;
403 }
404
405 if let Some(enabled) = self.autoscale_on_updates {
406 w.autoscale_on_updates(enabled);
407 }
408 if let Some(r) = self.hover_radius_px {
409 w.hover_radius_px(r);
410 }
411 if let Some(enabled) = self.highlight_on_hover {
412 w.set_highlight_on_hover(enabled);
413 }
414 if let Some(x) = self.x_label {
415 w.set_x_axis_label(x);
416 }
417 if let Some(y) = self.y_label {
418 w.set_y_axis_label(y);
419 }
420 if let Some((min, max)) = self.x_lim {
421 w.set_x_lim(min, max);
422 }

Callers 15

newFunction · 0.80
newFunction · 0.80
newMethod · 0.80
plot_widgetFunction · 0.80
plot_widgetFunction · 0.80
newFunction · 0.80
newFunction · 0.80
newMethod · 0.80
new_plotFunction · 0.80
newMethod · 0.80
newFunction · 0.80
newFunction · 0.80

Calls 15

set_x_axis_scaleMethod · 0.80
set_y_axis_scaleMethod · 0.80
set_controlsMethod · 0.80
set_controls_helpMethod · 0.80
autoscale_on_updatesMethod · 0.80
hover_radius_pxMethod · 0.80
set_x_axis_labelMethod · 0.80
set_y_axis_labelMethod · 0.80
set_x_limMethod · 0.80
set_y_limMethod · 0.80
set_cursor_overlayMethod · 0.80

Tested by

no test coverage detected