pub struct Plot<T: Data> { /* private fields */ }
Expand description

The type of a plot widget.

See Plot::new for information on how to construct this.

This implements druid::Widget so it can be used like any other widget type.

fn build_plot_widget() -> impl Widget<()> {
    // ... construct and return widget using Plot::new()
}

let main_window = WindowDesc::new(build_plot_widget);

Implementations

Create a plot widget

This takes a function that should draw the plot using the normal plotters API. The function has access to the width and height of the plotting area, to the Data of the rust widget, and to a plotters DrawingArea.

Plot::new(|(width, height), data: &AppState, root| {
    root.fill(&WHITE).unwrap();
    let mut chart = ChartBuilder::on(&root)
        .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)
        .unwrap();

    // see the plotters documentation on how to use `chart`
});

Trait Implementations

Handle an event. Read more

Handle a life cycle notification. Read more

Update the widget’s appearance in response to a change in the app’s Data or Env. Read more

Compute layout. Read more

Paint the widget appearance. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Wrap this widget in a Padding widget with the given Insets. Read more

Wrap this widget in an Align widget, configured to center it. Read more

Wrap this widget in an Align widget, configured to align left. Read more

Wrap this widget in an Align widget, configured to align right. Read more

Wrap this widget in an Align widget, configured to align vertically. Read more

Wrap this widget in an Align widget, configured to align horizontally. Read more

Wrap this widget in a SizedBox with an explicit width. Read more

Wrap this widget in a SizedBox with an explicit width. Read more

Wrap this widget in an SizedBox with an explicit width and height Read more

Wrap this widget in a SizedBox with an infinite width and height. Read more

Wrap this widget in a SizedBox with an infinite width. Read more

Wrap this widget in a SizedBox with an infinite width. Read more

Wrap this widget in a Container with the provided background. Read more

Wrap this widget in a Container with the given border. Read more

Wrap this widget in a EnvScope widget, modifying the parent Env with the provided closure. Read more

Wrap this widget with the provided Controller. Read more

Control the events of this widget with a Click widget. The closure provided will be called when the widget is clicked with the left mouse button. Read more

Draw the layout Rects of this widget and its children. Read more

Display the WidgetIds for this widget and its children, when hot. Read more

Draw a color-changing rectangle over this widget, allowing you to see the invalidation regions. Read more

Set the DEBUG_WIDGET env variable for this widget (and its descendants). Read more

Wrap this widget in a LensWrap widget for the provided Lens. Read more

👎 Deprecated since 0.7.0:

Use TextBox::with_formatter instead

Parse a Widget<String>’s contents

Assign the widget a specific WidgetId. Read more

Wrap this widget in a Box.