Skip to main content

Chart

Struct Chart 

Source
pub struct Chart {
Show 15 fields pub chart_type: ChartType, pub series: Vec<Series>, pub axes: Vec<Axis>, pub title: Option<ChartTitle>, pub subtitle: Option<ChartTitle>, pub legend: Option<LegendConfig>, pub background_color: Color, pub bar_config: BarConfig, pub padding: f32, pub text_annotations: Vec<TextAnnotation>, pub line_annotations: Vec<LineAnnotation>, pub fill_regions: Vec<FillRegion>, pub interactive: InteractiveState, pub show_crosshair: bool, pub show_tooltips: bool,
}
Expand description

Complete chart data.

Fields§

§chart_type: ChartType

Chart type

§series: Vec<Series>

Data series

§axes: Vec<Axis>

All axes (indexed by AxisId)

§title: Option<ChartTitle>

Main title

§subtitle: Option<ChartTitle>

Subtitle

§legend: Option<LegendConfig>

Legend configuration

§background_color: Color

Background color

§bar_config: BarConfig

Bar configuration (if bar chart)

§padding: f32

Padding around the chart area

§text_annotations: Vec<TextAnnotation>

Text annotations

§line_annotations: Vec<LineAnnotation>

Line annotations

§fill_regions: Vec<FillRegion>

Fill regions

§interactive: InteractiveState

Interactive state

§show_crosshair: bool

Whether to show crosshair on hover

§show_tooltips: bool

Whether to show tooltips on hover

Implementations§

Source§

impl Chart

Source

pub fn append_data(&mut self, series_idx: usize, points: &[DataPoint])

Append data points to a series efficiently.

This is more efficient than replacing all data when you’re only adding new points, as it allows caches to perform partial updates.

§Example
// Add new sensor readings
chart.append_data(0, &[DataPoint::new(10.0, 25.5), DataPoint::new(11.0, 26.0)]);
Source

pub fn push_point( &mut self, series_idx: usize, point: DataPoint, max_points: Option<usize>, )

Push a single data point to a series with an optional sliding window.

If max_points is Some, the oldest points will be removed to keep the series at or below the specified size. This is useful for real-time charts that show a fixed time window.

§Example
// Keep only the last 1000 points
chart.push_point(0, DataPoint::new(timestamp, value), Some(1000));
Source

pub fn set_data(&mut self, series_idx: usize, data: Vec<DataPoint>)

Replace all data in a series.

Use this when you need to completely replace the data, not just append.

§Example
chart.set_data(0, new_data_points);
Source

pub fn clear_data(&mut self, series_idx: usize)

Clear all data from a series.

Source

pub fn series_mut(&mut self, series_idx: usize) -> Option<&mut Series>

Get mutable access to a series for direct manipulation.

Source

pub fn series_len(&self, series_idx: usize) -> usize

Get the number of data points in a series.

Source

pub fn total_points(&self) -> usize

Get the total number of data points across all series.

Source

pub fn get_axis(&self, id: AxisId) -> Option<&Axis>

Get an axis by ID.

Source

pub fn get_axis_mut(&mut self, id: AxisId) -> Option<&mut Axis>

Get a mutable axis by ID.

Source

pub fn set_axis(&mut self, axis: Axis)

Add or replace an axis.

Source

pub fn x_axis(&self) -> Option<&Axis>

Get the X axis (primary).

Source

pub fn y_axis(&self) -> Option<&Axis>

Get the Y axis (primary).

Source

pub fn data_bounds_for_axis(&self, axis_id: AxisId) -> Option<(f64, f64)>

Get the combined bounds of all series for a specific axis.

Source

pub fn data_bounds(&self) -> Option<(DataPoint, DataPoint)>

Get the combined bounds of all series.

Source

pub fn axis_range(&self, axis_id: AxisId) -> (f64, f64)

Get the effective range for an axis.

Source

pub fn x_range(&self) -> (f64, f64)

Get the effective X range (respecting axis min/max overrides).

Source

pub fn y_range(&self) -> (f64, f64)

Get the effective Y range (respecting axis min/max overrides).

Trait Implementations§

Source§

impl Clone for Chart

Source§

fn clone(&self) -> Chart

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Chart

Source§

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

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

impl Default for Chart

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Chart> for StreamingChart

Source§

fn from(chart: Chart) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Chart

§

impl RefUnwindSafe for Chart

§

impl Send for Chart

§

impl Sync for Chart

§

impl Unpin for Chart

§

impl UnsafeUnpin for Chart

§

impl UnwindSafe for Chart

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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,