Skip to content

Commit d530096

Browse files
committed
do not normalize all values if we don't care about the target
1 parent 3f13ffc commit d530096

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/shape.js

+24-17
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,35 @@ ChartInternal.prototype.getShapeOffset = function (typeFilter, indices, isSub) {
4343
var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id),
4444
y0 = scale(0), offset = y0;
4545
targets.forEach(function (t) {
46+
// skip if not part of offset (part1)
47+
if (t.id === d.id || indices[t.id] !== indices[d.id]) {
48+
return;
49+
}
50+
51+
// skip if not part of offset (part 2)
52+
if (targetIds.indexOf(t.id) >= targetIds.indexOf(d.id)) {
53+
return;
54+
}
55+
4656
const rowValues = $$.isStepType(d) ? $$.convertValuesToStep(t.values) : t.values;
4757
const isTargetNormalized = $$.isTargetNormalized(d.id);
4858
const values = rowValues.map(v => (isTargetNormalized ? $$.getRatio("index", v, true) : v.value));
4959

50-
if (t.id === d.id || indices[t.id] !== indices[d.id]) { return; }
51-
if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) {
52-
// check if the x values line up
53-
if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { // "+" for timeseries
54-
// if not, try to find the value that does line up
55-
i = -1;
56-
rowValues.forEach(function (v, j) {
57-
const x1 = v.x.constructor === Date ? +v.x : v.x;
58-
const x2 = d.x.constructor === Date ? +d.x : d.x;
60+
// check if the x values line up
61+
if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { // "+" for timeseries
62+
// if not, try to find the value that does line up
63+
i = -1;
64+
rowValues.forEach(function (v, j) {
65+
const x1 = v.x.constructor === Date ? +v.x : v.x;
66+
const x2 = d.x.constructor === Date ? +d.x : d.x;
5967

60-
if (x1 === x2) {
61-
i = j;
62-
}
63-
});
64-
}
65-
if (i in rowValues && rowValues[i].value * d.value >= 0) {
66-
offset += scale(values[i]) - y0;
67-
}
68+
if (x1 === x2) {
69+
i = j;
70+
}
71+
});
72+
}
73+
if (i in rowValues && rowValues[i].value * d.value >= 0) {
74+
offset += scale(values[i]) - y0;
6875
}
6976
});
7077
return offset;

0 commit comments

Comments
 (0)