pub struct AreaChart {
pub title: String,
pub x_label: String,
pub y_label: String,
pub datasets: Vec<AreaChartDataset>,
pub config: FigureConfig,
}
Expand description
Represents an area chart, including its title, axis labels, datasets, and configuration.
Fields§
§title: String
Title of the area chart.
x_label: String
Label for the X-axis.
y_label: String
Label for the Y-axis.
datasets: Vec<AreaChartDataset>
A collection of datasets to be visualized in the area chart.
config: FigureConfig
Configuration settings for rendering the chart (e.g., colors, fonts, grid).
Implementations§
source§impl AreaChart
impl AreaChart
sourcepub fn new(
title: &str,
x_label: &str,
y_label: &str,
config: FigureConfig,
) -> Self
pub fn new( title: &str, x_label: &str, y_label: &str, config: FigureConfig, ) -> Self
Creates a new AreaChart
instance with the specified title, axis labels, and configuration.
§Parameters
title
: The title of the area chart.x_label
: The label for the X-axis.y_label
: The label for the Y-axis.config
: TheFigureConfig
containing appearance and behavior settings for the chart.
§Returns
A new AreaChart
instance with an empty dataset.
§Example
use crate::figure::configuration::figureconfig::FigureConfig;
use crate::figure::areachart::AreaChart;
let config = FigureConfig::default();
let area_chart = AreaChart::new("Example Chart", "X Axis", "Y Axis", config);
sourcepub fn add_dataset(&mut self, dataset: AreaChartDataset)
pub fn add_dataset(&mut self, dataset: AreaChartDataset)
sourcepub fn draw_area(
&self,
canvas: &mut PixelCanvas,
dataset: &AreaChartDataset,
origin_x: i32,
origin_y: i32,
scale_x: f64,
scale_y: f64,
)
pub fn draw_area( &self, canvas: &mut PixelCanvas, dataset: &AreaChartDataset, origin_x: i32, origin_y: i32, scale_x: f64, scale_y: f64, )
Draws the area under a dataset on the canvas.
This method fills the area under the dataset line, interpolating between points and blending the pixels into the canvas.
§Parameters
canvas
: ThePixelCanvas
on which to draw the area.dataset
: TheAreaChartDataset
whose area is to be drawn.origin_x
: The x-coordinate of the chart’s origin on the canvas.origin_y
: The y-coordinate of the chart’s origin on the canvas.scale_x
: The scaling factor for converting X-axis values to canvas coordinates.scale_y
: The scaling factor for converting Y-axis values to canvas coordinates.
§Details
The method interpolates between adjacent points in the dataset to fill the area under the line segment and blend it into the canvas using the dataset’s color and transparency.
§Example
let scale_x = 10.0;
let scale_y = 10.0;
area_chart.draw_area(&mut canvas, &dataset, 50, 400, scale_x, scale_y);
Trait Implementations§
source§impl Drawer for AreaChart
impl Drawer for AreaChart
source§fn draw_svg(&mut self, svg_canvas: &mut SvgCanvas)
fn draw_svg(&mut self, svg_canvas: &mut SvgCanvas)
SvgCanvas
. Read moresource§fn draw(&mut self, canvas: &mut PixelCanvas)
fn draw(&mut self, canvas: &mut PixelCanvas)
PixelCanvas
. Read moresource§fn draw_legend(&self, canvas: &mut PixelCanvas)
fn draw_legend(&self, canvas: &mut PixelCanvas)
PixelCanvas
. Read moresource§fn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig)
fn draw_grid(&self, canvas: &mut PixelCanvas, config: &FigureConfig)
source§fn 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, )
source§fn 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, )
source§fn 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, )
source§fn 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, )
Auto Trait Implementations§
impl Freeze for AreaChart
impl RefUnwindSafe for AreaChart
impl Send for AreaChart
impl Sync for AreaChart
impl Unpin for AreaChart
impl UnwindSafe for AreaChart
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.