Skip to main content

Series

Struct Series 

Source
pub struct Series<'a> { /* private fields */ }
Expand description

One named data series. Build it with Series::line, Series::scatter, Series::bars, Series::area, Series::step, Series::function, Series::hline, or Series::vline, then add it to a super::Plot.

Data is borrowed when possible (&[[f64; 2]]), so a million-point buffer is not copied every frame. Non-finite points break a line into segments.

Implementations§

Source§

impl Series<'static>

Source

pub fn from_dataset(data: &Dataset, x: &str, y: &str) -> Option<Self>

A line from two numeric columns of a crisol_core::data::Dataset.

let data = Dataset::from_columns([
    Column::floats("t", vec![0.0, 1.0]),
    Column::floats("v", vec![1.0, 2.0]),
]);
let series = Series::from_dataset(&data, "t", "v").expect("columns");
Source§

impl<'a> Series<'a>

Source

pub fn lod( name: impl Into<String>, pyramid: Arc<MinMaxPyramid>, budget: usize, ) -> Series<'static>

A line backed by a MinMaxPyramid.

The visible x range is fetched as tiles and decimated to budget tiles; changing the zoom fetches a different level. This is the streaming path for recordings with 10⁸–10⁹ points.

Source

pub fn line( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

A 1.5 pt polyline through the points, in order.

Source

pub fn spline( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

A line drawn as a smooth spline through the points (see Series::smooth).

Source

pub fn area( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

A line filled down to y = 0 with 18 % of its color.

Source

pub fn step( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

A staircase line: each value holds until the next x.

Source

pub fn scatter( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

Unconnected markers (3 pt radius circles by default).

Source

pub fn bars( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self

Vertical bars from y = 0 to each point; the width defaults to 80 % of the smallest x spacing.

Source

pub fn function( name: impl Into<String>, x_range: RangeInclusive<f64>, samples: usize, f: impl Fn(f64) -> f64, ) -> Series<'static>

f(x) sampled samples times over x_range.

Source

pub fn hline(name: impl Into<String>, y: f64) -> Series<'static>

A horizontal reference line across the whole plot.

Source

pub fn vline(name: impl Into<String>, x: f64) -> Series<'static>

A vertical reference line across the whole plot.

Source

pub fn color(self, color: Color32) -> Self

Explicit color; the theme palette is used in order otherwise.

Source

pub fn width(self, new_width: f32) -> Self

Line width in points (lines, steps, areas, reference lines).

Source

pub fn style(self, new_style: LineStyle) -> Self

Dashed or dotted lines.

Source

pub fn fill_to(self, base: f64) -> Self

Fill between the line and y = base.

Source

pub fn smooth(self, new_smoothing: Smoothing) -> Self

Smooth the line through its points (lines and areas; steps stay square). Dense lines (more than one point per 2 pt) are drawn straight: a spline would not change what you see.

Source

pub fn y_axis(self, axis: YAxis) -> Self

Measure the series against the left (default) or the right y axis.

Source

pub fn marker(self, new_marker: Marker) -> Self

Draw a marker on every vertex of a line, or change the scatter marker.

Source

pub fn radius(self, new_radius: f32) -> Self

Marker radius in points (scatter).

Source

pub fn bar_width(self, new_width: f64) -> Self

Bar width in data units (bars, candles, and waterfall bars).

Source

pub fn base(self, new_base: f64) -> Self

Where bars start (default 0).

Source

pub fn y_errors(self, errors: impl Into<Cow<'a, [f64]>>) -> Self

Symmetric ±error per point, drawn as whiskers.

Source

pub fn hide_from_legend(self) -> Self

Leave the series out of the legend.

Source

pub fn name(&self) -> &str

The series name (also the legend label).

Source

pub fn data(&self) -> &[[f64; 2]]

The points.

Source§

impl<'a> Series<'a>

Source

pub fn pie(name: impl Into<String>, value: f64) -> Series<'static>

One slice of a pie or donut chart. Add one series per slice; the values are normalized to the visible slices.

let mut config = crisol_plot::plot::PlotConfig::default();
config.pie.inner_radius = 0.55;
Plot::new("share")
    .config(config)
    .series(Series::pie("Desktop", 62.0))
    .series(Series::pie("Mobile", 38.0))
    .show(ui, &mut icons, &mut state);
Source

pub fn candles( name: impl Into<String>, rows: impl Into<Cow<'a, [[f64; 5]]>>, ) -> Series<'a>

Open–high–low–close candles: [x, open, high, low, close] rows.

Source

pub fn heatmap( name: impl Into<String>, cells: impl Into<Cow<'a, [[f64; 3]]>>, ) -> Series<'a>

A heatmap from [x, y, value] cells. Cell size follows the smallest gap on each axis; the color scale spans the visible values.

Source

pub fn radar( name: impl Into<String>, values: impl AsRef<[f64]>, ) -> Series<'static>

A radar polygon over the axes named in RadarConfig::labels. Values are indexed in order around the ring; zero is the center.

Source

pub fn gauge( name: impl Into<String>, value: f64, range: RangeInclusive<f64>, ) -> Series<'static>

One gauge with its own range.

Source

pub fn waterfall( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Series<'a>

A waterfall: each [x, change] bar starts where the previous one ended.

Trait Implementations§

Source§

impl<'a> Clone for Series<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Series<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Series<'a>

§

impl<'a> !Send for Series<'a>

§

impl<'a> !Sync for Series<'a>

§

impl<'a> !UnwindSafe for Series<'a>

§

impl<'a> Forget for Series<'a>

§

impl<'a> Freeze for Series<'a>
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, &'a [[f64; 2]]: Freeze, Vec<[f64; 2]>: Freeze, &'a [f64]: Freeze, Vec<f64>: Freeze, &'a [[f64; 5]]: Freeze, Vec<[f64; 5]>: Freeze, &'a [[f64; 3]]: Freeze, Vec<[f64; 3]>: Freeze, *const ArcInner<MinMaxPyramid> is !null: Freeze, PhantomData<ArcInner<MinMaxPyramid>>: Freeze,

§

impl<'a> Move for Series<'a>

§

impl<'a> Unpin for Series<'a>
where *const u8 is !null: Unpin, &'a [[f64; 2]]: Unpin, Vec<[f64; 2]>: Unpin, &'a [f64]: Unpin, Vec<f64>: Unpin, &'a [[f64; 5]]: Unpin, Vec<[f64; 5]>: Unpin, &'a [[f64; 3]]: Unpin, Vec<[f64; 3]>: Unpin, Arc<MinMaxPyramid>: Unpin,

§

impl<'a> UnsafeUnpin for Series<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.