From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Sat, 23 Dec 2017 13:34:55 +0000 (+0100) Subject: Optimization: prevent double ticks array reverse for vertical logarithmic axis (... X-Git-Tag: v2.7.2~1^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92d033beb2d29fc296aee23b9e9d9c4be1fadd15;p=thirdparty%2FChart.js.git Optimization: prevent double ticks array reverse for vertical logarithmic axis (#5076) with ticks option 'reverse: true'. --- diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 87fe9b1af..372efe7ad 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();