Skip to main content

PlotSpec

Struct PlotSpec 

Source
pub struct PlotSpec {
Show 14 fields pub version: u32, pub title: Option<String>, pub x_label: Option<String>, pub y_label: Option<String>, pub width: u32, pub height: u32, pub x_scale: Scale, pub y_scale: Scale, pub x_range: Option<[f64; 2]>, pub y_range: Option<[f64; 2]>, pub series: Vec<SeriesSpec>, pub legend: bool, pub grid: bool, pub theme: Option<PlotTheme>,
}
Expand description

A complete chart as data.

use crisol_plot_core::spec::{PlotSpec, SeriesKind, SeriesSpec};

let spec = PlotSpec::new(640, 360)
    .title("Signal")
    .series(SeriesSpec::line("v", vec![[0.0, 1.0], [1.0, 2.0]]));
assert_eq!(spec.series[0].kind, SeriesKind::Line);

Fields§

§version: u32

The schema version; PLOT_SPEC_VERSION for new charts.

§title: Option<String>

Chart title.

§x_label: Option<String>

Horizontal axis title.

§y_label: Option<String>

Left vertical axis title.

§width: u32

Image width in pixels.

§height: u32

Image height in pixels.

§x_scale: Scale

Horizontal scale.

§y_scale: Scale

Left vertical scale.

§x_range: Option<[f64; 2]>

Fixed x range in data units; automatic when None.

§y_range: Option<[f64; 2]>

Fixed y range in data units; automatic when None.

§series: Vec<SeriesSpec>

The series, drawn in order.

§legend: bool

Draw the legend.

§grid: bool

Draw major grid lines.

§theme: Option<PlotTheme>

Canvas and text colors; the renderer defaults when None.

Implementations§

Source§

impl PlotSpec

Source

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

An empty specification at width × height.

Source

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

Set the title.

Source

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

Set the horizontal axis title.

Source

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

Set the left vertical axis title.

Source

pub fn scale(self, x: Scale, y: Scale) -> Self

Set both scales.

Source

pub fn range(self, x: [f64; 2], y: [f64; 2]) -> Self

Set both fixed ranges.

Source

pub fn series(self, series: SeriesSpec) -> Self

Append a series.

Source

pub fn preset(self, preset: PagePreset, dpi: u32) -> Self

Set the size from a publication preset at dpi.

Source

pub fn theme(self, theme: PlotTheme) -> Self

Set the theme.

Source

pub fn validate(&self) -> Result<(), SpecError>

Validate the structural rules that serialization cannot express.

§Errors

When the size is zero, the version is newer than this crate, a range is reversed, or a series has no finite points.

Trait Implementations§

Source§

impl Clone for PlotSpec

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 Debug for PlotSpec

Source§

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

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

impl Default for PlotSpec

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for PlotSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PlotSpec

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PlotSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PlotSpec

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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