@@ -414,13 +414,13 @@ var Scale = Element.extend({
414414 var me = this ;
415415 var options = me . options ;
416416 var tickOpts = options . ticks ;
417- var ticks = me . getTicks ( ) ;
417+ var numTicks = me . getTicks ( ) . length ;
418418 var minRotation = tickOpts . minRotation || 0 ;
419419 var maxRotation = tickOpts . maxRotation ;
420420 var labelRotation = minRotation ;
421421 var labelSizes , maxLabelWidth , maxLabelHeight , maxWidth , tickWidth , maxHeight , maxLabelDiagonal ;
422422
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 ( ) ) {
424424 me . labelRotation = minRotation ;
425425 return ;
426426 }
@@ -432,11 +432,11 @@ var Scale = Element.extend({
432432 // Estimate the width of each grid based on the canvas width, the maximum
433433 // label width and the number of tick intervals
434434 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 ) ;
436436
437437 // Allow 3 pixels x2 padding either side for label readability
438438 if ( maxLabelWidth + 6 > tickWidth ) {
439- tickWidth = maxWidth / ( ticks . length - ( options . offset ? 0.5 : 1 ) ) ;
439+ tickWidth = maxWidth / ( numTicks - ( options . offset ? 0.5 : 1 ) ) ;
440440 maxHeight = me . maxHeight - getTickMarkLength ( options . gridLines )
441441 - tickOpts . padding - getScaleLabelHeight ( options . scaleLabel ) ;
442442 maxLabelDiagonal = Math . sqrt ( maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight ) ;
@@ -466,13 +466,12 @@ var Scale = Element.extend({
466466 height : 0
467467 } ;
468468
469- var ticks = me . getTicks ( ) ;
470469 var opts = me . options ;
471470 var tickOpts = opts . ticks ;
472471 var scaleLabelOpts = opts . scaleLabel ;
473472 var gridLineOpts = opts . gridLines ;
474473 var display = me . _isVisible ( ) ;
475- var position = opts . position ;
474+ var isBottom = opts . position === 'bottom' ;
476475 var isHorizontal = me . isHorizontal ( ) ;
477476
478477 // Width
@@ -514,16 +513,16 @@ var Scale = Element.extend({
514513 minSize . height = Math . min ( me . maxHeight , minSize . height + labelHeight + tickPadding ) ;
515514
516515 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 ) ;
518517 var paddingLeft , paddingRight ;
519518
520519 // Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
521520 // which means that the right padding is dominated by the font height
522521 if ( isRotated ) {
523- paddingLeft = position === 'bottom' ?
522+ paddingLeft = isBottom ?
524523 cosRotation * firstLabelSize . width + sinRotation * firstLabelSize . offset :
525524 sinRotation * ( firstLabelSize . height - firstLabelSize . offset ) ;
526- paddingRight = position === 'bottom' ?
525+ paddingRight = isBottom ?
527526 sinRotation * ( lastLabelSize . height - lastLabelSize . offset ) :
528527 cosRotation * lastLabelSize . width + sinRotation * lastLabelSize . offset ;
529528 } else {
0 commit comments