@@ -240,8 +240,17 @@ var Scale = Element.extend({
240
240
helpers . callback ( this . options . beforeUpdate , [ this ] ) ;
241
241
} ,
242
242
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
+ */
243
251
update : function ( maxWidth , maxHeight , margins ) {
244
252
var me = this ;
253
+ var optionTicks = me . options . ticks ;
245
254
var i , ilen , labels , label , ticks , tick ;
246
255
247
256
// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
@@ -325,9 +334,12 @@ var Scale = Element.extend({
325
334
me . beforeFit ( ) ;
326
335
me . fit ( ) ;
327
336
me . afterFit ( ) ;
328
- //
337
+ // Auto-skip
338
+ me . _ticks = optionTicks . display && optionTicks . autoSkip ? me . _autoSkip ( me . getTicks ( ) ) : me . getTicks ( ) ;
339
+
329
340
me . afterUpdate ( ) ;
330
341
342
+ // TODO: remove minSize from all layout boxes. It is unused
331
343
return me . minSize ;
332
344
333
345
} ,
@@ -465,6 +477,7 @@ var Scale = Element.extend({
465
477
height : 0
466
478
} ;
467
479
480
+ var chart = me . chart ;
468
481
var ticks = me . getTicks ( ) ;
469
482
var opts = me . options ;
470
483
var tickOpts = opts . ticks ;
@@ -553,8 +566,13 @@ var Scale = Element.extend({
553
566
554
567
me . handleMargins ( ) ;
555
568
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
+ }
558
576
} ,
559
577
560
578
/**
@@ -563,12 +581,10 @@ var Scale = Element.extend({
563
581
*/
564
582
handleMargins : function ( ) {
565
583
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 ) ;
572
588
} ,
573
589
574
590
afterFit : function ( ) {
@@ -834,7 +850,7 @@ var Scale = Element.extend({
834
850
var isMirrored = optionTicks . mirror ;
835
851
var isHorizontal = me . isHorizontal ( ) ;
836
852
837
- var ticks = optionTicks . display && optionTicks . autoSkip ? me . _autoSkip ( me . getTicks ( ) ) : me . getTicks ( ) ;
853
+ var ticks = me . getTicks ( ) ;
838
854
var tickFonts = parseTickFontOptions ( optionTicks ) ;
839
855
var tickPadding = optionTicks . padding ;
840
856
var labelOffset = optionTicks . labelOffset ;
0 commit comments