Kaynağa Gözat

Missing values, stack null & missing values

benrubson 9 yıl önce
ebeveyn
işleme
c976448f6a

+ 3 - 4
public/app/plugins/panel/graph/graph_tooltip.js

@@ -78,10 +78,9 @@ function ($, _) {
         }
 
         // Highlighting multiple Points depending on the plot type
-        if (series.lines.steps || series.stack) {
-          // stacked and steppedLine plots can have series with different length.
-          // Stacked series can increase its length on each new stacked serie if null points found,
-          // to speed the index search we begin always on the last found hoverIndex.
+        if (series.lines.steps) {
+          // steppedLine plots can have series with different length.
+          // To speed the index search we begin always on the last found hoverIndex.
           hoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex);
         }
 

+ 15 - 18
public/vendor/flot/jquery.flot.js

@@ -1201,24 +1201,21 @@ Licensed under the MIT license.
                             points[k + m] = null;
                         }
                     }
-                    else {
-                        // a little bit of line specific stuff that
-                        // perhaps shouldn't be here, but lacking
-                        // better means...
-                        if (insertSteps && k > 0
-                            && points[k - ps] != null
-                            && points[k - ps] != points[k]
-                            && points[k - ps + 1] != points[k + 1]) {
-                            // copy the point to make room for a middle point
-                            for (m = 0; m < ps; ++m)
-                                points[k + ps + m] = points[k + m];
-
-                            // middle point has same y
-                            points[k + 1] = points[k - ps + 1];
-
-                            // we've added a point, better reflect that
-                            k += ps;
-                        }
+
+                    if (insertSteps && k > 0 && (!nullify || points[k-ps] != null)) {
+                        // copy the point to make room for a middle point
+                        for (m = 0; m < ps; ++m)
+                            points[k + ps + m] = points[k + m];
+
+                        // middle point has same y
+                        points[k + 1] = points[k - ps + 1] || 0;
+
+                        // if series has null values, let's give the last correct value a nice step
+                        if(nullify)
+                        	points[k] = p[0];
+
+                        // we've added a point, better reflect that
+                        k += ps;
                     }
                 }
             }

+ 34 - 62
public/vendor/flot/jquery.flot.stack.js

@@ -78,41 +78,41 @@ charts or filled areas).
                 i = 0, j = 0, l, m;
 
             while (true) {
-                if (i >= points.length)
+                if (i >= points.length && j >= otherpoints.length)
                     break;
 
                 l = newpoints.length;
-
-                if (points[i] == null) {
-                    // copy gaps
-                    for (m = 0; m < ps; ++m)
-                        newpoints.push(points[i + m]);
+                px = points[i + keyOffset];
+                py = points[i + accumulateOffset];
+                qx = otherpoints[j + keyOffset];
+                qy = otherpoints[j + accumulateOffset];
+                bottom = 0;
+
+                if (i < points.length && px == null) {
+                    // ignore point
                     i += ps;
                 }
-                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]);
-                    }
-                    i += ps;
+                else if (j < otherpoints.length && qx == null && qy == null) {
+                    // ignore point
+                    j += otherps;
                 }
-                else if (otherpoints[j] == null) {
-                    // oops, got a gap
+                else if (i >= points.length) {
+                    // take the remaining points from the previous series
                     for (m = 0; m < ps; ++m)
-                        newpoints.push(null);
-                    fromgap = true;
+                        newpoints.push(otherpoints[j + m]);
+                    bottom = qy;
                     j += otherps;
                 }
+                else if (j >= otherpoints.length) {
+                    // take the remaining points from the current series
+                    for (m = 0; m < ps; ++m)
+                        newpoints.push(points[i + m]);
+                    i += ps;
+                }
                 else {
                     // 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 || qx == null) {
+                        // take the point from the current series and skip the previous' one
                         for (m = 0; m < ps; ++m)
                             newpoints.push(points[i + m]);
 
@@ -123,54 +123,26 @@ charts or filled areas).
                         j += otherps;
                     }
                     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 + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
-                            newpoints.push(qx);
-                            newpoints.push(intery + qy);
-                            for (m = 2; m < ps; ++m)
-                                newpoints.push(points[i + m]);
-                            bottom = qy;
-                        }
+                        // take the point from the previous series so that the next series can stack over it
+                        for (m = 0; m < ps; ++m)
+                            newpoints.push(otherpoints[j + m]);
+
+                        newpoints[l]=null;
+                        bottom = qy;
 
                         j += otherps;
                     }
                     else { // px < qx
-                        if (fromgap && withlines) {
-                            // if we come from a gap, we just skip this point
-                            i += ps;
-                            continue;
-                        }
-
+                        // take the point from the current series
                         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 + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
-
-                        newpoints[l + accumulateOffset] += bottom;
-
                         i += ps;
                     }
+                }  
 
-                    fromgap = false;
-
-                    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]) {
-                    for (m = 0; m < ps; ++m)
-                        newpoints[l + ps + m] = newpoints[l + m];
-                    newpoints[l + 1] = newpoints[l - ps + 1];
-                }
+                if (l != newpoints.length && withbottom)
+                    newpoints[l + 2] = bottom;
             }
 
             datapoints.points = newpoints;