mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
Add some comments about some previous modifications (#6533)
This commit is contained in:
parent
ef08a243c5
commit
2443326386
@ -183,6 +183,8 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
|
||||
}
|
||||
}
|
||||
|
||||
// Series could have different timeSteps,
|
||||
// let's find the smallest one so that bars are correctly rendered.
|
||||
function getMinTimeStepOfSeries(data) {
|
||||
var min = 100000000000;
|
||||
|
||||
|
@ -21,7 +21,9 @@ function ($) {
|
||||
var initial = last*ps;
|
||||
var len = series.datapoints.points.length;
|
||||
for (var j = initial; j < len; j += ps) {
|
||||
// Special case of a non stepped line, highlight the very last point just before a null point
|
||||
if ((series.datapoints.points[initial] != null && series.datapoints.points[j] == null && ! series.lines.steps)
|
||||
//normal case
|
||||
|| series.datapoints.points[j] > posX) {
|
||||
return Math.max(j - ps, 0)/ps;
|
||||
}
|
||||
@ -58,11 +60,13 @@ function ($) {
|
||||
series = seriesList[i];
|
||||
|
||||
if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) {
|
||||
// Init value & yaxis so that it does not brake series sorting
|
||||
results.push({ hidden: true, value: 0, yaxis: 0 });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) {
|
||||
// Init value & yaxis so that it does not brake series sorting
|
||||
results.push({ hidden: true, value: 0, yaxis: 0 });
|
||||
continue;
|
||||
}
|
||||
@ -71,6 +75,7 @@ function ($) {
|
||||
hoverDistance = pos.x - series.data[hoverIndex][0];
|
||||
pointTime = series.data[hoverIndex][0];
|
||||
|
||||
// Take the closest point before the cursor, or if it does not exist, the closest after
|
||||
if (! minDistance
|
||||
|| (hoverDistance >=0 && (hoverDistance < minDistance || minDistance < 0))
|
||||
|| (hoverDistance < 0 && hoverDistance > minDistance)) {
|
||||
@ -99,6 +104,7 @@ function ($) {
|
||||
hoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex);
|
||||
}
|
||||
|
||||
// Be sure we have a yaxis so that it does not brake series sorting
|
||||
yaxis = 0;
|
||||
if (series.yaxis) {
|
||||
yaxis = series.yaxis.n;
|
||||
@ -116,7 +122,7 @@ function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
// Find point which closer to pointer
|
||||
// Time of the point closer to pointer
|
||||
results.time = minTime;
|
||||
|
||||
return results;
|
||||
|
2
public/vendor/flot/jquery.flot.js
vendored
2
public/vendor/flot/jquery.flot.js
vendored
@ -1210,7 +1210,7 @@ Licensed under the MIT license.
|
||||
// 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 series has null values, let's give the last !null value a nice step
|
||||
if(nullify)
|
||||
points[k] = p[0];
|
||||
|
||||
|
25
public/vendor/flot/jquery.flot.stack.js
vendored
25
public/vendor/flot/jquery.flot.stack.js
vendored
@ -78,9 +78,12 @@ charts or filled areas).
|
||||
i = 0, j = 0, l, m;
|
||||
|
||||
while (true) {
|
||||
// browse all points from the current series and from the previous series
|
||||
if (i >= points.length && j >= otherpoints.length)
|
||||
break;
|
||||
|
||||
// newpoints will replace current series with
|
||||
// as many points as different timestamps we have in the 2 (current & previous) series
|
||||
l = newpoints.length;
|
||||
px = points[i + keyOffset];
|
||||
py = points[i + accumulateOffset];
|
||||
@ -89,30 +92,32 @@ charts or filled areas).
|
||||
bottom = 0;
|
||||
|
||||
if (i < points.length && px == null) {
|
||||
// ignore point
|
||||
// let's ignore null points from current series, nothing to do with them
|
||||
i += ps;
|
||||
}
|
||||
else if (j < otherpoints.length && qx == null) {
|
||||
// ignore point
|
||||
// let's ignore null points from previous series, nothing to do with them
|
||||
j += otherps;
|
||||
}
|
||||
else if (i >= points.length) {
|
||||
// take the remaining points from the previous series
|
||||
// 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)
|
||||
newpoints.push(otherpoints[j + m]);
|
||||
bottom = qy;
|
||||
j += otherps;
|
||||
}
|
||||
else if (j >= otherpoints.length) {
|
||||
// take the remaining points from the current series
|
||||
// no more points in the previous series, of course let's 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
|
||||
// next available points from current and previous series have the same timestamp
|
||||
if (px == qx) {
|
||||
// take the point from the current series and skip the previous' one
|
||||
// so take the point from the current series and skip the previous' one
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
@ -122,8 +127,9 @@ charts or filled areas).
|
||||
i += ps;
|
||||
j += otherps;
|
||||
}
|
||||
// next available point with the smallest timestamp is from the previous series
|
||||
else if (px > qx) {
|
||||
// take the point from the previous series so that the next series can stack over it
|
||||
// so take the point from the previous series so that next series will correctly stack
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(otherpoints[j + m]);
|
||||
|
||||
@ -135,8 +141,9 @@ charts or filled areas).
|
||||
|
||||
j += otherps;
|
||||
}
|
||||
else { // px < qx
|
||||
// take the point from the current series
|
||||
// (px < qx) next available point with the smallest timestamp is from the current series
|
||||
else {
|
||||
// so of course let's take the point from the current series
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user