@@ -442,13 +442,13 @@ var Scale = Element.extend({
442442 var me = this ;
443443 var options = me . options ;
444444 var tickOpts = options . ticks ;
445- var ticks = me . getTicks ( ) ;
445+ var numTicks = me . getTicks ( ) . length ;
446446 var minRotation = tickOpts . minRotation || 0 ;
447447 var maxRotation = tickOpts . maxRotation ;
448448 var labelRotation = minRotation ;
449449 var labelSizes , maxLabelWidth , maxLabelHeight , maxWidth , tickWidth , maxHeight , maxLabelDiagonal ;
450450
451- if ( ! me . _isVisible ( ) || ! tickOpts . display || minRotation >= maxRotation || ticks . length <= 1 || ! me . isHorizontal ( ) ) {
451+ if ( ! me . _isVisible ( ) || ! tickOpts . display || minRotation >= maxRotation || numTicks <= 1 || ! me . isHorizontal ( ) ) {
452452 me . labelRotation = minRotation ;
453453 return ;
454454 }
@@ -460,11 +460,11 @@ var Scale = Element.extend({
460460 // Estimate the width of each grid based on the canvas width, the maximum
461461 // label width and the number of tick intervals
462462 maxWidth = Math . min ( me . maxWidth , me . chart . width - maxLabelWidth ) ;
463- tickWidth = options . offset ? me . maxWidth / ticks . length : maxWidth / ( ticks . length - 1 ) ;
463+ tickWidth = options . offset ? me . maxWidth / numTicks : maxWidth / ( numTicks - 1 ) ;
464464
465465 // Allow 3 pixels x2 padding either side for label readability
466466 if ( maxLabelWidth + 6 > tickWidth ) {
467- tickWidth = maxWidth / ( ticks . length - ( options . offset ? 0.5 : 1 ) ) ;
467+ tickWidth = maxWidth / ( numTicks - ( options . offset ? 0.5 : 1 ) ) ;
468468 maxHeight = me . maxHeight - getTickMarkLength ( options . gridLines )
469469 - tickOpts . padding - getScaleLabelHeight ( options . scaleLabel ) ;
470470 maxLabelDiagonal = Math . sqrt ( maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight ) ;
@@ -494,13 +494,12 @@ var Scale = Element.extend({
494494 height : 0
495495 } ;
496496
497- var ticks = me . getTicks ( ) ;
498497 var opts = me . options ;
499498 var tickOpts = opts . ticks ;
500499 var scaleLabelOpts = opts . scaleLabel ;
501500 var gridLineOpts = opts . gridLines ;
502501 var display = me . _isVisible ( ) ;
503- var position = opts . position ;
502+ var isBottom = opts . position === 'bottom' ;
504503 var isHorizontal = me . isHorizontal ( ) ;
505504
506505 // Width
@@ -542,16 +541,16 @@ var Scale = Element.extend({
542541 minSize . height = Math . min ( me . maxHeight , minSize . height + labelHeight + tickPadding ) ;
543542
544543 var offsetLeft = me . getPixelForTick ( 0 ) - me . left ;
545- var offsetRight = me . right - me . getPixelForTick ( ticks . length - 1 ) ;
544+ var offsetRight = me . right - me . getPixelForTick ( me . getTicks ( ) . length - 1 ) ;
546545 var paddingLeft , paddingRight ;
547546
548547 // Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
549548 // which means that the right padding is dominated by the font height
550549 if ( isRotated ) {
551- paddingLeft = position === 'bottom' ?
550+ paddingLeft = isBottom ?
552551 cosRotation * firstLabelSize . width + sinRotation * firstLabelSize . offset :
553552 sinRotation * ( firstLabelSize . height - firstLabelSize . offset ) ;
554- paddingRight = position === 'bottom' ?
553+ paddingRight = isBottom ?
555554 sinRotation * ( lastLabelSize . height - lastLabelSize . offset ) :
556555 cosRotation * lastLabelSize . width + sinRotation * lastLabelSize . offset ;
557556 } else {
0 commit comments