Browse Source

Missing values, keep interpolation

benrubson 9 years ago
parent
commit
07bf4c0b82
1 changed files with 13 additions and 3 deletions
  1. 13 3
      public/vendor/flot/jquery.flot.stack.js

+ 13 - 3
public/vendor/flot/jquery.flot.stack.js

@@ -92,7 +92,7 @@ charts or filled areas).
                     // ignore point
                     // ignore point
                     i += ps;
                     i += ps;
                 }
                 }
-                else if (j < otherpoints.length && qx == null && qy == null) {
+                else if (j < otherpoints.length && qx == null) {
                     // ignore point
                     // ignore point
                     j += otherps;
                     j += otherps;
                 }
                 }
@@ -111,7 +111,7 @@ charts or filled areas).
                 }
                 }
                 else {
                 else {
                     // cases where we actually got two points
                     // cases where we actually got two points
-                    if (px == qx || qx == null) {
+                    if (px == qx) {
                         // take the point from the current series and skip the previous' one
                         // 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,7 +127,10 @@ charts or filled areas).
                         for (m = 0; m < ps; ++m)
                         for (m = 0; m < ps; ++m)
                             newpoints.push(otherpoints[j + m]);
                             newpoints.push(otherpoints[j + m]);
 
 
-                        newpoints[l]=null;
+                        // we might be able to interpolate
+                        if (i > 0 && points[i - ps] != null)
+                            newpoints[l + accumulateOffset] += py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
+
                         bottom = qy;
                         bottom = qy;
 
 
                         j += otherps;
                         j += otherps;
@@ -137,6 +140,13 @@ charts or filled areas).
                         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,
+                        // this can give us a better y
+                        if (j > 0 && otherpoints[j - otherps] != null)
+                            bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
+
+                        newpoints[l + accumulateOffset] += bottom;
+
                         i += ps;
                         i += ps;
                     }
                     }
                 }  
                 }