6363 }
6464}
6565
66+ impl < ' a , DB : DrawingBackend , CT : ReverseCoordTranslate > ChartContext < ' a , DB , CT > {
67+ /// Convert the chart context into an closure that can be used for coordinate translation
68+ pub fn into_coord_trans ( self ) -> impl Fn ( BackendCoord ) -> Option < CT :: From > {
69+ let coord_spec = self . drawing_area . into_coord_spec ( ) ;
70+ move |coord| coord_spec. reverse_translate ( coord)
71+ }
72+ }
73+
6674impl < ' a , DB : DrawingBackend , CT : CoordTranslate > ChartContext < ' a , DB , CT > {
6775 /// Configure the styles for drawing series labels in the chart
6876 pub fn configure_series_labels < ' b > ( & ' b mut self ) -> SeriesLabelStyle < ' a , ' b , DB , CT >
@@ -76,24 +84,12 @@ impl<'a, DB: DrawingBackend, CT: CoordTranslate> ChartContext<'a, DB, CT> {
7684 pub fn plotting_area ( & self ) -> & DrawingArea < DB , CT > {
7785 & self . drawing_area
7886 }
79- }
8087
81- impl < ' a , DB : DrawingBackend , CT : CoordTranslate > ChartContext < ' a , DB , CT > {
8288 /// Cast the reference to a chart context to a reference to underlying coordinate specification.
8389 pub fn as_coord_spec ( & self ) -> & CT {
8490 self . drawing_area . as_coord_spec ( )
8591 }
86- }
87-
88- impl < ' a , DB : DrawingBackend , CT : ReverseCoordTranslate > ChartContext < ' a , DB , CT > {
89- /// Convert the chart context into an closure that can be used for coordinate translation
90- pub fn into_coord_trans ( self ) -> impl Fn ( BackendCoord ) -> Option < CT :: From > {
91- let coord_spec = self . drawing_area . into_coord_spec ( ) ;
92- move |coord| coord_spec. reverse_translate ( coord)
93- }
94- }
9592
96- impl < ' a , DB : DrawingBackend , CT : CoordTranslate > ChartContext < ' a , DB , CT > {
9793 // TODO: All draw_series_impl is overly strict about lifetime, because we don't have stable HKT,
9894 // what we can ensure is for all lifetime 'b the element reference &'b E is a iterator
9995 // of points reference with the same lifetime.
0 commit comments