40 series: { stack: null }
44 function findMatchingSeries(s, allseries) {
46 for (var i = 0; i < allseries.length; ++i) {
47 if (s == allseries[i])
50 if (allseries[i].stack == s.stack)
57 function stackData(plot, s, datapoints) {
58 if (s.stack == null || s.stack ===
false)
61 var other = findMatchingSeries(s, plot.getData());
65 var ps = datapoints.pointsize,
66 points = datapoints.points,
67 otherps = other.datapoints.pointsize,
68 otherpoints = other.datapoints.points,
70 px, py, intery, qx, qy, bottom,
71 withlines = s.lines.show,
72 horizontal = s.bars.horizontal,
73 withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
74 withsteps = withlines && s.lines.steps,
76 keyOffset = horizontal ? 1 : 0,
77 accumulateOffset = horizontal ? 0 : 1,
81 if (i >= points.length)
86 if (points[i] == null) {
88 for (m = 0; m < ps; ++m)
89 newpoints.push(points[i + m]);
92 else if (j >= otherpoints.length) {
95 for (m = 0; m < ps; ++m)
96 newpoints.push(points[i + m]);
100 else if (otherpoints[j] == null) {
102 for (m = 0; m < ps; ++m)
103 newpoints.push(null);
109 px = points[i + keyOffset];
110 py = points[i + accumulateOffset];
111 qx = otherpoints[j + keyOffset];
112 qy = otherpoints[j + accumulateOffset];
116 for (m = 0; m < ps; ++m)
117 newpoints.push(points[i + m]);
119 newpoints[l + accumulateOffset] += qy;
128 if (withlines && i > 0 && points[i - ps] != null) {
129 intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
131 newpoints.push(intery + qy);
132 for (m = 2; m < ps; ++m)
133 newpoints.push(points[i + m]);
140 if (fromgap && withlines) {
146 for (m = 0; m < ps; ++m)
147 newpoints.push(points[i + m]);
151 if (withlines && j > 0 && otherpoints[j - otherps] != null)
152 bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
154 newpoints[l + accumulateOffset] += bottom;
161 if (l != newpoints.length && withbottom)
162 newpoints[l + 2] += bottom;
166 if (withsteps && l != newpoints.length && l > 0
167 && newpoints[l] != null
168 && newpoints[l] != newpoints[l - ps]
169 && newpoints[l + 1] != newpoints[l - ps + 1]) {
170 for (m = 0; m < ps; ++m)
171 newpoints[l + ps + m] = newpoints[l + m];
172 newpoints[l + 1] = newpoints[l - ps + 1];
176 datapoints.points = newpoints;
179 plot.hooks.processDatapoints.push(stackData);
182 $.plot.plugins.push({