pub struct Transform { /* private fields */ }Expand description
A one-dimensional coordinate transform for a series or reference line.
For normal data coordinates, the transform is a value converter that runs
before the plot’s axis scale. For example, Transform::affine(2.0, -1.0)
draws raw * 2 - 1, then lets the x/y axis scale map that value into plot
space.
Transform::axes() is different: it treats the input as a normalized
position inside the plot area. 0.4 means 40% from the low edge, so the
position stays fixed while the user pans or zooms.
Implementations§
Source§impl Transform
impl Transform
Sourcepub const fn axes() -> Self
pub const fn axes() -> Self
Interpret values as normalized positions inside the plot area.
0.0 is the low edge of the axis and 1.0 is the high edge. A point
using PositionTransform::axes() therefore remains fixed in the plot
area during pan and zoom.
Sourcepub const fn affine(scale: f64, translate: f64) -> Self
pub const fn affine(scale: f64, translate: f64) -> Self
Convert a data value with value * scale + translate before axis scaling.
Sourcepub const fn log(base: f64) -> Self
pub const fn log(base: f64) -> Self
Convert a data value with log_base(value) before axis scaling.
Sourcepub const fn exp(base: f64) -> Self
pub const fn exp(base: f64) -> Self
Convert a data value with base.powf(value) before axis scaling.
Sourcepub fn coordinate_system(&self) -> CoordinateSystem
pub fn coordinate_system(&self) -> CoordinateSystem
Return the transform’s source coordinate system.
Sourcepub fn then(self, next: Transform) -> Self
pub fn then(self, next: Transform) -> Self
Run this value conversion, then run another one.
The returned transform applies self first, then next. The source
coordinate system of self is retained.
Sourcepub fn transform_value(&self, value: f64) -> Option<f64>
pub fn transform_value(&self, value: f64) -> Option<f64>
Convert a raw value using only this transform’s operation.
Sourcepub fn transform_data(&self, pos: f64, axis_scale: AxisScale) -> Option<f64>
pub fn transform_data(&self, pos: f64, axis_scale: AxisScale) -> Option<f64>
Convert a data-coordinate value into plot-space.
This applies the transform first, then the axis scale. Transform::axes()
needs the current axis range, which is only available internally during
rendering.
Sourcepub fn transform_position(
&self,
pos: f64,
axis_scale: AxisScale,
axis_range: [f64; 2],
) -> Option<f64>
pub fn transform_position( &self, pos: f64, axis_scale: AxisScale, axis_range: [f64; 2], ) -> Option<f64>
Convert a value into a normalized [0, 1] position along an axis.
Data-coordinate transforms use axis_range as raw data coordinates.
Axes-coordinate transforms already store normalized positions.
Trait Implementations§
impl StructuralPartialEq for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnsafeUnpin for Transform
impl UnwindSafe for Transform
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> DowncastSync for T
impl<T> DowncastSync for T
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<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.