PlotBuilder

Struct PlotBuilder 

Source
pub struct PlotBuilder<T: Plottable + Graph> { /* private fields */ }
Expand description

A builder for creating and configuring data visualizations.

PlotBuilder provides a fluent interface for customizing plots with various styling and labeling options. It works with any type that implements the Plottable trait, allowing for consistent visualization capabilities across different data structures.

This builder is typically created via the plot() method on types that implement the Plottable trait. After configuring the plot with the desired options, it can be rendered and saved using the methods from PlotBuilderExt.

Implementations§

Source§

impl<T: Plottable + Graph> PlotBuilder<T>

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the title of the plot.

This method configures the main title that appears at the top of the visualization.

§Parameters
  • title - The text to display as the plot title
§Returns

The PlotBuilder instance with the updated title setting

Source

pub fn x_label(self, label: impl Into<String>) -> Self

Sets the label for the x-axis.

This method configures the descriptive text displayed along the horizontal axis.

§Parameters
  • label - The text to display as the x-axis label
§Returns

The PlotBuilder instance with the updated x-axis label

Source

pub fn y_label(self, label: impl Into<String>) -> Self

Sets the label for the y-axis.

This method configures the descriptive text displayed along the vertical axis.

§Parameters
  • label - The text to display as the y-axis label
§Returns

The PlotBuilder instance with the updated y-axis label

Source

pub fn z_label(self, label: impl Into<String>) -> Self

Sets the label for the z-axis.

This method configures the descriptive text displayed along the z-axis in three-dimensional plots.

§Parameters
  • label - The text to display as the z-axis label
§Returns

The PlotBuilder instance with the updated z-axis label

Source

pub fn line_style(self, line_style: LineStyle) -> Self

Sets the colors for data series lines.

This method configures the colors used to render each data series or curve in the visualization.

§Parameters
  • colors - A vector of RGB colors to use for the plot lines
§Returns

The PlotBuilder instance with the updated line colors

Source

pub fn legend(self, legend: Vec<impl Into<String>>) -> Self

Sets the legend for the current instance.

This method accepts a vector of items that can be converted into strings and sets the legend field of the current instance’s options. It returns the modified instance for further chaining.

§Arguments
  • legend - A Vec containing items that implement the Into<String> trait. Each element will be converted into a String and assigned to the legend.
§Returns

Returns the modified instance with the legend updated.

In this example, the legend is updated to include “Item 1”, “Item 2”, and “Item 3”.

Source

pub fn add_legend(self, legend: impl Into<String>) -> Self

Adds a legend entry to the existing legend configuration or initializes a new legend with the provided entry if none exists.

This method allows chaining, modifying the legend configuration within the options of the current object. If a legend already exists, the provided legend entry will be appended to it. If no legend exists, a new legend will be created containing the provided entry.

§Arguments
  • legend - An item implementing Into<String> that represents the legend entry to add.
§Returns

Returns Self (the modified object) to allow method chaining.

In this example, two legend entries, "Legend 1" and "Legend 2", are added to the chart’s legend configuration.

Source

pub fn dimensions(self, width: u32, height: u32) -> Self

Sets the overall dimensions of the plot.

This method configures the width and height of the generated plot image.

§Parameters
  • width - The width of the plot in pixels
  • height - The height of the plot in pixels
§Returns

The PlotBuilder instance with the updated dimensions

Source

pub fn color_scheme(self, color_scheme: ColorScheme) -> Self

Sets the color scheme for the current instance.

This method allows you to specify a ColorScheme to customize the appearance or theme of the associated object. The method updates the color_scheme field in the options struct with the provided value and returns an updated instance of self.

§Parameters
  • color_scheme: The desired ColorScheme to be applied. This defines the visual style or theme to be used by the object.
§Returns

An updated instance of Self with the new color scheme applied.

Source

pub fn show_legend(self, show_legend: bool) -> Self

Sets the visibility of the legend in the chart or visualization.

§Parameters
  • show_legend: A boolean specifying whether the legend should be displayed.
    • true: The legend will be displayed.
    • false: The legend will be hidden.
§Returns
  • Returns an updated instance of Self with the show_legend option set according to the provided parameter.

Trait Implementations§

Source§

impl<T: Plottable + Graph> Graph for PlotBuilder<T>

Source§

fn graph_data(&self) -> GraphData

Return the raw data ready for plotting.
Source§

fn graph_config(&self) -> GraphConfig

Optional per‑object configuration overrides.

Auto Trait Implementations§

§

impl<T> Freeze for PlotBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PlotBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for PlotBuilder<T>
where T: Send,

§

impl<T> Sync for PlotBuilder<T>
where T: Sync,

§

impl<T> Unpin for PlotBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for PlotBuilder<T>
where T: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more