@@ -240,8 +240,17 @@ var Scale = Element.extend({
240240 helpers . callback ( this . options . beforeUpdate , [ this ] ) ;
241241 } ,
242242
243+ /**
244+ * @param {number } maxWidth - the max width in pixels
245+ * @param {number } maxHeight - the max height in pixels
246+ * @param {object } margins - the space between the edge of the scale and edge of the chart
247+ * This space comes from two sources:
248+ * - padding - space that's required to show the labels at the edges of the scale
249+ * - thickness of scales or legends in another orientation
250+ */
243251 update : function ( maxWidth , maxHeight , margins ) {
244252 var me = this ;
253+ var optionTicks = me . options . ticks ;
245254 var i , ilen , labels , label , ticks , tick ;
246255
247256 // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
@@ -325,9 +334,12 @@ var Scale = Element.extend({
325334 me . beforeFit ( ) ;
326335 me . fit ( ) ;
327336 me . afterFit ( ) ;
328- //
337+ // Auto-skip
338+ me . _ticks = optionTicks . display && optionTicks . autoSkip ? me . _autoSkip ( me . getTicks ( ) ) : me . getTicks ( ) ;
339+
329340 me . afterUpdate ( ) ;
330341
342+ // TODO: remove minSize as a public property and return value from all layout boxes. It is unused
331343 return me . minSize ;
332344
333345 } ,
@@ -465,6 +477,7 @@ var Scale = Element.extend({
465477 height : 0
466478 } ;
467479
480+ var chart = me . chart ;
468481 var ticks = me . getTicks ( ) ;
469482 var opts = me . options ;
470483 var tickOpts = opts . ticks ;
@@ -553,8 +566,13 @@ var Scale = Element.extend({
553566
554567 me . handleMargins ( ) ;
555568
556- me . width = minSize . width ;
557- me . height = minSize . height ;
569+ if ( isHorizontal ) {
570+ me . width = chart . width - me . margins . left - me . margins . right ;
571+ me . height = minSize . height ;
572+ } else {
573+ me . width = minSize . width ;
574+ me . height = chart . height - me . margins . top - me . margins . bottom ;
575+ }
558576 } ,
559577
560578 /**
@@ -563,12 +581,10 @@ var Scale = Element.extend({
563581 */
564582 handleMargins : function ( ) {
565583 var me = this ;
566- if ( me . margins ) {
567- me . margins . left = Math . max ( me . paddingLeft , me . margins . left ) ;
568- me . margins . top = Math . max ( me . paddingTop , me . margins . top ) ;
569- me . margins . right = Math . max ( me . paddingRight , me . margins . right ) ;
570- me . margins . bottom = Math . max ( me . paddingBottom , me . margins . bottom ) ;
571- }
584+ me . margins . left = Math . max ( me . paddingLeft , me . margins . left ) ;
585+ me . margins . top = Math . max ( me . paddingTop , me . margins . top ) ;
586+ me . margins . right = Math . max ( me . paddingRight , me . margins . right ) ;
587+ me . margins . bottom = Math . max ( me . paddingBottom , me . margins . bottom ) ;
572588 } ,
573589
574590 afterFit : function ( ) {
@@ -834,7 +850,7 @@ var Scale = Element.extend({
834850 var isMirrored = optionTicks . mirror ;
835851 var isHorizontal = me . isHorizontal ( ) ;
836852
837- var ticks = optionTicks . display && optionTicks . autoSkip ? me . _autoSkip ( me . getTicks ( ) ) : me . getTicks ( ) ;
853+ var ticks = me . getTicks ( ) ;
838854 var tickFonts = parseTickFontOptions ( optionTicks ) ;
839855 var tickPadding = optionTicks . padding ;
840856 var labelOffset = optionTicks . labelOffset ;
0 commit comments