|
|
|
|
@ -29,7 +29,7 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function ( $ ) {
|
|
|
|
|
(function ($) {
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
series: {
|
|
|
|
|
@ -37,37 +37,37 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function init( plot ) {
|
|
|
|
|
function init(plot) {
|
|
|
|
|
|
|
|
|
|
function findBottomSeries( s, allseries ) {
|
|
|
|
|
function findBottomSeries(s, allseries) {
|
|
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < allseries.length; ++i ) {
|
|
|
|
|
if ( allseries[ i ].id === s.fillBetween ) {
|
|
|
|
|
return allseries[ i ];
|
|
|
|
|
for (i = 0; i < allseries.length; ++i) {
|
|
|
|
|
if (allseries[i].id === s.fillBetween) {
|
|
|
|
|
return allseries[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( typeof s.fillBetween === "number" ) {
|
|
|
|
|
if ( s.fillBetween < 0 || s.fillBetween >= allseries.length ) {
|
|
|
|
|
if (typeof s.fillBetween === "number") {
|
|
|
|
|
if (s.fillBetween < 0 || s.fillBetween >= allseries.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return allseries[ s.fillBetween ];
|
|
|
|
|
return allseries[s.fillBetween];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function computeFillBottoms( plot, s, datapoints ) {
|
|
|
|
|
function computeFillBottoms(plot, s, datapoints) {
|
|
|
|
|
|
|
|
|
|
if ( s.fillBetween == null ) {
|
|
|
|
|
if (s.fillBetween == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var other = findBottomSeries( s, plot.getData() );
|
|
|
|
|
var other = findBottomSeries(s, plot.getData());
|
|
|
|
|
|
|
|
|
|
if ( !other ) {
|
|
|
|
|
if (!other) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -85,42 +85,42 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
j = 0,
|
|
|
|
|
l, m;
|
|
|
|
|
|
|
|
|
|
while ( true ) {
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
|
if ( i >= points.length ) {
|
|
|
|
|
if (i >= points.length) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
l = newpoints.length;
|
|
|
|
|
|
|
|
|
|
if ( points[ i ] == null ) {
|
|
|
|
|
if (points[i] == null) {
|
|
|
|
|
|
|
|
|
|
// copy gaps
|
|
|
|
|
|
|
|
|
|
for ( m = 0; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( points[ i + m ] );
|
|
|
|
|
for (m = 0; m < ps; ++m) {
|
|
|
|
|
newpoints.push(points[i + m]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i += ps;
|
|
|
|
|
|
|
|
|
|
} else if ( j >= otherpoints.length ) {
|
|
|
|
|
} else if (j >= otherpoints.length) {
|
|
|
|
|
|
|
|
|
|
// for lines, we can't use the rest of the points
|
|
|
|
|
|
|
|
|
|
if ( !withlines ) {
|
|
|
|
|
for ( m = 0; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( points[ i + m ] );
|
|
|
|
|
if (!withlines) {
|
|
|
|
|
for (m = 0; m < ps; ++m) {
|
|
|
|
|
newpoints.push(points[i + m]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i += ps;
|
|
|
|
|
|
|
|
|
|
} else if ( otherpoints[ j ] == null ) {
|
|
|
|
|
} else if (otherpoints[j] == null) {
|
|
|
|
|
|
|
|
|
|
// oops, got a gap
|
|
|
|
|
|
|
|
|
|
for ( m = 0; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( null );
|
|
|
|
|
for (m = 0; m < ps; ++m) {
|
|
|
|
|
newpoints.push(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fromgap = true;
|
|
|
|
|
@ -130,35 +130,35 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
|
|
|
|
|
// cases where we actually got two points
|
|
|
|
|
|
|
|
|
|
px = points[ i ];
|
|
|
|
|
py = points[ i + 1 ];
|
|
|
|
|
qx = otherpoints[ j ];
|
|
|
|
|
qy = otherpoints[ j + 1 ];
|
|
|
|
|
px = points[i];
|
|
|
|
|
py = points[i + 1];
|
|
|
|
|
qx = otherpoints[j];
|
|
|
|
|
qy = otherpoints[j + 1];
|
|
|
|
|
bottom = 0;
|
|
|
|
|
|
|
|
|
|
if ( px === qx ) {
|
|
|
|
|
if (px === qx) {
|
|
|
|
|
|
|
|
|
|
for ( m = 0; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( points[ i + m ] );
|
|
|
|
|
for (m = 0; m < ps; ++m) {
|
|
|
|
|
newpoints.push(points[i + m]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//newpoints[ l + 1 ] += qy;
|
|
|
|
|
//newpoints[l + 1] += qy;
|
|
|
|
|
bottom = qy;
|
|
|
|
|
|
|
|
|
|
i += ps;
|
|
|
|
|
j += otherps;
|
|
|
|
|
|
|
|
|
|
} else if ( px > qx ) {
|
|
|
|
|
} else if (px > qx) {
|
|
|
|
|
|
|
|
|
|
// we got past point below, might need to
|
|
|
|
|
// insert interpolated extra point
|
|
|
|
|
|
|
|
|
|
if ( withlines && i > 0 && points[ i - ps ] != null ) {
|
|
|
|
|
intery = py + ( points[ i - ps + 1 ] - py ) * ( qx - px ) / ( points[ i - ps ] - px );
|
|
|
|
|
newpoints.push( qx );
|
|
|
|
|
newpoints.push( intery );
|
|
|
|
|
for ( m = 2; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( points[ i + m ] );
|
|
|
|
|
if (withlines && i > 0 && points[i - ps] != null) {
|
|
|
|
|
intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
|
|
|
|
|
newpoints.push(qx);
|
|
|
|
|
newpoints.push(intery);
|
|
|
|
|
for (m = 2; m < ps; ++m) {
|
|
|
|
|
newpoints.push(points[i + m]);
|
|
|
|
|
}
|
|
|
|
|
bottom = qy;
|
|
|
|
|
}
|
|
|
|
|
@ -169,20 +169,20 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
|
|
|
|
|
// if we come from a gap, we just skip this point
|
|
|
|
|
|
|
|
|
|
if ( fromgap && withlines ) {
|
|
|
|
|
if (fromgap && withlines) {
|
|
|
|
|
i += ps;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( m = 0; m < ps; ++m ) {
|
|
|
|
|
newpoints.push( points[ i + m ] );
|
|
|
|
|
for (m = 0; m < ps; ++m) {
|
|
|
|
|
newpoints.push(points[i + m]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we might be able to interpolate a point below,
|
|
|
|
|
// this can give us a better y
|
|
|
|
|
|
|
|
|
|
if ( withlines && j > 0 && otherpoints[ j - otherps ] != null ) {
|
|
|
|
|
bottom = qy + ( otherpoints[ j - otherps + 1 ] - qy ) * ( px - qx ) / ( otherpoints[ j - otherps ] - qx );
|
|
|
|
|
if (withlines && j > 0 && otherpoints[j - otherps] != null) {
|
|
|
|
|
bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//newpoints[l + 1] += bottom;
|
|
|
|
|
@ -192,28 +192,28 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
|
|
|
|
|
|
|
fromgap = false;
|
|
|
|
|
|
|
|
|
|
if ( l !== newpoints.length && withbottom ) {
|
|
|
|
|
newpoints[ l + 2 ] = bottom;
|
|
|
|
|
if (l !== newpoints.length && withbottom) {
|
|
|
|
|
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 ] ) {
|
|
|
|
|
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 + ps + m] = newpoints[l + m];
|
|
|
|
|
}
|
|
|
|
|
newpoints[ l + 1 ] = newpoints[ l - ps + 1 ];
|
|
|
|
|
newpoints[l + 1] = newpoints[l - ps + 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datapoints.points = newpoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plot.hooks.processDatapoints.push( computeFillBottoms );
|
|
|
|
|
plot.hooks.processDatapoints.push(computeFillBottoms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.plot.plugins.push({
|
|
|
|
|
|