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>
impl Series<'static>
Sourcepub fn from_dataset(data: &Dataset, x: &str, y: &str) -> Option<Self>
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>
impl<'a> Series<'a>
Sourcepub fn line(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
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.
Sourcepub fn spline(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
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).
Sourcepub fn area(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
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.
Sourcepub fn step(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
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.
Sourcepub fn scatter(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
pub fn scatter( name: impl Into<String>, data: impl Into<Cow<'a, [[f64; 2]]>>, ) -> Self
Unconnected markers (3 pt radius circles by default).
Sourcepub fn bars(
name: impl Into<String>,
data: impl Into<Cow<'a, [[f64; 2]]>>,
) -> Self
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.
Sourcepub fn function(
name: impl Into<String>,
x_range: RangeInclusive<f64>,
samples: usize,
f: impl Fn(f64) -> f64,
) -> Series<'static>
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.
Sourcepub fn hline(name: impl Into<String>, y: f64) -> Series<'static>
pub fn hline(name: impl Into<String>, y: f64) -> Series<'static>
A horizontal reference line across the whole plot.
Sourcepub fn vline(name: impl Into<String>, x: f64) -> Series<'static>
pub fn vline(name: impl Into<String>, x: f64) -> Series<'static>
A vertical reference line across the whole plot.
Sourcepub fn color(self, color: Color32) -> Self
pub fn color(self, color: Color32) -> Self
Explicit color; the theme palette is used in order otherwise.
Sourcepub fn width(self, new_width: f32) -> Self
pub fn width(self, new_width: f32) -> Self
Line width in points (lines, steps, areas, reference lines).
Sourcepub fn smooth(self, new_smoothing: Smoothing) -> Self
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.
Sourcepub fn y_axis(self, axis: YAxis) -> Self
pub fn y_axis(self, axis: YAxis) -> Self
Measure the series against the left (default) or the right y axis.
Sourcepub fn marker(self, new_marker: Marker) -> Self
pub fn marker(self, new_marker: Marker) -> Self
Draw a marker on every vertex of a line, or change the scatter marker.
Sourcepub fn bar_width(self, new_width: f64) -> Self
pub fn bar_width(self, new_width: f64) -> Self
Bar width in data units (bars, candles, and waterfall bars).
Sourcepub fn y_errors(self, errors: impl Into<Cow<'a, [f64]>>) -> Self
pub fn y_errors(self, errors: impl Into<Cow<'a, [f64]>>) -> Self
Symmetric ±error per point, drawn as whiskers.
Sourcepub fn hide_from_legend(self) -> Self
pub fn hide_from_legend(self) -> Self
Leave the series out of the legend.
Source§impl<'a> Series<'a>
impl<'a> Series<'a>
Sourcepub fn pie(name: impl Into<String>, value: f64) -> Series<'static>
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);Sourcepub fn candles(
name: impl Into<String>,
rows: impl Into<Cow<'a, [[f64; 5]]>>,
) -> Series<'a>
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.
Sourcepub fn heatmap(
name: impl Into<String>,
cells: impl Into<Cow<'a, [[f64; 3]]>>,
) -> Series<'a>
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.
Sourcepub fn radar(
name: impl Into<String>,
values: impl AsRef<[f64]>,
) -> Series<'static>
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.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Forget for Series<'a>
impl<'a> Freeze for Series<'a>
impl<'a> Move for Series<'a>
impl<'a> RefUnwindSafe for Series<'a>where
Vec<[f64; 2]>: RefUnwindSafe,
Vec<f64>: RefUnwindSafe,
Vec<[f64; 5]>: RefUnwindSafe,
Vec<[f64; 3]>: RefUnwindSafe,
impl<'a> Send for Series<'a>
impl<'a> Sync for Series<'a>
impl<'a> Unpin for Series<'a>
impl<'a> UnsafeUnpin for Series<'a>where
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'a [[f64; 2]]: UnsafeUnpin,
Vec<[f64; 2]>: UnsafeUnpin,
&'a [f64]: UnsafeUnpin,
Vec<f64>: UnsafeUnpin,
&'a [[f64; 5]]: UnsafeUnpin,
Vec<[f64; 5]>: UnsafeUnpin,
&'a [[f64; 3]]: UnsafeUnpin,
Vec<[f64; 3]>: UnsafeUnpin,
impl<'a> UnwindSafe for Series<'a>where
RawVecInner: UnwindSafe,
&'a [[f64; 2]]: UnwindSafe,
Vec<[f64; 2]>: UnwindSafe,
&'a [f64]: UnwindSafe,
Vec<f64>: UnwindSafe,
&'a [[f64; 5]]: UnwindSafe,
Vec<[f64; 5]>: UnwindSafe,
&'a [[f64; 3]]: UnwindSafe,
Vec<[f64; 3]>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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