Axis

Trait Axis 

Source
pub trait Axis<T, C: PixelColor> {
    type TickGenerator: TickGenerator<T>;
    type Style;

    // Required methods
    fn min(&self) -> T;
    fn max(&self) -> T;
    fn orientation(&self) -> AxisOrientation;
    fn position(&self) -> AxisPosition;
    fn transform_value(&self, value: T, viewport: Rectangle) -> i32;
    fn inverse_transform(&self, coordinate: i32, viewport: Rectangle) -> T;
    fn tick_generator(&self) -> &Self::TickGenerator;
    fn style(&self) -> &Self::Style;
    fn draw<D>(&self, viewport: Rectangle, target: &mut D) -> ChartResult<()>
       where D: DrawTarget<Color = C>;
    fn required_space(&self) -> u32;
}
Expand description

Core trait for all axis types

Required Associated Types§

Source

type TickGenerator: TickGenerator<T>

The tick generator type for this axis

Source

type Style

The style type for this axis

Required Methods§

Source

fn min(&self) -> T

Get the minimum value of the axis

Source

fn max(&self) -> T

Get the maximum value of the axis

Source

fn orientation(&self) -> AxisOrientation

Get the axis orientation

Source

fn position(&self) -> AxisPosition

Get the axis position

Source

fn transform_value(&self, value: T, viewport: Rectangle) -> i32

Transform a data value to screen coordinate

§Arguments
  • value - The data value to transform
  • viewport - The available drawing area
Source

fn inverse_transform(&self, coordinate: i32, viewport: Rectangle) -> T

Transform a screen coordinate back to data value

§Arguments
  • coordinate - The screen coordinate
  • viewport - The available drawing area
Source

fn tick_generator(&self) -> &Self::TickGenerator

Get the tick generator for this axis

Source

fn style(&self) -> &Self::Style

Get the style configuration

Source

fn draw<D>(&self, viewport: Rectangle, target: &mut D) -> ChartResult<()>
where D: DrawTarget<Color = C>,

Draw the axis to the target

§Arguments
  • viewport - The area to draw the axis in
  • target - The display target to draw to
Source

fn required_space(&self) -> u32

Calculate the space required for this axis (labels, ticks, etc.)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§