pub struct Chart { /* private fields */ }
Expand description
The chart representation.
§Anatomy of a Chart
A chart is a collection of different components, each of which is responsible for rendering a specific part of the chart. Below is a sample chart with a few components:
Sales Report
| # coffee
30| x x juice
| @ x @ @ milk
20| # @ x@ x@ #
| #x@ #x@ #x@ #x
10| #x@ #x@ #x@ #x@
| #x@ #x@ #x@ #x@
0+-----------------------------------------------------
Jan Feb Mar Apr
The chart above has the following components: an x axis, an y axis, a title on the top center, and a legend on the top right.
The creation of charts in Charming is done in a builder-like fashion. Once you get a hang of this pattern, you will find that it is very easy to compose a chart. For instance, the following code snippet shows how to create the chart above:
use charming::Chart;
use charming::component::{Axis, Legend, Title};
let chart = Chart::new()
.title(Title::new().text("Sales Report"))
.x_axis(Axis::new().data(vec!["Jan", "Feb", "Mar", "Apr"]))
.y_axis(Axis::new())
.legend(Legend::new().data(vec!["coffee", "juice", "milk"]));
§Components of a Chart
The following sections describe the components of a chart in detail.
§Title
Title
is the title of a chart, including main title and subtitle. A chart
can have multiple titles, which is useful when you want to show multiple sub-
charts in a single chart.
use charming::Chart;
use charming::component::Title;
let chart = Chart::new()
.title(Title::new().text("Sales Report"));
§Legend
[Legend
] is the legend of a chart, which is used to show the meaning of the
symbols and colors in the chart. A chart can have multiple legends.
use charming::Chart;
use charming::component::Legend;
let chart = Chart::new()
.legend(Legend::new().data(vec!["coffee", "juice", "milk"]));
§Grid
Grid
is the background grid in a cartesian coordinate system. A chart can
have multiple grids.
use charming::Chart;
use charming::component::Grid;
let chart = Chart::new()
.grid(Grid::new());
§X Axis and Y Axis
Axis
is the axis in a cartesian coordinate system.
use charming::Chart;
use charming::component::Axis;
let chart = Chart::new()
.x_axis(Axis::new().data(vec!["Jan", "Feb", "Mar", "Apr"]))
.y_axis(Axis::new());
§Polar Coordinate
[Polar
] is the polar coordinate system. Polar coordinate can be used in
scatter and line charts. Every polar coordinate has an AngleAxis
and a
RadiusAxis
.
§Radar Coordinate
RadarCoordinate
is the radar coordinate system. Radar coordinate can be in
radar charts.
§Data Zoom
DataZoom
is used for zooming a specific area, which enables user to view
data in different scales. A chart can have multiple data zooms.
§Visual Map
VisualMap
is a visual encoding component. It maps data to visual channels,
such as color, symbol size or symbol shape. A chart can have multiple visual
maps.
§Tooltip
Tooltip
is a floating box that appears when user hovers over a data item.
§AxisPointer
AxisPointer
is a tool for displaying reference line and axis value under
mouse pointer.
§Toolbox
Toolbox
is a feature toolbox that includes data view, save as image, data
zoom, restore, and reset.
Implementations§
Source§impl Chart
impl Chart
pub fn new() -> Self
pub fn title(self, title: Title) -> Self
pub fn animation(self, animation: bool) -> Self
pub fn animation_threshold<F: Into<f64>>(self, animation_threshold: F) -> Self
pub fn animation_duration<A: Into<AnimationTime>>( self, animation_time: A, ) -> Self
pub fn animation_easing(self, easing: Easing) -> Self
pub fn animation_delay<A: Into<AnimationTime>>(self, animation_time: A) -> Self
pub fn animation_duration_update<A: Into<AnimationTime>>( self, animation_time: A, ) -> Self
pub fn animation_easing_update(self, easing: Easing) -> Self
pub fn animation_delay_update<A: Into<AnimationTime>>( self, animation_time: A, ) -> Self
pub fn tooltip(self, tooltip: Tooltip) -> Self
pub fn legend<L: Into<LegendConfig>>(self, legend: L) -> Self
pub fn toolbox(self, toolbox: Toolbox) -> Self
pub fn grid(self, grid: Grid) -> Self
pub fn grid3d(self, grid: Grid3D) -> Self
pub fn x_axis(self, x_axis: Axis) -> Self
pub fn x_axis3d(self, x_axis: Axis3D) -> Self
pub fn y_axis(self, y_axis: Axis) -> Self
pub fn y_axis3d(self, y_axis: Axis3D) -> Self
pub fn z_axis3d(self, z_axis: Axis3D) -> Self
pub fn polar(self, polar: PolarCoordinate) -> Self
pub fn angle_axis(self, angle_axis: AngleAxis) -> Self
pub fn radius_axis(self, radius_axis: RadiusAxis) -> Self
pub fn single_axis(self, single_axis: SingleAxis) -> Self
pub fn parallel_axis(self, parallel_axis: ParallelAxis) -> Self
pub fn axis_pointer(self, axis_pointer: AxisPointer) -> Self
pub fn visual_map(self, visual_map: VisualMap) -> Self
pub fn data_zoom(self, data_zoom: DataZoom) -> Self
pub fn parallel(self, parallel: ParallelCoordinate) -> Self
pub fn dataset(self, dataset: Dataset) -> Self
pub fn radar(self, radar: RadarCoordinate) -> Self
pub fn color(self, color: Vec<Color>) -> Self
pub fn background_color<C: Into<Color>>(self, color: C) -> Self
pub fn mark_line(self, mark_line: MarkLine) -> Self
pub fn aria(self, aria: Aria) -> Self
pub fn series<S: Into<Series>>(self, series: S) -> Self
pub fn geo_map<M: Into<GeoMap>>(self, map: M) -> Self
pub fn save_as_image_type(&self) -> Option<&SaveAsImageType>
Trait Implementations§
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 UnwindSafe for Chart
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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 moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.