mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 04:09:08 +02:00
Optimization: prevent double ticks array reverse for vertical logarithmic axis (#5076)
with ticks option 'reverse: true'.
This commit is contained in:
parent
ce1fc28b74
commit
92d033beb2
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user