@@ -26,7 +26,6 @@ import {
2626 makeColumnLayout ,
2727 retrieveColumnLayout
2828} from '../layout/barGrid' ;
29- import BoundingRect , { RectLike } from 'zrender/src/core/BoundingRect' ;
3029
3130import TimeScale from '../scale/Time' ;
3231import Model from '../model/Model' ;
@@ -290,69 +289,6 @@ export function getAxisRawValue(axis: Axis, tick: ScaleTick): number | string {
290289 return axis . type === 'category' ? axis . scale . getLabel ( tick ) : tick . value ;
291290}
292291
293- /**
294- * @param axis
295- * @return Be null/undefined if no labels.
296- */
297- export function estimateLabelUnionRect ( axis : Axis ) {
298- const axisModel = axis . model ;
299- const scale = axis . scale ;
300-
301- if ( ! axisModel . get ( [ 'axisLabel' , 'show' ] ) || scale . isBlank ( ) ) {
302- return ;
303- }
304-
305- let realNumberScaleTicks : ScaleTick [ ] ;
306- let tickCount ;
307- const categoryScaleExtent = scale . getExtent ( ) ;
308-
309- // Optimize for large category data, avoid call `getTicks()`.
310- if ( scale instanceof OrdinalScale ) {
311- tickCount = scale . count ( ) ;
312- }
313- else {
314- realNumberScaleTicks = scale . getTicks ( ) ;
315- tickCount = realNumberScaleTicks . length ;
316- }
317-
318- const axisLabelModel = axis . getLabelModel ( ) ;
319- const labelFormatter = makeLabelFormatter ( axis ) ;
320-
321- let rect ;
322- let step = 1 ;
323- // Simple optimization for large amount of labels
324- if ( tickCount > 40 ) {
325- step = Math . ceil ( tickCount / 40 ) ;
326- }
327- for ( let i = 0 ; i < tickCount ; i += step ) {
328- const tick = realNumberScaleTicks
329- ? realNumberScaleTicks [ i ]
330- : {
331- value : categoryScaleExtent [ 0 ] + i
332- } ;
333- const label = labelFormatter ( tick , i ) ;
334- const unrotatedSingleRect = axisLabelModel . getTextRect ( label ) ;
335- const singleRect = rotateTextRect ( unrotatedSingleRect , axisLabelModel . get ( 'rotate' ) || 0 ) ;
336-
337- rect ? rect . union ( singleRect ) : ( rect = singleRect ) ;
338- }
339-
340- return rect ;
341- }
342-
343- function rotateTextRect ( textRect : RectLike , rotate : number ) {
344- const rotateRadians = rotate * Math . PI / 180 ;
345- const beforeWidth = textRect . width ;
346- const beforeHeight = textRect . height ;
347- const afterWidth = beforeWidth * Math . abs ( Math . cos ( rotateRadians ) )
348- + Math . abs ( beforeHeight * Math . sin ( rotateRadians ) ) ;
349- const afterHeight = beforeWidth * Math . abs ( Math . sin ( rotateRadians ) )
350- + Math . abs ( beforeHeight * Math . cos ( rotateRadians ) ) ;
351- const rotatedRect = new BoundingRect ( textRect . x , textRect . y , afterWidth , afterHeight ) ;
352-
353- return rotatedRect ;
354- }
355-
356292/**
357293 * @param model axisLabelModel or axisTickModel
358294 * @return {number|String } Can be null|'auto'|number|function
@@ -399,3 +335,7 @@ export function unionAxisExtentFromData(dataExtent: number[], data: SeriesData,
399335 } ) ;
400336 }
401337}
338+
339+ export function isNameLocationCenter ( nameLocation : string ) {
340+ return nameLocation === 'middle' || nameLocation === 'center' ;
341+ }
0 commit comments