dataviz::figure::figuretypes::quadrant1graph

Struct Quadrant1Graph

source
pub struct Quadrant1Graph {
    pub datasets: Vec<CartesianDataset>,
    pub title: String,
    pub x_label: String,
    pub y_label: String,
    pub config: FigureConfig,
}
Expand description

Represents a graph limited to the first quadrant (x >= 0, y >= 0), including datasets and configuration settings.

Fields§

§datasets: Vec<CartesianDataset>

A collection of datasets to be visualized in the graph.

§title: String

Title of the graph.

§x_label: String

Label for the X-axis.

§y_label: String

Label for the Y-axis.

§config: FigureConfig

Configuration settings for rendering the graph (e.g., colors, fonts, grid).

Implementations§

source§

impl Quadrant1Graph

source

pub fn new( title: &str, x_label: &str, y_label: &str, config: FigureConfig, ) -> Self

Creates a new Quadrant1Graph instance with the specified title, labels, and configuration.

§Parameters
  • title: The title of the graph.
  • x_label: The label for the X-axis.
  • y_label: The label for the Y-axis.
  • config: The FigureConfig containing appearance and behavior settings.
§Returns

A new Quadrant1Graph instance with an empty dataset.

§Example
use crate::figure::configuration::figureconfig::FigureConfig;
use crate::figure::quadrant1graph::Quadrant1Graph;

let config = FigureConfig::default();
let graph = Quadrant1Graph::new("First Quadrant Graph", "X Axis", "Y Axis", config);
source

pub fn add_dataset(&mut self, dataset: CartesianDataset)

Adds a dataset to the graph after filtering out points not in the first quadrant.

§Parameters
  • dataset: The CartesianDataset to be added to the graph.
§Details

This method ensures that only points with x >= 0.0 and y >= 0.0 are included in the dataset.

§Example
use crate::figure::datasets::cartesiangraphdataset::CartesianDataset;
use crate::figure::utilities::linetype::LineType;

let mut graph = Quadrant1Graph::new("Example Graph", "X Axis", "Y Axis", config);
let dataset = CartesianDataset {
    points: vec![(1.0, 2.0), (-1.0, 3.0), (4.0, -2.0)],
    color: [255, 0, 0],
    label: "Dataset 1".to_string(),
    line_type: LineType::Solid,
};
graph.add_dataset(dataset);

Trait Implementations§

source§

impl Drawer for Quadrant1Graph

source§

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

Draws the plot content on an SvgCanvas. Read more
source§

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

Draws the main content of the plot on a PixelCanvas. Read more
source§

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

Draws the legend for the plot on a PixelCanvas. Read more
source§

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

Draws the grid for the plot based on the provided configuration. Read more
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. Read more
source§

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

Draws a text label on the canvas. Read more
source§

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

Draws the plot title on the canvas. Read more
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. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V