Skip to main content

Chart

Struct Chart 

Source
pub struct Chart {
    pub kind: Kind,
    pub title: Option<String>,
    pub labels: Vec<String>,
    pub series: Vec<Series>,
    pub palette: Palette,
    pub legend: Legend,
    pub x: Axis,
    pub y: Axis,
    pub right: Option<Axis>,
    pub aspect_ratio: Option<f64>,
    /* private fields */
}
Expand description

A chart, as a builder.

Fields§

§kind: Kind§title: Option<String>§labels: Vec<String>§series: Vec<Series>§palette: Palette§legend: Legend§x: Axis§y: Axis§right: Option<Axis>

A second value axis on the right, for a series in another unit.

§aspect_ratio: Option<f64>

Let the canvas take the height its container gives it.

Implementations§

Source§

impl Chart

Source

pub fn new(kind: Kind) -> Chart

Source

pub fn line(title: impl Into<String>) -> Chart

Source

pub fn bar(title: impl Into<String>) -> Chart

Source

pub fn horizontal_bar(title: impl Into<String>) -> Chart

Source

pub fn doughnut(title: impl Into<String>) -> Chart

Source

pub fn pie(title: impl Into<String>) -> Chart

Source

pub fn scatter( title: impl Into<String>, label: impl Into<String>, points: impl IntoIterator<Item = (f64, f64)>, ) -> Chart

Points in two dimensions, which have no category labels at all.

Source

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

Source

pub fn untitled(self) -> Chart

Drop the title from the chart itself — for a card whose heading already says it, so a screen reader does not read it twice.

Source

pub fn labels( self, labels: impl IntoIterator<Item = impl Into<String>>, ) -> Chart

Source

pub fn series(self, series: Series) -> Chart

Source

pub fn values( self, label: impl Into<String>, values: impl IntoIterator<Item = f64>, ) -> Chart

A single unnamed run — the common case for a doughnut or a sparkline.

Source

pub fn palette(self, palette: Palette) -> Chart

Source

pub fn legend(self, legend: Legend) -> Chart

Source

pub fn x(self, axis: Axis) -> Chart

Source

pub fn y(self, axis: Axis) -> Chart

Source

pub fn right(self, axis: Axis) -> Chart

A second value axis on the right, for Series::right_axis.

Source

pub fn stacked(self) -> Chart

Stack every series, on both axes that can be stacked.

Source

pub fn aspect_ratio(self, ratio: f64) -> Chart

Source

pub fn problems(&self) -> Vec<String>

Every series is as long as the labels, and there is something to draw.

Not enforced — a chart is not worth refusing to render a page over — but a dashboard can call it in a test, and the first line of a mismatched chart is a silently truncated one.

Source

pub fn to_json(&self) -> Json

The configuration object, ready for a data-chart attribute.

Trait Implementations§

Source§

impl Clone for Chart

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 Chart

Source§

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

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

impl From<Chart> for Json

Source§

fn from(chart: Chart) -> Json

Converts to this type from the input type.
Source§

impl PartialEq for Chart

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 StructuralPartialEq for Chart

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