Struct plotters_druid::Plot
source · [−]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
sourceimpl<T: Data> Plot<T>
impl<T: Data> Plot<T>
sourcepub fn new(
f: impl Fn((u32, u32), &T, &DrawingArea<PietBackend<'_, '_>, Shift>) + 'static
) -> Plot<T>
pub fn new(
f: impl Fn((u32, u32), &T, &DrawingArea<PietBackend<'_, '_>, Shift>) + 'static
) -> Plot<T>
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
sourceimpl<T> Widget<T> for Plot<T> where
T: Data,
impl<T> Widget<T> for Plot<T> where
T: Data,
sourcefn event(&mut self, _: &mut EventCtx<'_, '_>, _: &Event, _: &mut T, _: &Env)
fn event(&mut self, _: &mut EventCtx<'_, '_>, _: &Event, _: &mut T, _: &Env)
Handle an event. Read more
sourcefn lifecycle(
&mut self,
_: &mut LifeCycleCtx<'_, '_>,
_: &LifeCycle,
_: &T,
_: &Env
)
fn lifecycle(
&mut self,
_: &mut LifeCycleCtx<'_, '_>,
_: &LifeCycle,
_: &T,
_: &Env
)
Handle a life cycle notification. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for Plot<T>
impl<T> !Send for Plot<T>
impl<T> !Sync for Plot<T>
impl<T> Unpin for Plot<T>
impl<T> !UnwindSafe for Plot<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
pub fn round_into(self) -> U
sourceimpl<T, W> WidgetExt<T> for W where
T: Data,
W: 'static + Widget<T>,
impl<T, W> WidgetExt<T> for W where
T: Data,
W: 'static + Widget<T>,
sourcefn align_left(self) -> Align<T>
fn align_left(self) -> Align<T>
sourcefn align_right(self) -> Align<T>
fn align_right(self) -> Align<T>
sourcefn align_vertical(self, align: UnitPoint) -> Align<T>
fn align_vertical(self, align: UnitPoint) -> Align<T>
sourcefn align_horizontal(self, align: UnitPoint) -> Align<T>
fn align_horizontal(self, align: UnitPoint) -> Align<T>
sourcefn fix_height(self, height: f64) -> SizedBox<T>
fn fix_height(self, height: f64) -> SizedBox<T>
sourcefn expand_width(self) -> SizedBox<T>
fn expand_width(self) -> SizedBox<T>
sourcefn expand_height(self) -> SizedBox<T>
fn expand_height(self) -> SizedBox<T>
sourcefn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
sourcefn border(
self,
color: impl Into<KeyOrValue<Color>>,
width: impl Into<KeyOrValue<f64>>
) -> Container<T>
fn border(
self,
color: impl Into<KeyOrValue<Color>>,
width: impl Into<KeyOrValue<f64>>
) -> Container<T>
sourcefn controller<C>(self, controller: C) -> ControllerHost<Self, C> where
C: Controller<T, Self>,
fn controller<C>(self, controller: C) -> ControllerHost<Self, C> where
C: Controller<T, Self>,
Wrap this widget with the provided Controller. Read more
sourcefn on_click(
self,
f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static
) -> ControllerHost<Self, Click<T>>
fn on_click(
self,
f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static
) -> ControllerHost<Self, Click<T>>
sourcefn debug_paint_layout(self) -> EnvScope<T, Self>
fn debug_paint_layout(self) -> EnvScope<T, Self>
sourcefn debug_widget_id(self) -> EnvScope<T, Self>
fn debug_widget_id(self) -> EnvScope<T, Self>
Display the WidgetIds for this widget and its children, when hot. Read more
sourcefn debug_invalidation(self) -> DebugInvalidation<T, Self>
fn debug_invalidation(self) -> DebugInvalidation<T, Self>
Draw a color-changing rectangle over this widget, allowing you to see the invalidation regions. Read more
sourcefn debug_widget(self) -> EnvScope<T, Self>
fn debug_widget(self) -> EnvScope<T, Self>
Set the DEBUG_WIDGET env variable for this widget (and its descendants). Read more
sourcefn parse(self) -> Parse<Self> where
Self: Widget<String>,
fn parse(self) -> Parse<Self> where
Self: Widget<String>,
Use TextBox::with_formatter instead
Parse a Widget<String>’s contents