@@ -23,7 +23,7 @@ macro_rules! impl_get_extent {
2323 . [ <get_ $name _extent>] ( )
2424 . ok_or_else( || LayoutError :: ExtentsError ) ?;
2525
26- Ok ( self . compute_absolute_pixel_coords ( extent) )
26+ Ok ( extent)
2727 }
2828 #[ doc = "Get the size of the `" $name "` container." ]
2929 #[ doc = " * **Returns**: An option containing a tuple `(width, height)`." ]
@@ -181,13 +181,6 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
181181 }
182182 }
183183
184- /// Translate the `extent` given in local pixel coordinates to be given
185- /// in absolute pixel coordinates.
186- fn compute_absolute_pixel_coords ( & self , extent : Extent < i32 > ) -> Extent < i32 > {
187- let ( x_range, y_range) = self . root_area . get_pixel_range ( ) ;
188- extent. translate ( ( x_range. start , y_range. start ) )
189- }
190-
191184 pub fn draw ( & mut self ) -> Result < & mut Self , DrawingAreaErrorKind < DB :: ErrorType > > {
192185 let ( x_range, y_range) = self . root_area . get_pixel_range ( ) ;
193186 let ( x_top, y_top) = ( x_range. start , y_range. start ) ;
@@ -200,34 +193,25 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
200193 . nodes
201194 . get_chart_title_extent ( )
202195 . ok_or_else ( || LayoutError :: ExtentsError ) ?;
203- self . root_area . draw_text (
204- text,
205- & self . chart_title . style ,
206- ( extent. x0 + x_top, extent. y0 + y_top) ,
207- ) ?;
196+ self . root_area
197+ . draw_text ( text, & self . chart_title . style , ( extent. x0 , extent. y0 ) ) ?;
208198 }
209199
210200 if let Some ( text) = self . top_label . text . as_ref ( ) {
211201 let extent = self
212202 . nodes
213203 . get_top_label_extent ( )
214204 . ok_or_else ( || LayoutError :: ExtentsError ) ?;
215- self . root_area . draw_text (
216- text,
217- & self . top_label . style ,
218- ( extent. x0 + x_top, extent. y0 + y_top) ,
219- ) ?;
205+ self . root_area
206+ . draw_text ( text, & self . top_label . style , ( extent. x0 , extent. y0 ) ) ?;
220207 }
221208 if let Some ( text) = self . bottom_label . text . as_ref ( ) {
222209 let extent = self
223210 . nodes
224211 . get_bottom_label_extent ( )
225212 . ok_or_else ( || LayoutError :: ExtentsError ) ?;
226- self . root_area . draw_text (
227- text,
228- & self . bottom_label . style ,
229- ( extent. x0 + x_top, extent. y0 + y_top) ,
230- ) ?;
213+ self . root_area
214+ . draw_text ( text, & self . bottom_label . style , ( extent. x0 , extent. y0 ) ) ?;
231215 }
232216 // Draw the vertically oriented labels
233217 if let Some ( text) = self . left_label . text . as_ref ( ) {
@@ -238,7 +222,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
238222 self . root_area . draw_text (
239223 text,
240224 & self . left_label . style . transform ( FontTransform :: Rotate270 ) ,
241- ( extent. x0 + x_top , extent. y1 + y_top ) ,
225+ ( extent. x0 , extent. y1 ) ,
242226 ) ?;
243227 }
244228 if let Some ( text) = self . right_label . text . as_ref ( ) {
@@ -249,7 +233,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
249233 self . root_area . draw_text (
250234 text,
251235 & self . right_label . style . transform ( FontTransform :: Rotate270 ) ,
252- ( extent. x0 + x_top , extent. y1 + y_top ) ,
236+ ( extent. x0 , extent. y1 ) ,
253237 ) ?;
254238 }
255239
0 commit comments