From cb90072015ede1b567760617f5b59217ff815655 Mon Sep 17 00:00:00 2001 From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Sat, 23 Dec 2017 14:34:55 +0100 Subject: [PATCH] Optimization: prevent double ticks array reverse for vertical logarithmic axis (#5076) with ticks option 'reverse: true'. --- src/scales/scale.logarithmic.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 87fe9b1af2b..372efe7adab 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -161,6 +161,7 @@ module.exports = function(Chart) { var me = this; var opts = me.options; var tickOpts = opts.ticks; + var reverse = !me.isHorizontal(); var generationOptions = { min: tickOpts.min, @@ -168,25 +169,22 @@ module.exports = function(Chart) { }; var ticks = me.ticks = Ticks.generators.logarithmic(generationOptions, me); - if (!me.isHorizontal()) { - // We are in a vertical orientation. The top value is the highest. So reverse the array - ticks.reverse(); - } - // At this point, we need to update our max and min given the tick values since we have expanded the // range of the scale me.max = helpers.max(ticks); me.min = helpers.min(ticks); if (tickOpts.reverse) { - ticks.reverse(); - + reverse = !reverse; me.start = me.max; me.end = me.min; } else { me.start = me.min; me.end = me.max; } + if (reverse) { + ticks.reverse(); + } }, convertTicksToLabels: function() { this.tickValues = this.ticks.slice();