@@ -414,13 +414,13 @@ var Scale = Element.extend({
414
414
var me = this ;
415
415
var options = me . options ;
416
416
var tickOpts = options . ticks ;
417
- var ticks = me . getTicks ( ) ;
417
+ var numTicks = me . getTicks ( ) . length ;
418
418
var minRotation = tickOpts . minRotation || 0 ;
419
419
var maxRotation = tickOpts . maxRotation ;
420
420
var labelRotation = minRotation ;
421
421
var labelSizes , maxLabelWidth , maxLabelHeight , maxWidth , tickWidth , maxHeight , maxLabelDiagonal ;
422
422
423
- if ( ! me . _isVisible ( ) || ! tickOpts . display || minRotation >= maxRotation || ticks . length <= 1 || ! me . isHorizontal ( ) ) {
423
+ if ( ! me . _isVisible ( ) || ! tickOpts . display || minRotation >= maxRotation || numTicks <= 1 || ! me . isHorizontal ( ) ) {
424
424
me . labelRotation = minRotation ;
425
425
return ;
426
426
}
@@ -432,11 +432,11 @@ var Scale = Element.extend({
432
432
// Estimate the width of each grid based on the canvas width, the maximum
433
433
// label width and the number of tick intervals
434
434
maxWidth = Math . min ( me . maxWidth , me . chart . width - maxLabelWidth ) ;
435
- tickWidth = options . offset ? me . maxWidth / ticks . length : maxWidth / ( ticks . length - 1 ) ;
435
+ tickWidth = options . offset ? me . maxWidth / numTicks : maxWidth / ( numTicks - 1 ) ;
436
436
437
437
// Allow 3 pixels x2 padding either side for label readability
438
438
if ( maxLabelWidth + 6 > tickWidth ) {
439
- tickWidth = maxWidth / ( ticks . length - ( options . offset ? 0.5 : 1 ) ) ;
439
+ tickWidth = maxWidth / ( numTicks - ( options . offset ? 0.5 : 1 ) ) ;
440
440
maxHeight = me . maxHeight - getTickMarkLength ( options . gridLines )
441
441
- tickOpts . padding - getScaleLabelHeight ( options . scaleLabel ) ;
442
442
maxLabelDiagonal = Math . sqrt ( maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight ) ;
@@ -466,13 +466,12 @@ var Scale = Element.extend({
466
466
height : 0
467
467
} ;
468
468
469
- var ticks = me . getTicks ( ) ;
470
469
var opts = me . options ;
471
470
var tickOpts = opts . ticks ;
472
471
var scaleLabelOpts = opts . scaleLabel ;
473
472
var gridLineOpts = opts . gridLines ;
474
473
var display = me . _isVisible ( ) ;
475
- var position = opts . position ;
474
+ var isBottom = opts . position === 'bottom' ;
476
475
var isHorizontal = me . isHorizontal ( ) ;
477
476
478
477
// Width
@@ -514,16 +513,16 @@ var Scale = Element.extend({
514
513
minSize . height = Math . min ( me . maxHeight , minSize . height + labelHeight + tickPadding ) ;
515
514
516
515
var offsetLeft = me . getPixelForTick ( 0 ) - me . left ;
517
- var offsetRight = me . right - me . getPixelForTick ( ticks . length - 1 ) ;
516
+ var offsetRight = me . right - me . getPixelForTick ( me . getTicks ( ) . length - 1 ) ;
518
517
var paddingLeft , paddingRight ;
519
518
520
519
// Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
521
520
// which means that the right padding is dominated by the font height
522
521
if ( isRotated ) {
523
- paddingLeft = position === 'bottom' ?
522
+ paddingLeft = isBottom ?
524
523
cosRotation * firstLabelSize . width + sinRotation * firstLabelSize . offset :
525
524
sinRotation * ( firstLabelSize . height - firstLabelSize . offset ) ;
526
- paddingRight = position === 'bottom' ?
525
+ paddingRight = isBottom ?
527
526
sinRotation * ( lastLabelSize . height - lastLabelSize . offset ) :
528
527
cosRotation * lastLabelSize . width + sinRotation * lastLabelSize . offset ;
529
528
} else {
0 commit comments