pub struct GroupBarChart {
pub datasets: Vec<BarDataset>,
pub title: String,
pub x_label: String,
pub y_label: String,
pub orientation: Orientation,
pub config: FigureConfig,
}
Expand description
A grouped bar chart representation, supporting horizontal and vertical orientations.
Fields§
§datasets: Vec<BarDataset>
A collection of datasets to be visualized in the grouped bar chart.
title: String
Title of the bar chart.
x_label: String
Label for the X-axis.
y_label: String
Label for the Y-axis.
orientation: Orientation
Orientation of the bar chart (Horizontal
or Vertical
).
config: FigureConfig
Configuration settings for rendering the chart (e.g., colors, fonts, grid).
Implementations§
source§impl GroupBarChart
impl GroupBarChart
sourcepub fn new(
title: &str,
x_label: &str,
y_label: &str,
orientation: Orientation,
config: FigureConfig,
) -> Self
pub fn new( title: &str, x_label: &str, y_label: &str, orientation: Orientation, config: FigureConfig, ) -> Self
Creates a new GroupBarChart
instance with the specified title, labels, orientation, and configuration.
§Parameters
title
: The title of the bar chart.x_label
: The label for the X-axis.y_label
: The label for the Y-axis.orientation
: The orientation of the bar chart (Horizontal
orVertical
).config
: TheFigureConfig
containing appearance and behavior settings for the chart.
§Returns
A new GroupBarChart
instance with an empty dataset.
§Example
use crate::figure::configuration::figureconfig::FigureConfig;
use crate::figure::groupbarchart::GroupBarChart;
use crate::figure::utilities::orientation::Orientation;
let config = FigureConfig::default();
let bar_chart = GroupBarChart::new("Sales Chart", "Year", "Revenue", Orientation::Vertical, config);
sourcepub fn add_dataset(&mut self, dataset: BarDataset)
pub fn add_dataset(&mut self, dataset: BarDataset)
sourcepub fn draw_horizontal(&self, canvas: &mut PixelCanvas)
pub fn draw_horizontal(&self, canvas: &mut PixelCanvas)
Draws a horizontal grouped bar chart.
§Parameters
canvas
: ThePixelCanvas
to render the bar chart on.
§Details
This method draws a horizontally oriented bar chart with grouped bars.
It uses the FigureConfig
settings for appearance and adjusts the canvas accordingly.
§Example
bar_chart.draw_horizontal(&mut canvas);
sourcepub fn draw_vertical(&self, canvas: &mut PixelCanvas)
pub fn draw_vertical(&self, canvas: &mut PixelCanvas)
Draws a vertical grouped bar chart.
§Parameters
canvas
: ThePixelCanvas
to render the bar chart on.
§Details
This method draws a vertically oriented bar chart with grouped bars.
It uses the FigureConfig
settings for appearance and adjusts the canvas accordingly.
§Example
bar_chart.draw_vertical(&mut canvas);
Trait Implementations§
source§impl Drawer for GroupBarChart
impl Drawer for GroupBarChart
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, )
source§impl Hover for GroupBarChart
impl Hover for GroupBarChart
source§fn handle_hover(
&self,
mouse_x: u32,
mouse_y: u32,
canvas: &PixelCanvas,
) -> Option<Vec<u32>>
fn handle_hover( &self, mouse_x: u32, mouse_y: u32, canvas: &PixelCanvas, ) -> Option<Vec<u32>>
source§fn find_closest_point(
&self,
mouse_x: u32,
mouse_y: u32,
canvas: &PixelCanvas,
) -> Option<((f64, f64), f64)>
fn find_closest_point( &self, mouse_x: u32, mouse_y: u32, canvas: &PixelCanvas, ) -> Option<((f64, f64), f64)>
source§fn to_canvas_coordinates(
&self,
x: f64,
y: f64,
canvas: &PixelCanvas,
) -> (u32, u32)
fn to_canvas_coordinates( &self, x: f64, y: f64, canvas: &PixelCanvas, ) -> (u32, u32)
Auto Trait Implementations§
impl Freeze for GroupBarChart
impl RefUnwindSafe for GroupBarChart
impl Send for GroupBarChart
impl Sync for GroupBarChart
impl Unpin for GroupBarChart
impl UnwindSafe for GroupBarChart
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.