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
: ThePixelCanvas
to 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
: ThePixelCanvas
to 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
: ThePixelCanvas
to draw the grid on.config
: TheFigureConfig
containing 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
: ThePixelCanvas
to draw the axis on.config
: TheFigureConfig
containing 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
: ThePixelCanvas
to draw the label on.config
: TheFigureConfig
containing 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
: ThePixelCanvas
to draw the title on.config
: TheFigureConfig
containing 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
: ThePixelCanvas
to draw the axis value on.config
: TheFigureConfig
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
orAxisType::AxisY
).