Commit 850d39fc by benrubson

Revert #6287 for jquery.flot.stack.js

parent 61bb9cbc
...@@ -78,46 +78,41 @@ charts or filled areas). ...@@ -78,46 +78,41 @@ charts or filled areas).
i = 0, j = 0, l, m; i = 0, j = 0, l, m;
while (true) { while (true) {
// browse all points from the current series and from the previous series if (i >= points.length)
if (i >= points.length && j >= otherpoints.length)
break; break;
// newpoints will replace current series with
// as many points as different timestamps we have in the 2 (current & previous) series
l = newpoints.length; l = newpoints.length;
px = points[i + keyOffset];
py = points[i + accumulateOffset];
qx = otherpoints[j + keyOffset];
qy = otherpoints[j + accumulateOffset];
bottom = 0;
if (i < points.length && px == null) { if (points[i] == null) {
// let's ignore null points from current series, nothing to do with them // copy gaps
i += ps;
}
else if (j < otherpoints.length && qx == null) {
// let's ignore null points from previous series, nothing to do with them
j += otherps;
}
else if (i >= points.length) {
// no more points in the current series, simply take the remaining points
// from the previous series so that next series will correctly stack
for (m = 0; m < ps; ++m) for (m = 0; m < ps; ++m)
newpoints.push(otherpoints[j + m]); newpoints.push(points[i + m]);
bottom = qy; i += ps;
j += otherps;
} }
else if (j >= otherpoints.length) { else if (j >= otherpoints.length) {
// no more points in the previous series, of course let's take // for lines, we can't use the rest of the points
// the remaining points from the current series if (!withlines) {
for (m = 0; m < ps; ++m) for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]); newpoints.push(points[i + m]);
}
i += ps; i += ps;
} }
else if (otherpoints[j] == null) {
// oops, got a gap
for (m = 0; m < ps; ++m)
newpoints.push(null);
fromgap = true;
j += otherps;
}
else { else {
// next available points from current and previous series have the same timestamp // cases where we actually got two points
px = points[i + keyOffset];
py = points[i + accumulateOffset];
qx = otherpoints[j + keyOffset];
qy = otherpoints[j + accumulateOffset];
bottom = 0;
if (px == qx) { if (px == qx) {
// so take the point from the current series and skip the previous' one
for (m = 0; m < ps; ++m) for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]); newpoints.push(points[i + m]);
...@@ -127,39 +122,55 @@ charts or filled areas). ...@@ -127,39 +122,55 @@ charts or filled areas).
i += ps; i += ps;
j += otherps; j += otherps;
} }
// next available point with the smallest timestamp is from the previous series
else if (px > qx) { else if (px > qx) {
// so take the point from the previous series so that next series will correctly stack // we got past point below, might need to
for (m = 0; m < ps; ++m) // insert interpolated extra point
newpoints.push(otherpoints[j + m]); if (withlines && i > 0 && points[i - ps] != null) {
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
// we might be able to interpolate newpoints.push(qx);
if (i > 0 && points[i - ps] != null) newpoints.push(intery + qy);
newpoints[l + accumulateOffset] += py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px); for (m = 2; m < ps; ++m)
newpoints.push(points[i + m]);
bottom = qy; bottom = qy;
}
j += otherps; j += otherps;
} }
// (px < qx) next available point with the smallest timestamp is from the current series else { // px < qx
else { if (fromgap && withlines) {
// so of course let's take the point from the current series // if we come from a gap, we just skip this point
i += ps;
continue;
}
for (m = 0; m < ps; ++m) for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]); newpoints.push(points[i + m]);
// we might be able to interpolate a point below, // we might be able to interpolate a point below,
// this can give us a better y // this can give us a better y
if (j > 0 && otherpoints[j - otherps] != null) if (withlines && j > 0 && otherpoints[j - otherps] != null)
bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx); bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
newpoints[l + accumulateOffset] += bottom; newpoints[l + accumulateOffset] += bottom;
i += ps; i += ps;
} }
}
fromgap = false;
if (l != newpoints.length && withbottom) if (l != newpoints.length && withbottom)
newpoints[l + 2] = bottom; newpoints[l + 2] += bottom;
}
// maintain the line steps invariant
if (withsteps && l != newpoints.length && l > 0
&& newpoints[l] != null
&& newpoints[l] != newpoints[l - ps]
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
for (m = 0; m < ps; ++m)
newpoints[l + ps + m] = newpoints[l + m];
newpoints[l + 1] = newpoints[l - ps + 1];
}
} }
datapoints.points = newpoints; datapoints.points = newpoints;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment