pub struct ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate, { /* private fields */ }
Expand description
The context of the chart. This is the core object of Plotters. Any plot/chart is abstracted as this type, and any data series can be placed to the chart context.
- To draw a series on a chart context, use ChartContext::draw_series
- To draw a single element to the chart, you may want to use ChartContext::plotting_area
Implementations
sourceimpl<'a, DB, XT, YT, X, Y> ChartContext<'a, DB, Cartesian2d<X, Y>> where
DB: DrawingBackend,
X: Ranged<ValueType = XT> + ValueFormatter<XT>,
Y: Ranged<ValueType = YT> + ValueFormatter<YT>,
impl<'a, DB, XT, YT, X, Y> ChartContext<'a, DB, Cartesian2d<X, Y>> where
DB: DrawingBackend,
X: Ranged<ValueType = XT> + ValueFormatter<XT>,
Y: Ranged<ValueType = YT> + ValueFormatter<YT>,
sourcepub fn configure_mesh(&mut self) -> MeshStyle<'a, '_, X, Y, DB>
pub fn configure_mesh(&mut self) -> MeshStyle<'a, '_, X, Y, DB>
Initialize a mesh configuration object and mesh drawing can be finalized by calling
the function MeshStyle::draw
.
sourceimpl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: ReverseCoordTranslate,
impl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: ReverseCoordTranslate,
sourceimpl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate,
impl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate,
sourcepub fn configure_series_labels(&'b mut self) -> SeriesLabelStyle<'a, 'b, DB, CT> where
DB: 'a,
pub fn configure_series_labels(&'b mut self) -> SeriesLabelStyle<'a, 'b, DB, CT> where
DB: 'a,
Configure the styles for drawing series labels in the chart
sourcepub fn plotting_area(&self) -> &DrawingArea<DB, CT>
pub fn plotting_area(&self) -> &DrawingArea<DB, CT>
Get a reference of underlying plotting area
sourcepub fn as_coord_spec(&self) -> &CT
pub fn as_coord_spec(&self) -> &CT
Cast the reference to a chart context to a reference to underlying coordinate specification.
sourcepub fn draw_series<B, E, R, S>(
&mut self,
series: S
) -> Result<&mut SeriesAnno<'a, DB>, DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>> where
B: CoordMapper,
E: Drawable<DB, B>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
&'b E: for<'b> PointCollection<'b, <CT as CoordTranslate>::From, B>,
pub fn draw_series<B, E, R, S>(
&mut self,
series: S
) -> Result<&mut SeriesAnno<'a, DB>, DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>> where
B: CoordMapper,
E: Drawable<DB, B>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
&'b E: for<'b> PointCollection<'b, <CT as CoordTranslate>::From, B>,
Draw a data series. A data series in Plotters is abstracted as an iterator of elements
sourceimpl<'a, DB, X, Y> ChartContext<'a, DB, Cartesian2d<X, Y>> where
DB: DrawingBackend,
X: Ranged,
Y: Ranged,
impl<'a, DB, X, Y> ChartContext<'a, DB, Cartesian2d<X, Y>> where
DB: DrawingBackend,
X: Ranged,
Y: Ranged,
sourcepub fn backend_coord(
&self,
coord: &(<X as Ranged>::ValueType, <Y as Ranged>::ValueType)
) -> (i32, i32)
pub fn backend_coord(
&self,
coord: &(<X as Ranged>::ValueType, <Y as Ranged>::ValueType)
) -> (i32, i32)
Maps the coordinate to the backend coordinate. This is typically used with an interactive chart.
sourcepub fn set_secondary_coord<SX, SY>(
self,
x_coord: SX,
y_coord: SY
) -> DualCoordChartContext<'a, DB, Cartesian2d<X, Y>, Cartesian2d<<SX as AsRangedCoord>::CoordDescType, <SY as AsRangedCoord>::CoordDescType>> where
SX: AsRangedCoord,
SY: AsRangedCoord,
pub fn set_secondary_coord<SX, SY>(
self,
x_coord: SX,
y_coord: SY
) -> DualCoordChartContext<'a, DB, Cartesian2d<X, Y>, Cartesian2d<<SX as AsRangedCoord>::CoordDescType, <SY as AsRangedCoord>::CoordDescType>> where
SX: AsRangedCoord,
SY: AsRangedCoord,
Convert this chart context into a dual axis chart context and attach a second coordinate spec on the chart context. For more detailed information, see documentation for struct DualCoordChartContext
x_coord
: The coordinate spec for the X axisy_coord
: The coordinate spec for the Y axis- returns The newly created dual spec chart context
sourceimpl<'a, DB, X, Y, Z, XT, YT, ZT> ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
DB: DrawingBackend,
X: Ranged<ValueType = XT> + ValueFormatter<XT>,
Y: Ranged<ValueType = YT> + ValueFormatter<YT>,
Z: Ranged<ValueType = ZT> + ValueFormatter<ZT>,
impl<'a, DB, X, Y, Z, XT, YT, ZT> ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
DB: DrawingBackend,
X: Ranged<ValueType = XT> + ValueFormatter<XT>,
Y: Ranged<ValueType = YT> + ValueFormatter<YT>,
Z: Ranged<ValueType = ZT> + ValueFormatter<ZT>,
pub fn configure_axes(&mut self) -> Axes3dStyle<'a, '_, X, Y, Z, DB>
sourceimpl<'a, DB, X, Y, Z> ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
X: Ranged,
Y: Ranged,
Z: Ranged,
DB: DrawingBackend,
impl<'a, DB, X, Y, Z> ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
X: Ranged,
Y: Ranged,
Z: Ranged,
DB: DrawingBackend,
sourcepub fn with_projection<P>(
&mut self,
pf: P
) -> &mut ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
P: FnOnce(ProjectionMatrixBuilder) -> ProjectionMatrix,
pub fn with_projection<P>(
&mut self,
pf: P
) -> &mut ChartContext<'a, DB, Cartesian3d<X, Y, Z>> where
P: FnOnce(ProjectionMatrixBuilder) -> ProjectionMatrix,
Override the 3D projection matrix. This function allows to override the default projection matrix.
pf
: A function that takes the default projection matrix configuration and returns the projection matrix. This function will allow you to adjust the pitch, yaw angle and the centeral point of the projection, etc. You can also build a projection matrix which is not relies on the default configuration as well.
pub fn set_3d_pixel_range(
&mut self,
size: (i32, i32, i32)
) -> &mut ChartContext<'a, DB, Cartesian3d<X, Y, Z>>
sourceimpl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate,
impl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate,
sourcepub fn into_chart_state(self) -> ChartState<CT>
pub fn into_chart_state(self) -> ChartState<CT>
Convert a chart context into a chart state, by doing so, the chart context is consumed and
a saved chart state is created for later use. This is typically used in incrmental rendering. See documentation of ChartState
for more detailed example.
Convert the chart context into a sharable chart state.
Normally a chart state can not be clone, since the coordinate spec may not be able to be
cloned. In this case, we can use an Arc
get the coordinate wrapped thus the state can be
cloned and shared by multiple chart context
sourceimpl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate + Clone,
impl<'a, DB, CT> ChartContext<'a, DB, CT> where
DB: DrawingBackend,
CT: CoordTranslate + Clone,
sourcepub fn to_chart_state(&self) -> ChartState<CT>
pub fn to_chart_state(&self) -> ChartState<CT>
Make the chart context, do not consume the chart context and clone the coordinate spec
Auto Trait Implementations
impl<'a, DB, CT> !RefUnwindSafe for ChartContext<'a, DB, CT>
impl<'a, DB, CT> !Send for ChartContext<'a, DB, CT>
impl<'a, DB, CT> !Sync for ChartContext<'a, DB, CT>
impl<'a, DB, CT> Unpin for ChartContext<'a, DB, CT> where
CT: Unpin,
impl<'a, DB, CT> !UnwindSafe for ChartContext<'a, DB, CT>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more