@@ -23,7 +23,7 @@ macro_rules! impl_get_extent {
23
23
. [ <get_ $name _extent>] ( )
24
24
. ok_or_else( || LayoutError :: ExtentsError ) ?;
25
25
26
- Ok ( self . compute_absolute_pixel_coords ( extent) )
26
+ Ok ( extent)
27
27
}
28
28
#[ doc = "Get the size of the `" $name "` container." ]
29
29
#[ doc = " * **Returns**: An option containing a tuple `(width, height)`." ]
@@ -181,13 +181,6 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
181
181
}
182
182
}
183
183
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
-
191
184
pub fn draw ( & mut self ) -> Result < & mut Self , DrawingAreaErrorKind < DB :: ErrorType > > {
192
185
let ( x_range, y_range) = self . root_area . get_pixel_range ( ) ;
193
186
let ( x_top, y_top) = ( x_range. start , y_range. start ) ;
@@ -200,34 +193,25 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
200
193
. nodes
201
194
. get_chart_title_extent ( )
202
195
. 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 ) ) ?;
208
198
}
209
199
210
200
if let Some ( text) = self . top_label . text . as_ref ( ) {
211
201
let extent = self
212
202
. nodes
213
203
. get_top_label_extent ( )
214
204
. 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 ) ) ?;
220
207
}
221
208
if let Some ( text) = self . bottom_label . text . as_ref ( ) {
222
209
let extent = self
223
210
. nodes
224
211
. get_bottom_label_extent ( )
225
212
. 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 ) ) ?;
231
215
}
232
216
// Draw the vertically oriented labels
233
217
if let Some ( text) = self . left_label . text . as_ref ( ) {
@@ -238,7 +222,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
238
222
self . root_area . draw_text (
239
223
text,
240
224
& self . left_label . style . transform ( FontTransform :: Rotate270 ) ,
241
- ( extent. x0 + x_top , extent. y1 + y_top ) ,
225
+ ( extent. x0 , extent. y1 ) ,
242
226
) ?;
243
227
}
244
228
if let Some ( text) = self . right_label . text . as_ref ( ) {
@@ -249,7 +233,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartLayout<'a, 'b, DB> {
249
233
self . root_area . draw_text (
250
234
text,
251
235
& self . right_label . style . transform ( FontTransform :: Rotate270 ) ,
252
- ( extent. x0 + x_top , extent. y1 + y_top ) ,
236
+ ( extent. x0 , extent. y1 ) ,
253
237
) ?;
254
238
}
255
239
0 commit comments