Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jun 27, 2019
1 parent 2ac5678 commit d0d2bfc
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/core/core.scale.js
Expand Up @@ -243,14 +243,14 @@ var Scale = Element.extend({
/**
* @param {number} maxWidth - the max width in pixels
* @param {number} maxHeight - the max height in pixels
* @param {object} margins - the space between the edge of the scale and edge of the chart
* @param {object} margins - the space between the edge of the other scales and edge of the chart
* This space comes from two sources:
* - padding - space that's required to show the labels at the edges of the scale
* - thickness of scales or legends in another orientation
*/
update: function(maxWidth, maxHeight, margins) {
var me = this;
var optionTicks = me.options.ticks;
var tickOpts = me.options.ticks;
var i, ilen, labels, ticks;

// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
Expand Down Expand Up @@ -301,6 +301,13 @@ var Scale = Element.extend({
} else {
// Support old implementations (that modified `this.ticks` directly in buildTicks)
me.ticks = me.afterBuildTicks(me.ticks);
ticks = [];
for (i = 0, ilen = me.ticks.length; i < ilen; ++i) {
ticks.push({
value: me.ticks[i],
major: false
});
}
}

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

me.afterTickToLabelConversion();

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

// IMPORTANT: from this point, we consider that `this.ticks` will NEVER change!

if (!ticks) {
ticks = [];
for (i = 0, ilen = labels.length; i < ilen; ++i) {
ticks.push({
value: me.ticks[i],
major: false
});
}
}

// BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `this.ticks`)
for (i = 0, ilen = labels.length; i < ilen; ++i) {
ticks[i].label = labels[i];
Expand All @@ -342,7 +338,7 @@ var Scale = Element.extend({
me.fit();
me.afterFit();
// Auto-skip
me._ticks = optionTicks.display && optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
me._ticks = tickOpts.display && tickOpts.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();

me.afterUpdate();

Expand Down

0 comments on commit d0d2bfc

Please sign in to comment.