Grid

Trait Grid 

Source
pub trait Grid<C: PixelColor> {
    // Required methods
    fn draw<D>(&self, viewport: Rectangle, target: &mut D) -> ChartResult<()>
       where D: DrawTarget<Color = C>;
    fn orientation(&self) -> GridOrientation;
    fn is_visible(&self) -> bool;
    fn set_visible(&mut self, visible: bool);
    fn style(&self) -> &GridStyle<C>;
    fn set_style(&mut self, style: GridStyle<C>);
    fn calculate_positions(&self, viewport: Rectangle) -> Vec<i32, 64>;
    fn spacing(&self) -> f32;
    fn set_spacing(&mut self, spacing: f32);
    fn as_any(&self) -> &dyn Any;
}
Expand description

Core trait for all grid types

Required Methods§

Source

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

Draw the grid lines to the target

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

fn orientation(&self) -> GridOrientation

Get the grid orientation (horizontal or vertical)

Source

fn is_visible(&self) -> bool

Check if the grid is visible

Source

fn set_visible(&mut self, visible: bool)

Set grid visibility

Source

fn style(&self) -> &GridStyle<C>

Get the grid style

Source

fn set_style(&mut self, style: GridStyle<C>)

Set the grid style

Source

fn calculate_positions(&self, viewport: Rectangle) -> Vec<i32, 64>

Calculate the positions where grid lines should be drawn Returns a vector of positions in screen coordinates

Source

fn spacing(&self) -> f32

Get the spacing between grid lines

Source

fn set_spacing(&mut self, spacing: f32)

Set the spacing between grid lines

Source

fn as_any(&self) -> &dyn Any

Support for downcasting to concrete types

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§

Source§

impl<C: PixelColor + 'static> Grid<C> for CustomGrid<C>

Source§

impl<C: PixelColor + 'static> Grid<C> for LinearGrid<C>

Source§

impl<T, C> Grid<C> for TickBasedGrid<T, C>
where T: Copy + PartialOrd + Display + 'static, C: PixelColor + 'static,