Skip to content

Commit d0d2bfc

Browse files
committed
Address review comments
1 parent 2ac5678 commit d0d2bfc

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/core/core.scale.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,14 @@ var Scale = Element.extend({
243243
/**
244244
* @param {number} maxWidth - the max width in pixels
245245
* @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
246+
* @param {object} margins - the space between the edge of the other scales and edge of the chart
247247
* This space comes from two sources:
248248
* - padding - space that's required to show the labels at the edges of the scale
249249
* - thickness of scales or legends in another orientation
250250
*/
251251
update: function(maxWidth, maxHeight, margins) {
252252
var me = this;
253-
var optionTicks = me.options.ticks;
253+
var tickOpts = me.options.ticks;
254254
var i, ilen, labels, ticks;
255255

256256
// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
@@ -301,6 +301,13 @@ var Scale = Element.extend({
301301
} else {
302302
// Support old implementations (that modified `this.ticks` directly in buildTicks)
303303
me.ticks = me.afterBuildTicks(me.ticks);
304+
ticks = [];
305+
for (i = 0, ilen = me.ticks.length; i < ilen; ++i) {
306+
ticks.push({
307+
value: me.ticks[i],
308+
major: false
309+
});
310+
}
304311
}
305312

306313
me.beforeTickToLabelConversion();
@@ -312,20 +319,9 @@ var Scale = Element.extend({
312319

313320
me.afterTickToLabelConversion();
314321

322+
// IMPORTANT: below this point, we consider that `this.ticks` will NEVER change!
315323
me.ticks = labels; // BACKWARD COMPATIBILITY
316324

317-
// IMPORTANT: from this point, we consider that `this.ticks` will NEVER change!
318-
319-
if (!ticks) {
320-
ticks = [];
321-
for (i = 0, ilen = labels.length; i < ilen; ++i) {
322-
ticks.push({
323-
value: me.ticks[i],
324-
major: false
325-
});
326-
}
327-
}
328-
329325
// BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `this.ticks`)
330326
for (i = 0, ilen = labels.length; i < ilen; ++i) {
331327
ticks[i].label = labels[i];
@@ -342,7 +338,7 @@ var Scale = Element.extend({
342338
me.fit();
343339
me.afterFit();
344340
// Auto-skip
345-
me._ticks = optionTicks.display && optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
341+
me._ticks = tickOpts.display && tickOpts.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
346342

347343
me.afterUpdate();
348344

0 commit comments

Comments
 (0)