]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Optimization: prevent double ticks array reverse for vertical logarithmic axis (...
authorjcopperfield <33193571+jcopperfield@users.noreply.github.com>
Sat, 23 Dec 2017 13:34:55 +0000 (14:34 +0100)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 23 Dec 2017 13:34:55 +0000 (08:34 -0500)
with ticks option 'reverse: true'.

src/scales/scale.logarithmic.js

index 87fe9b1af2b16dd674fd9048291ae4d6e2b01d63..372efe7adabfabda545ca9b4c3fea278f2552977 100644 (file)
@@ -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();