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§
sourcefn draw(&mut self, canvas: &mut PixelCanvas)
fn draw(&mut self, canvas: &mut PixelCanvas)
Draws the main content of the plot on a PixelCanvas.
§Parameters
canvas: ThePixelCanvasto draw the plot on.
sourcefn draw_legend(&self, canvas: &mut PixelCanvas)
fn draw_legend(&self, canvas: &mut PixelCanvas)
Draws the legend for the plot on a PixelCanvas.
§Parameters
canvas: ThePixelCanvasto draw the legend on.
Provided Methods§
sourcefn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig)
fn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig)
Draws the grid for the plot based on the provided configuration.
§Parameters
canvas: ThePixelCanvasto draw the grid on.config: TheFigureConfigcontaining grid appearance settings.
sourcefn draw_axis(
&self,
canvas: &mut PixelCanvas,
config: &FigureConfig,
x1: i32,
y1: i32,
x2: i32,
y2: i32,
)
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: ThePixelCanvasto draw the axis on.config: TheFigureConfigcontaining axis appearance settings.x1,y1: The starting coordinates of the axis.x2,y2: The ending coordinates of the axis.
sourcefn draw_label(
&self,
canvas: &mut PixelCanvas,
config: &FigureConfig,
x: u32,
y: u32,
text: &str,
)
fn draw_label( &self, canvas: &mut PixelCanvas, config: &FigureConfig, x: u32, y: u32, text: &str, )
Draws a text label on the canvas.
§Parameters
canvas: ThePixelCanvasto draw the label on.config: TheFigureConfigcontaining label appearance settings.x,y: The position to draw the label, centered on(x, y).text: The label text.
sourcefn draw_title(
&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, )
Draws the plot title on the canvas.
§Parameters
canvas: ThePixelCanvasto draw the title on.config: TheFigureConfigcontaining title appearance settings.x,y: The position to draw the title, centered on(x, y).text: The title text.
sourcefn draw_axis_value(
&self,
canvas: &mut PixelCanvas,
config: &FigureConfig,
x: u32,
y: u32,
text: &str,
axis: AxisType,
)
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: ThePixelCanvasto draw the axis value on.config: TheFigureConfigcontaining 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::AxisXorAxisType::AxisY).