pub struct DualCoordChartContext<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> { /* private fields */ }
Expand description
The chart context that has two coordinate system attached.
This situation is quite common, for example, we with two different coodinate system.
For instance this example
This is done by attaching a second coordinate system to ChartContext by method ChartContext::set_secondary_coord.
For instance of dual coordinate charts, see this example.
Note: DualCoordChartContext
is always deref to the chart context.
- If you want to configure the secondary axis, method DualCoordChartContext::configure_secondary_axes
- If you want to draw a series using secondary coordinate system, use DualCoordChartContext::draw_secondary_series. And method ChartContext::draw_series will always use primary coordinate spec.
Implementations§
Source§impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
Sourcepub fn into_chart_state(self) -> DualCoordChartState<CT1, CT2>
pub fn into_chart_state(self) -> DualCoordChartState<CT1, CT2>
Convert the chart context into a chart state, similar to ChartContext::into_chart_state
Convert the chart context into a sharable chart state.
Sourcepub fn to_chart_state(&self) -> DualCoordChartState<CT1, CT2>
pub fn to_chart_state(&self) -> DualCoordChartState<CT1, CT2>
Copy the coordinate specs and make a chart state
Source§impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartContext<'a, DB, CT1, CT2>
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartContext<'a, DB, CT1, CT2>
Sourcepub fn secondary_plotting_area(&self) -> &DrawingArea<DB, CT2>
pub fn secondary_plotting_area(&self) -> &DrawingArea<DB, CT2>
Get a reference to the drawing area that uses the secondary coordinate system
Sourcepub fn borrow_secondary(&self) -> &ChartContext<'a, DB, CT2>
pub fn borrow_secondary(&self) -> &ChartContext<'a, DB, CT2>
Borrow a mutable reference to the chart context that uses the secondary coordinate system
Source§impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: ReverseCoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: ReverseCoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
Sourcepub fn into_secondary_coord_trans(
self,
) -> impl Fn(BackendCoord) -> Option<CT2::From>
pub fn into_secondary_coord_trans( self, ) -> impl Fn(BackendCoord) -> Option<CT2::From>
Convert the chart context into the secondary coordinate translation function
Source§impl<DB: DrawingBackend, CT1: ReverseCoordTranslate, CT2: ReverseCoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
impl<DB: DrawingBackend, CT1: ReverseCoordTranslate, CT2: ReverseCoordTranslate> DualCoordChartContext<'_, DB, CT1, CT2>
Sourcepub fn into_coord_trans_pair(
self,
) -> (impl Fn(BackendCoord) -> Option<CT1::From>, impl Fn(BackendCoord) -> Option<CT2::From>)
pub fn into_coord_trans_pair( self, ) -> (impl Fn(BackendCoord) -> Option<CT1::From>, impl Fn(BackendCoord) -> Option<CT2::From>)
Convert the chart context into a pair of closures that maps the pixel coordinate into the logical coordinate for both primary coordinate system and secondary coordinate system.
Source§impl<'a, DB: DrawingBackend, CT1: CoordTranslate, XT, YT, SX, SY> DualCoordChartContext<'a, DB, CT1, Cartesian2d<SX, SY>>where
SX: ValueFormatter<XT> + Ranged<ValueType = XT>,
SY: ValueFormatter<YT> + Ranged<ValueType = YT>,
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, XT, YT, SX, SY> DualCoordChartContext<'a, DB, CT1, Cartesian2d<SX, SY>>where
SX: ValueFormatter<XT> + Ranged<ValueType = XT>,
SY: ValueFormatter<YT> + Ranged<ValueType = YT>,
Sourcepub fn configure_secondary_axes<'b>(
&'b mut self,
) -> SecondaryMeshStyle<'a, 'b, SX, SY, DB>
pub fn configure_secondary_axes<'b>( &'b mut self, ) -> SecondaryMeshStyle<'a, 'b, SX, SY, DB>
Start configure the style for the secondary axes
Source§impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged, SX: Ranged, SY: Ranged> DualCoordChartContext<'a, DB, Cartesian2d<X, Y>, Cartesian2d<SX, SY>>
impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged, SX: Ranged, SY: Ranged> DualCoordChartContext<'a, DB, Cartesian2d<X, Y>, Cartesian2d<SX, SY>>
Sourcepub fn draw_secondary_series<E, R, S>(
&mut self,
series: S,
) -> Result<&mut SeriesAnno<'a, DB>, DrawingAreaErrorKind<DB::ErrorType>>where
for<'b> &'b E: PointCollection<'b, (SX::ValueType, SY::ValueType)>,
E: Drawable<DB>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
pub fn draw_secondary_series<E, R, S>(
&mut self,
series: S,
) -> Result<&mut SeriesAnno<'a, DB>, DrawingAreaErrorKind<DB::ErrorType>>where
for<'b> &'b E: PointCollection<'b, (SX::ValueType, SY::ValueType)>,
E: Drawable<DB>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
Draw a series use the secondary coordinate system.
series
: The series to drawReturns
the series annotation object or error code
Methods from Deref<Target = ChartContext<'a, DB, CT1>>§
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
.
Sourcepub fn configure_series_labels<'b>(
&'b mut self,
) -> SeriesLabelStyle<'a, 'b, DB, CT>where
DB: 'a,
pub fn configure_series_labels<'b>(
&'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::ErrorType>>where
B: CoordMapper,
for<'b> &'b E: PointCollection<'b, CT::From, B>,
E: Drawable<DB, B>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
pub fn draw_series<B, E, R, S>(
&mut self,
series: S,
) -> Result<&mut SeriesAnno<'a, DB>, DrawingAreaErrorKind<DB::ErrorType>>where
B: CoordMapper,
for<'b> &'b E: PointCollection<'b, CT::From, B>,
E: Drawable<DB, B>,
R: Borrow<E>,
S: IntoIterator<Item = R>,
Draw a data series. A data series in Plotters is abstracted as an iterator of elements
Sourcepub fn backend_coord(
&self,
coord: &(X::ValueType, Y::ValueType),
) -> BackendCoord
pub fn backend_coord( &self, coord: &(X::ValueType, Y::ValueType), ) -> BackendCoord
Maps the coordinate to the backend coordinate. This is typically used with an interactive chart.
pub fn configure_axes(&mut self) -> Axes3dStyle<'a, '_, X, Y, Z, DB>
Sourcepub fn with_projection<P: FnOnce(ProjectionMatrixBuilder) -> ProjectionMatrix>(
&mut self,
pf: P,
) -> &mut Self
pub fn with_projection<P: FnOnce(ProjectionMatrixBuilder) -> ProjectionMatrix>( &mut self, pf: P, ) -> &mut Self
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 Self
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