mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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) {
|
function getMinTimeStepOfSeries(data) {
|
||||||
var min = 100000000000;
|
var min = 100000000000;
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@ function ($) {
|
|||||||
var initial = last*ps;
|
var initial = last*ps;
|
||||||
var len = series.datapoints.points.length;
|
var len = series.datapoints.points.length;
|
||||||
for (var j = initial; j < len; j += ps) {
|
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)
|
if ((series.datapoints.points[initial] != null && series.datapoints.points[j] == null && ! series.lines.steps)
|
||||||
|
//normal case
|
||||||
|| series.datapoints.points[j] > posX) {
|
|| series.datapoints.points[j] > posX) {
|
||||||
return Math.max(j - ps, 0)/ps;
|
return Math.max(j - ps, 0)/ps;
|
||||||
}
|
}
|
||||||
@ -58,11 +60,13 @@ function ($) {
|
|||||||
series = seriesList[i];
|
series = seriesList[i];
|
||||||
|
|
||||||
if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) {
|
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 });
|
results.push({ hidden: true, value: 0, yaxis: 0 });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) {
|
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 });
|
results.push({ hidden: true, value: 0, yaxis: 0 });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -71,6 +75,7 @@ function ($) {
|
|||||||
hoverDistance = pos.x - series.data[hoverIndex][0];
|
hoverDistance = pos.x - series.data[hoverIndex][0];
|
||||||
pointTime = 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
|
if (! minDistance
|
||||||
|| (hoverDistance >=0 && (hoverDistance < minDistance || minDistance < 0))
|
|| (hoverDistance >=0 && (hoverDistance < minDistance || minDistance < 0))
|
||||||
|| (hoverDistance < 0 && hoverDistance > minDistance)) {
|
|| (hoverDistance < 0 && hoverDistance > minDistance)) {
|
||||||
@ -99,6 +104,7 @@ function ($) {
|
|||||||
hoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex);
|
hoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Be sure we have a yaxis so that it does not brake series sorting
|
||||||
yaxis = 0;
|
yaxis = 0;
|
||||||
if (series.yaxis) {
|
if (series.yaxis) {
|
||||||
yaxis = series.yaxis.n;
|
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;
|
results.time = minTime;
|
||||||
|
|
||||||
return results;
|
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
|
// middle point has same y
|
||||||
points[k + 1] = points[k - ps + 1] || 0;
|
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)
|
if(nullify)
|
||||||
points[k] = p[0];
|
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;
|
i = 0, j = 0, l, m;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
// browse all points from the current series and from the previous series
|
||||||
if (i >= points.length && j >= otherpoints.length)
|
if (i >= points.length && j >= otherpoints.length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// newpoints will replace current series with
|
||||||
|
// as many points as different timestamps we have in the 2 (current & previous) series
|
||||||
l = newpoints.length;
|
l = newpoints.length;
|
||||||
px = points[i + keyOffset];
|
px = points[i + keyOffset];
|
||||||
py = points[i + accumulateOffset];
|
py = points[i + accumulateOffset];
|
||||||
@ -89,30 +92,32 @@ charts or filled areas).
|
|||||||
bottom = 0;
|
bottom = 0;
|
||||||
|
|
||||||
if (i < points.length && px == null) {
|
if (i < points.length && px == null) {
|
||||||
// ignore point
|
// let's ignore null points from current series, nothing to do with them
|
||||||
i += ps;
|
i += ps;
|
||||||
}
|
}
|
||||||
else if (j < otherpoints.length && qx == null) {
|
else if (j < otherpoints.length && qx == null) {
|
||||||
// ignore point
|
// let's ignore null points from previous series, nothing to do with them
|
||||||
j += otherps;
|
j += otherps;
|
||||||
}
|
}
|
||||||
else if (i >= points.length) {
|
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)
|
for (m = 0; m < ps; ++m)
|
||||||
newpoints.push(otherpoints[j + m]);
|
newpoints.push(otherpoints[j + m]);
|
||||||
bottom = qy;
|
bottom = qy;
|
||||||
j += otherps;
|
j += otherps;
|
||||||
}
|
}
|
||||||
else if (j >= otherpoints.length) {
|
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)
|
for (m = 0; m < ps; ++m)
|
||||||
newpoints.push(points[i + m]);
|
newpoints.push(points[i + m]);
|
||||||
i += ps;
|
i += ps;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// cases where we actually got two points
|
// next available points from current and previous series have the same timestamp
|
||||||
if (px == qx) {
|
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)
|
for (m = 0; m < ps; ++m)
|
||||||
newpoints.push(points[i + m]);
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
@ -122,8 +127,9 @@ charts or filled areas).
|
|||||||
i += ps;
|
i += ps;
|
||||||
j += otherps;
|
j += otherps;
|
||||||
}
|
}
|
||||||
|
// next available point with the smallest timestamp is from the previous series
|
||||||
else if (px > qx) {
|
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)
|
for (m = 0; m < ps; ++m)
|
||||||
newpoints.push(otherpoints[j + m]);
|
newpoints.push(otherpoints[j + m]);
|
||||||
|
|
||||||
@ -135,8 +141,9 @@ charts or filled areas).
|
|||||||
|
|
||||||
j += otherps;
|
j += otherps;
|
||||||
}
|
}
|
||||||
else { // px < qx
|
// (px < qx) next available point with the smallest timestamp is from the current series
|
||||||
// take the point from the current series
|
else {
|
||||||
|
// so of course let's take the point from the current series
|
||||||
for (m = 0; m < ps; ++m)
|
for (m = 0; m < ps; ++m)
|
||||||
newpoints.push(points[i + m]);
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user