pub struct Plot<'a, D: Float, Message: Clone, Tag = (), Renderer: Renderer = Renderer> { /* private fields */ }Expand description
The plot rendering context for drawing shapes.
This is passed to your PlotData::draw implementation. Use [Plot::add_shape]
to render visual elements.
Implementations§
Source§impl<'a, D, Message, Tag, Renderer> Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag, Renderer> Plot<'a, D, Message, Tag, Renderer>
Sourcepub fn plot_bounds(&self) -> PlotRect<D>
pub fn plot_bounds(&self) -> PlotRect<D>
Returns the current plot bounds in data space.
§Example
let bounds = plot.bounds();
let (x_min, x_max) = (bounds.min_x(), bounds.max_x());
let (y_min, y_max) = (bounds.min_y(), bounds.max_y());Sourcepub fn render<S: Shape<D, Renderer>>(&mut self, shape: S)
pub fn render<S: Shape<D, Renderer>>(&mut self, shape: S)
Renders a shape to the plot.
§Example
plot.add_shape(
Ellipse::new(PlotPoint::new(5.0, 10.0), Measure::Screen(20.0), Measure::Screen(10.0))
.fill(Color::from_rgb(1.0, 0.0, 0.0))
);Sourcepub fn push_interaction(
&mut self,
id: impl Into<Id<Tag>>,
interaction: impl Into<Interaction<Message, Tag>>,
)
pub fn push_interaction( &mut self, id: impl Into<Id<Tag>>, interaction: impl Into<Interaction<Message, Tag>>, )
Pushes an interaction to the plot
Methods from Deref<Target = Context<'a, D, Renderer>>§
Sourcepub fn default_font(&self) -> Font
pub fn default_font(&self) -> Font
Returns the default font of the underlying renderer
Sourcepub fn measure_text(&self, text: Text<&str>) -> Size
pub fn measure_text(&self, text: Text<&str>) -> Size
Measures a Text to get it’s bounds
Sourcepub fn clip_bounds(&self) -> Rectangle
pub fn clip_bounds(&self) -> Rectangle
Returns the screen bounds bounds of the plot
Methods from Deref<Target = Transform<'a, D, f32, f32>>§
Sourcepub fn screen_bounds(&self) -> &ScreenRect<S>
pub fn screen_bounds(&self) -> &ScreenRect<S>
Returns the screen rectangle bounds used by this transform.
This is the same rectangle that was passed to Transform::new.
§Examples
use aksel::{Transform, scale::Linear, ScreenRect};
let screen = ScreenRect { x: 0.0, y: 0.0, width: 800.0, height: 600.0 };
let x_scale = Linear::<f64, f32>::new(0.0, 100.0);
let y_scale = Linear::<f64, f32>::new(0.0, 50.0);
let transform = Transform::new(&screen, &x_scale, &y_scale);
let bounds = transform.screen_bounds();
assert_eq!(bounds.width, 800.0);
assert_eq!(bounds.height, 600.0);pub fn plot_bounds(&self) -> PlotRect<D>
Sourcepub fn screen_to_chart_opt(
&self,
screen_point: &ScreenPoint<S>,
) -> Option<PlotPoint<D>>
pub fn screen_to_chart_opt( &self, screen_point: &ScreenPoint<S>, ) -> Option<PlotPoint<D>>
Transforms a point from screen coordinates to chart coordinates.
Sourcepub fn screen_to_chart(&self, screen_point: &ScreenPoint<S>) -> PlotPoint<D>
pub fn screen_to_chart(&self, screen_point: &ScreenPoint<S>) -> PlotPoint<D>
Transforms a point from screen coordinates to chart coordinates.
Sourcepub fn chart_to_screen_opt(
&self,
plot_point: &PlotPoint<D>,
) -> Option<ScreenPoint<S>>
pub fn chart_to_screen_opt( &self, plot_point: &PlotPoint<D>, ) -> Option<ScreenPoint<S>>
Transforms a point from chart coordinates to screen coordinates.
Sourcepub fn chart_to_screen(&self, plot_point: &PlotPoint<D>) -> ScreenPoint<S>
pub fn chart_to_screen(&self, plot_point: &PlotPoint<D>) -> ScreenPoint<S>
Transforms a point from chart coordinates to screen coordinates.
Sourcepub fn x_to_screen_opt(&self, plot_x: &D) -> Option<S>
pub fn x_to_screen_opt(&self, plot_x: &D) -> Option<S>
Transforms a single chart x-coordinate to a screen x-coordinate.
Sourcepub fn x_to_screen(&self, plot_x: &D) -> S
pub fn x_to_screen(&self, plot_x: &D) -> S
Transforms a single chart x-coordinate to a screen x-coordinate.
Sourcepub fn y_to_screen_opt(&self, plot_y: &D) -> Option<S>
pub fn y_to_screen_opt(&self, plot_y: &D) -> Option<S>
Transforms a single chart y-coordinate to a screen y-coordinate. (This includes the y-axis inversion)
Sourcepub fn y_to_screen(&self, plot_y: &D) -> S
pub fn y_to_screen(&self, plot_y: &D) -> S
Transforms a single chart y-coordinate to a screen y-coordinate. (This includes the y-axis inversion)
Sourcepub fn x_from_screen_opt(&self, screen_x: &S) -> Option<D>
pub fn x_from_screen_opt(&self, screen_x: &S) -> Option<D>
Transforms a single screen x-coordinate to a chart x-coordinate.
Sourcepub fn x_from_screen(&self, screen_x: &S) -> D
pub fn x_from_screen(&self, screen_x: &S) -> D
Transforms a single screen x-coordinate to a chart x-coordinate.
Sourcepub fn y_from_screen_opt(&self, screen_y: &S) -> Option<D>
pub fn y_from_screen_opt(&self, screen_y: &S) -> Option<D>
Transforms a single screen y-coordinate to a chart y-coordinate. (This accounts for the y-axis inversion)
Sourcepub fn y_from_screen(&self, screen_y: &S) -> D
pub fn y_from_screen(&self, screen_y: &S) -> D
Transforms a single screen y-coordinate to a chart y-coordinate. (This accounts for the y-axis inversion)
Sourcepub fn screen_to_chart_rect_opt(
&self,
screen_rect: ScreenRect<S>,
) -> Option<PlotRect<D>>
pub fn screen_to_chart_rect_opt( &self, screen_rect: ScreenRect<S>, ) -> Option<PlotRect<D>>
Transforms a rectangle from screen coordinates to chart coordinates.
Sourcepub fn screen_to_chart_rect(&self, screen_rect: ScreenRect<S>) -> PlotRect<D>
pub fn screen_to_chart_rect(&self, screen_rect: ScreenRect<S>) -> PlotRect<D>
Transforms a rectangle from screen coordinates to chart coordinates.
Sourcepub fn chart_to_screen_rect_opt(
&self,
plot_rect: PlotRect<D>,
) -> Option<ScreenRect<S>>
pub fn chart_to_screen_rect_opt( &self, plot_rect: PlotRect<D>, ) -> Option<ScreenRect<S>>
Transforms a rectangle from chart coordinates to screen coordinates.
Sourcepub fn chart_to_screen_rect(&self, plot_rect: PlotRect<D>) -> ScreenRect<S>
pub fn chart_to_screen_rect(&self, plot_rect: PlotRect<D>) -> ScreenRect<S>
Transforms a rectangle from chart coordinates to screen coordinates.
Trait Implementations§
Auto Trait Implementations§
impl<'a, D, Message, Tag, Renderer> Freeze for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag = (), Renderer = Renderer<Renderer, Renderer>> !RefUnwindSafe for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag = (), Renderer = Renderer<Renderer, Renderer>> !Send for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag = (), Renderer = Renderer<Renderer, Renderer>> !Sync for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag, Renderer> Unpin for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag, Renderer> UnsafeUnpin for Plot<'a, D, Message, Tag, Renderer>
impl<'a, D, Message, Tag = (), Renderer = Renderer<Renderer, Renderer>> !UnwindSafe for Plot<'a, D, Message, Tag, Renderer>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more