dataviz::figure::drawers::drawer

Trait Drawer

source
pub trait Drawer {
    // Required methods
    fn draw(&mut self, canvas: &mut PixelCanvas);
    fn draw_legend(&self, canvas: &mut PixelCanvas);
    fn draw_svg(&mut self, svg_canvas: &mut SvgCanvas);

    // Provided methods
    fn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig) { ... }
    fn draw_axis(
        &self,
        canvas: &mut PixelCanvas,
        config: &FigureConfig,
        x1: i32,
        y1: i32,
        x2: i32,
        y2: i32,
    ) { ... }
    fn draw_label(
        &self,
        canvas: &mut PixelCanvas,
        config: &FigureConfig,
        x: u32,
        y: u32,
        text: &str,
    ) { ... }
    fn draw_title(
        &self,
        canvas: &mut PixelCanvas,
        config: &FigureConfig,
        x: u32,
        y: u32,
        text: &str,
    ) { ... }
    fn draw_axis_value(
        &self,
        canvas: &mut PixelCanvas,
        config: &FigureConfig,
        x: u32,
        y: u32,
        text: &str,
        axis: AxisType,
    ) { ... }
}
Expand description

A trait for rendering charts and graphs, supporting multiple output formats.

Required Methods§

source

fn draw(&mut self, canvas: &mut PixelCanvas)

Draws the main content of the plot on a PixelCanvas.

§Parameters
  • canvas: The PixelCanvas to draw the plot on.
source

fn draw_legend(&self, canvas: &mut PixelCanvas)

Draws the legend for the plot on a PixelCanvas.

§Parameters
  • canvas: The PixelCanvas to draw the legend on.
source

fn draw_svg(&mut self, svg_canvas: &mut SvgCanvas)

Draws the plot content on an SvgCanvas.

§Parameters
  • svg_canvas: The SvgCanvas to render the plot on.

Provided Methods§

source

fn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig)

Draws the grid for the plot based on the provided configuration.

§Parameters
  • canvas: The PixelCanvas to draw the grid on.
  • config: The FigureConfig containing grid appearance settings.
source

fn draw_axis( &self, canvas: &mut PixelCanvas, config: &FigureConfig, x1: i32, y1: i32, x2: i32, y2: i32, )

Draws an axis line on the canvas.

§Parameters
  • canvas: The PixelCanvas to draw the axis on.
  • config: The FigureConfig containing axis appearance settings.
  • x1, y1: The starting coordinates of the axis.
  • x2, y2: The ending coordinates of the axis.
source

fn draw_label( &self, canvas: &mut PixelCanvas, config: &FigureConfig, x: u32, y: u32, text: &str, )

Draws a text label on the canvas.

§Parameters
  • canvas: The PixelCanvas to draw the label on.
  • config: The FigureConfig containing label appearance settings.
  • x, y: The position to draw the label, centered on (x, y).
  • text: The label text.
source

fn draw_title( &self, canvas: &mut PixelCanvas, config: &FigureConfig, x: u32, y: u32, text: &str, )

Draws the plot title on the canvas.

§Parameters
  • canvas: The PixelCanvas to draw the title on.
  • config: The FigureConfig containing title appearance settings.
  • x, y: The position to draw the title, centered on (x, y).
  • text: The title text.
source

fn draw_axis_value( &self, canvas: &mut PixelCanvas, config: &FigureConfig, x: u32, y: u32, text: &str, axis: AxisType, )

Draws a value on the axis (tick label) based on its type.

§Parameters
  • canvas: The PixelCanvas to draw the axis value on.
  • config: The FigureConfig containing axis value appearance settings.
  • x, y: The position to draw the value.
  • text: The text of the axis value.
  • axis: The type of axis (AxisType::AxisX or AxisType::AxisY).

Implementors§