Skip to main content

ChartLayout

Struct ChartLayout 

Source
pub struct ChartLayout {
    pub width: f64,
    pub height: f64,
    pub grids: Vec<GridLayout>,
    pub series: Vec<SeriesLayout>,
    pub geo: Vec<GeoLayout>,
    pub title_rect: Option<BBox>,
    pub legend_rect: Option<BBox>,
    pub plot_rect: BBox,
}
Expand description

The whole layout of a chart.

Fields§

§width: f64

The width of the chart, in canvas pixels.

§height: f64

The height of the chart, in canvas pixels.

§grids: Vec<GridLayout>

The grids of the chart.

§series: Vec<SeriesLayout>

The series of the chart.

§geo: Vec<GeoLayout>

The maps of the chart, projected into the plot area.

§title_rect: Option<BBox>

The rectangle the title occupies.

§legend_rect: Option<BBox>

The rectangle the legend occupies.

§plot_rect: BBox

The rectangle the chart’s plot area occupies.

Implementations§

Source§

impl ChartLayout

Inherent implementation of ChartLayout.

Source

pub fn compute( option: &ChartOption, width: f64, height: f64, measurer: &TextMeasurer, ) -> ChartLayout

Computes the layout of a chart.

The layout is the bridge between the option and the display list: it resolves the sizes, computes the scales and the ticks, and places every data point in pixel space. The renderer then only has to turn the result into drawing instructions.

measurer is used to size the axis labels; passing a measurer that has already measured the same labels costs nothing, because the measurements are cached.

§Arguments
  • &ChartOption - Shared reference to a ChartOption.
  • f64 - A 64-bit float (f64).
  • &TextMeasurer - Shared reference to a TextMeasurer.
§Returns
  • ChartLayout - A ChartLayout value.
Source

pub fn compute_with_maps( option: &ChartOption, width: f64, height: f64, measurer: &TextMeasurer, maps: &MapRegistry, ) -> ChartLayout

Computes the layout of a chart that draws maps.

The geometry of a map is far too large to live in an option: the same map is drawn by every chart of an application, and it is registered once. The registry is where the charts look it up.

§Arguments
  • &ChartOption - Shared reference to a ChartOption.
  • f64 - A 64-bit float (f64).
  • &TextMeasurer - Shared reference to a TextMeasurer.
  • &MapRegistry - Shared reference to a MapRegistry.
§Returns
  • ChartLayout - A ChartLayout value.
Source

pub fn geo(&self, name: &str) -> Option<&GeoLayout>

Returns the map with the given name.

A chart can hold more than one map: a geo component and a map series may draw different maps, and two map series may draw the same one twice.

§Arguments
  • &str - Shared reference to a str.
§Returns
  • Option<&GeoLayout> - Some(...) on success, None otherwise.
Source§

impl ChartLayout

Source

pub fn get_width(&self) -> f64

Source

pub fn get_mut_width(&mut self) -> &mut f64

Source

pub fn set_width(&mut self, val: f64) -> &mut Self

Source

pub fn get_height(&self) -> f64

Source

pub fn get_mut_height(&mut self) -> &mut f64

Source

pub fn set_height(&mut self, val: f64) -> &mut Self

Source

pub fn get_grids(&self) -> &Vec<GridLayout>

Source

pub fn get_mut_grids(&mut self) -> &mut Vec<GridLayout>

Source

pub fn set_grids(&mut self, val: Vec<GridLayout>) -> &mut Self

Source

pub fn get_series(&self) -> &Vec<SeriesLayout>

Source

pub fn get_mut_series(&mut self) -> &mut Vec<SeriesLayout>

Source

pub fn set_series(&mut self, val: Vec<SeriesLayout>) -> &mut Self

Source

pub fn get_geo(&self) -> &Vec<GeoLayout>

Source

pub fn get_mut_geo(&mut self) -> &mut Vec<GeoLayout>

Source

pub fn set_geo(&mut self, val: Vec<GeoLayout>) -> &mut Self

Source

pub fn get_title_rect(&self) -> Option<BBox>

Source

pub fn try_get_title_rect(&self) -> Option<BBox>

Source

pub fn get_mut_title_rect(&mut self) -> &mut Option<BBox>

Source

pub fn set_title_rect(&mut self, val: Option<BBox>) -> &mut Self

Source

pub fn get_legend_rect(&self) -> Option<BBox>

Source

pub fn try_get_legend_rect(&self) -> Option<BBox>

Source

pub fn get_mut_legend_rect(&mut self) -> &mut Option<BBox>

Source

pub fn set_legend_rect(&mut self, val: Option<BBox>) -> &mut Self

Source

pub fn get_plot_rect(&self) -> BBox

Source

pub fn get_mut_plot_rect(&mut self) -> &mut BBox

Source

pub fn set_plot_rect(&mut self, val: BBox) -> &mut Self

Trait Implementations§

Source§

impl Clone for ChartLayout

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 ChartLayout

Source§

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

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

impl Default for ChartLayout

Source§

fn default() -> Self

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

impl PartialEq for ChartLayout

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 ChartLayout

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more