Skip to content

Commit 92d033b

Browse files
jcopperfieldetimberg
authored andcommitted
Optimization: prevent double ticks array reverse for vertical logarithmic axis (#5076)
with ticks option 'reverse: true'.
1 parent ce1fc28 commit 92d033b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/scales/scale.logarithmic.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,32 +161,30 @@ module.exports = function(Chart) {
161161
var me = this;
162162
var opts = me.options;
163163
var tickOpts = opts.ticks;
164+
var reverse = !me.isHorizontal();
164165

165166
var generationOptions = {
166167
min: tickOpts.min,
167168
max: tickOpts.max
168169
};
169170
var ticks = me.ticks = Ticks.generators.logarithmic(generationOptions, me);
170171

171-
if (!me.isHorizontal()) {
172-
// We are in a vertical orientation. The top value is the highest. So reverse the array
173-
ticks.reverse();
174-
}
175-
176172
// At this point, we need to update our max and min given the tick values since we have expanded the
177173
// range of the scale
178174
me.max = helpers.max(ticks);
179175
me.min = helpers.min(ticks);
180176

181177
if (tickOpts.reverse) {
182-
ticks.reverse();
183-
178+
reverse = !reverse;
184179
me.start = me.max;
185180
me.end = me.min;
186181
} else {
187182
me.start = me.min;
188183
me.end = me.max;
189184
}
185+
if (reverse) {
186+
ticks.reverse();
187+
}
190188
},
191189
convertTicksToLabels: function() {
192190
this.tickValues = this.ticks.slice();

0 commit comments

Comments
 (0)