Skip to content

Commit

Permalink
Fix some CC issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jun 26, 2019
1 parent fee3e99 commit 0f0124a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
20 changes: 10 additions & 10 deletions src/core/core.controller.js
Expand Up @@ -154,6 +154,14 @@ function positionIsHorizontal(position) {
return position === 'top' || position === 'bottom';
}

function compare2Level(l1, l2) {
return function(a, b) {
return a[l1] === b[l1]
? a[l2] - b[l2]
: a[l1] - b[l1];
};
}

var Chart = function(item, config) {
this.construct(item, config);
return this;
Expand Down Expand Up @@ -515,11 +523,7 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
// Do this before render so that any plugins that need final scale updates can use it
plugins.notify(me, 'afterUpdate');

me._layers.sort(function(a, b) {
return a.z === b.z
? a._idx - b._idx
: a.z - b.z;
});
me._layers.sort(compare2Level('z', '_idx'));

if (me._bufferedRender) {
me._bufferedRequest = {
Expand Down Expand Up @@ -729,11 +733,7 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
}
}

result.sort(function(a, b) {
return a.order === b.order
? a.index - b.index
: a.order - b.order;
});
result.sort(compare2Level('order', 'index'));

return result;
},
Expand Down
9 changes: 2 additions & 7 deletions src/scales/scale.linear.js
Expand Up @@ -80,13 +80,8 @@ function updateMinMax(scale, meta, data) {
continue;
}

if (value.min < scale.min) {
scale.min = value.min;
}

if (value.max > scale.max) {
scale.max = value.max;
}
scale.min = Math.min(scale.min, value.min);
scale.max = Math.max(scale.max, value.max);
}
}

Expand Down

0 comments on commit 0f0124a

Please sign in to comment.