Skip to main content

Plot

Struct Plot 

Source
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>
where Message: Clone, Tag: Hash + Eq + Clone, D: Float, Renderer: Renderer,

Source

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());
Source

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))
);
Source

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>>§

Source

pub fn default_font(&self) -> Font

Returns the default font of the underlying renderer

Source

pub fn measure_text(&self, text: Text<&str>) -> Size

Measures a Text to get it’s bounds

Source

pub fn clip_bounds(&self) -> Rectangle

Returns the screen bounds bounds of the plot

Methods from Deref<Target = Transform<'a, D, f32, f32>>§

Source

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);
Source

pub fn plot_bounds(&self) -> PlotRect<D>

Source

pub fn screen_to_chart_opt( &self, screen_point: &ScreenPoint<S>, ) -> Option<PlotPoint<D>>

Transforms a point from screen coordinates to chart coordinates.

Source

pub fn screen_to_chart(&self, screen_point: &ScreenPoint<S>) -> PlotPoint<D>

Transforms a point from screen coordinates to chart coordinates.

Source

pub fn chart_to_screen_opt( &self, plot_point: &PlotPoint<D>, ) -> Option<ScreenPoint<S>>

Transforms a point from chart coordinates to screen coordinates.

Source

pub fn chart_to_screen(&self, plot_point: &PlotPoint<D>) -> ScreenPoint<S>

Transforms a point from chart coordinates to screen coordinates.

Source

pub fn x_to_screen_opt(&self, plot_x: &D) -> Option<S>

Transforms a single chart x-coordinate to a screen x-coordinate.

Source

pub fn x_to_screen(&self, plot_x: &D) -> S

Transforms a single chart x-coordinate to a screen x-coordinate.

Source

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)

Source

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)

Source

pub fn x_from_screen_opt(&self, screen_x: &S) -> Option<D>

Transforms a single screen x-coordinate to a chart x-coordinate.

Source

pub fn x_from_screen(&self, screen_x: &S) -> D

Transforms a single screen x-coordinate to a chart x-coordinate.

Source

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)

Source

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)

Source

pub fn screen_to_chart_rect_opt( &self, screen_rect: ScreenRect<S>, ) -> Option<PlotRect<D>>

Transforms a rectangle from screen coordinates to chart coordinates.

Source

pub fn screen_to_chart_rect(&self, screen_rect: ScreenRect<S>) -> PlotRect<D>

Transforms a rectangle from screen coordinates to chart coordinates.

Source

pub fn chart_to_screen_rect_opt( &self, plot_rect: PlotRect<D>, ) -> Option<ScreenRect<S>>

Transforms a rectangle from chart coordinates to screen coordinates.

Source

pub fn chart_to_screen_rect(&self, plot_rect: PlotRect<D>) -> ScreenRect<S>

Transforms a rectangle from chart coordinates to screen coordinates.

Trait Implementations§

Source§

impl<'a, D: Float, Message: Clone, Tag, Renderer: Renderer> Deref for Plot<'a, D, Message, Tag, Renderer>

Source§

type Target = Context<'a, D, Renderer>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more