Skip to main content

ChartBuilder

Struct ChartBuilder 

Source
pub struct ChartBuilder { /* private fields */ }
Expand description

Builder for creating charts.

Implementations§

Source§

impl ChartBuilder

Source

pub fn new() -> Self

Create a new chart builder.

Source

pub fn line() -> Self

Create a line chart builder.

Source

pub fn bar() -> Self

Create a bar chart builder.

Source

pub fn scatter() -> Self

Create a scatter plot builder.

Source

pub fn area() -> Self

Create an area chart builder.

Source

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

Set the chart title.

Source

pub fn title_config(self, title: ChartTitle) -> Self

Set the chart title with full configuration.

Source

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

Set the chart subtitle.

Source

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

Set the X axis label.

Source

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

Set the Y axis label.

Source

pub fn x_axis_config(self, axis: Axis) -> Self

Configure the primary X axis.

Source

pub fn y_axis_config(self, axis: Axis) -> Self

Configure the primary Y axis.

Source

pub fn secondary_y_axis(self, axis: Axis) -> Self

Add a secondary Y axis (right side).

Source

pub fn secondary_x_axis(self, axis: Axis) -> Self

Add a secondary X axis (top).

Source

pub fn add_axis(self, axis: Axis) -> Self

Add a custom axis.

Source

pub fn x_range(self, min: f64, max: f64) -> Self

Set the X axis range.

Source

pub fn y_range(self, min: f64, max: f64) -> Self

Set the Y axis range.

Source

pub fn secondary_y_range(self, min: f64, max: f64) -> Self

Set the secondary Y axis range.

Source

pub fn add_series<T: Into<DataPoint> + Copy>( self, name: impl Into<String>, data: &[T], ) -> Self

Add a data series.

Source

pub fn add_series_styled<T: Into<DataPoint> + Copy>( self, name: impl Into<String>, data: &[T], style: SeriesStyle, ) -> Self

Add a data series with custom style.

Source

pub fn add_series_secondary_y<T: Into<DataPoint> + Copy>( self, name: impl Into<String>, data: &[T], ) -> Self

Add a data series on the secondary Y axis.

Source

pub fn add_series_with_axes<T: Into<DataPoint> + Copy>( self, name: impl Into<String>, data: &[T], x_axis: AxisId, y_axis: AxisId, ) -> Self

Add a data series with custom axes.

Source

pub fn plot_function<F>( self, name: impl Into<String>, f: F, x_min: f64, x_max: f64, samples: usize, ) -> Self
where F: Fn(f64) -> f64,

Plot a mathematical function.

Source

pub fn add_text_annotation(self, annotation: TextAnnotation) -> Self

Add a text annotation.

Source

pub fn add_text_at(self, text: impl Into<String>, x: f64, y: f64) -> Self

Add a text at data coordinates.

Source

pub fn add_line_annotation(self, annotation: LineAnnotation) -> Self

Add a line annotation.

Source

pub fn add_horizontal_line(self, y: f64, color: Color) -> Self

Add a horizontal reference line.

Source

pub fn add_vertical_line(self, x: f64, color: Color) -> Self

Add a vertical reference line.

Source

pub fn add_fill_region(self, region: FillRegion) -> Self

Add a fill region.

Source

pub fn add_horizontal_band(self, y_min: f64, y_max: f64, color: Color) -> Self

Add a horizontal band fill.

Source

pub fn add_vertical_band(self, x_min: f64, x_max: f64, color: Color) -> Self

Add a vertical band fill.

Source

pub fn fill_below_series( self, series_index: usize, baseline: f64, color: Color, ) -> Self

Add fill below a series.

Source

pub fn fill_between_series( self, series1: usize, series2: usize, color: Color, ) -> Self

Add fill between two series.

Source

pub fn with_grid(self) -> Self

Enable grid lines.

Source

pub fn without_grid(self) -> Self

Disable grid lines.

Source

pub fn with_legend(self, position: LegendPosition) -> Self

Set legend position.

Source

pub fn without_legend(self) -> Self

Disable legend.

Source

pub fn background(self, color: Color) -> Self

Set background color.

Source

pub fn padding(self, padding: f32) -> Self

Set padding around the chart area.

Source

pub fn bar_config(self, config: BarConfig) -> Self

Set bar chart configuration.

Source

pub fn interactive(self, enabled: bool) -> Self

Enable interactivity (pan and zoom).

Source

pub fn with_crosshair(self) -> Self

Enable crosshair on hover.

Source

pub fn with_tooltips(self) -> Self

Enable tooltips on hover.

Source

pub fn without_tooltips(self) -> Self

Disable tooltips.

Source

pub fn zoom_limits(self, min: f32, max: f32) -> Self

Set zoom limits.

Source

pub fn build(self) -> Chart

Build the chart.

Source

pub fn x_axis<F>(self, f: F) -> Self

Configure the primary X axis using a closure.

§Example
chart.x_axis(|a| a
    .label("Time (s)")
    .range(0.0, 100.0)
    .grid(|g| g.major(|m| m.thickness(1.0)))
);
Source

pub fn y_axis<F>(self, f: F) -> Self

Configure the primary Y axis using a closure.

Source

pub fn add_custom_axis<F>(self, name: &str, f: F) -> Self

Add a custom axis using a closure.

§Example
chart.add_custom_axis("pressure", |a| a
    .orientation(AxisOrientation::Vertical)
    .position(AxisPosition::Right)
    .label("Pressure (kPa)")
    .range(0.0, 200.0)
);
Source

pub fn add_series_with<F>(self, name: impl Into<String>, f: F) -> Self

Add a series using a closure for configuration.

§Example
chart.add_series_with("Temperature", |s| s
    .data(&data)
    .color(Color::RED)
    .dashed(5.0, 3.0)
    .markers(|m| m.circle().size(4.0))
);
Source

pub fn streaming_series<F>( self, name: impl Into<String>, capacity: usize, f: F, ) -> Self

Create a streaming series with a ring buffer.

The series is created with an empty ring buffer of the specified capacity.

§Example
chart.streaming_series("Live Sensor", 10_000, |s| s
    .color(Color::BLUE)
    .fill_to_baseline(Color::rgba(0.0, 0.0, 1.0, 0.1))
);

Trait Implementations§

Source§

impl Debug for ChartBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChartBuilder

Source§

fn default() -> Self

Returns the “default value” for a 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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

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

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

Source§

impl<T> WasmNotSendSync for T

Source§

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