Skip to content

Commit fab25e7

Browse files
committed
Fix unneeded reverse loop, shorten cotroller.line
1 parent 74ff647 commit fab25e7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/controllers/controller.line.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ module.exports = DatasetController.extend({
183183
var yScale = me._yScale;
184184
var sumPos = 0;
185185
var sumNeg = 0;
186+
var rightValue = Number(yScale.getRightValue(value));
186187
var metasets = chart._getSortedVisibleDatasetMetas();
187188
var ilen = metasets.length;
188-
var i, ds, dsMeta;
189+
var i, ds, dsMeta, stackedRightValue;
189190

190191
if (yScale.options.stacked) {
191192
for (i = 0; i < ilen; ++i) {
@@ -196,7 +197,7 @@ module.exports = DatasetController.extend({
196197

197198
ds = chart.data.datasets[dsMeta.index];
198199
if (dsMeta.type === 'line' && dsMeta.yAxisID === yScale.id) {
199-
var stackedRightValue = Number(yScale.getRightValue(ds.data[index]));
200+
stackedRightValue = +yScale.getRightValue(ds.data[index]);
200201
if (stackedRightValue < 0) {
201202
sumNeg += stackedRightValue || 0;
202203
} else {
@@ -205,14 +206,11 @@ module.exports = DatasetController.extend({
205206
}
206207
}
207208

208-
var rightValue = Number(yScale.getRightValue(value));
209209
if (rightValue < 0) {
210210
return yScale.getPixelForValue(sumNeg + rightValue);
211211
}
212-
return yScale.getPixelForValue(sumPos + rightValue);
213212
}
214-
215-
return yScale.getPixelForValue(value);
213+
return yScale.getPixelForValue(sumPos + rightValue);
216214
},
217215

218216
updateBezierControlPoints: function() {

src/scales/scale.linear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function stackData(scale, stacks, meta, data) {
5050
var ilen = data.length;
5151
var i, value;
5252

53-
for (i = ilen - 1; i >= 0; --i) {
53+
for (i = 0; i < ilen; ++i) {
5454
value = +scale.getRightValue(data[i]);
5555
if (isNaN(value) || meta.data[i].hidden) {
5656
continue;

0 commit comments

Comments
 (0)