Commit 2b5fa599 by Masaori Koshiba

Fix styles warned by jshint

parent ae2201ef
...@@ -29,8 +29,9 @@ function (angular, _, kbn) { ...@@ -29,8 +29,9 @@ function (angular, _, kbn) {
var queries = _.compact(_.map(options.targets, _.partial(convertTargetToQuery, options))); var queries = _.compact(_.map(options.targets, _.partial(convertTargetToQuery, options)));
var plotParams = _.compact(_.map(options.targets, function(target) { var plotParams = _.compact(_.map(options.targets, function(target) {
var alias = target.alias; var alias = target.alias;
if (typeof target.alias == 'undefined' || target.alias == "") if (typeof target.alias === 'undefined' || target.alias === "") {
alias = target.metric; alias = target.metric;
}
return !target.hide return !target.hide
? {alias: alias, ? {alias: alias,
exouter: target.exOuter} exouter: target.exOuter}
...@@ -171,8 +172,9 @@ function (angular, _, kbn) { ...@@ -171,8 +172,9 @@ function (angular, _, kbn) {
} }
}); });
details+= ") "; details+= ") ";
if (details != " ( ) ") if (details !== " ( ) ") {
target += details; target += details;
}
var datapoints = []; var datapoints = [];
for (var i = 0; i < result.values.length; i++) { for (var i = 0; i < result.values.length; i++) {
...@@ -180,8 +182,9 @@ function (angular, _, kbn) { ...@@ -180,8 +182,9 @@ function (angular, _, kbn) {
var v = result.values[i][1]; var v = result.values[i][1];
datapoints[i] = [v, t]; datapoints[i] = [v, t];
} }
if (plotParams[index].exouter) if (plotParams[index].exouter) {
datapoints = PeakFilter(datapoints, 10); datapoints = new PeakFilter(datapoints, 10);
}
output.push({ target: target, datapoints: datapoints }); output.push({ target: target, datapoints: datapoints });
}); });
index ++; index ++;
...@@ -387,28 +390,32 @@ function (angular, _, kbn) { ...@@ -387,28 +390,32 @@ function (angular, _, kbn) {
function PeakFilter(dataIn, limit) { function PeakFilter(dataIn, limit) {
var datapoints = dataIn; var datapoints = dataIn;
var arrLength = datapoints.length; var arrLength = datapoints.length;
if (arrLength <= 3) if (arrLength <= 3) {
return datapoints; return datapoints;
}
var LastIndx = arrLength - 1; var LastIndx = arrLength - 1;
// Check first point // Check first point
var prvDelta = Math.abs((datapoints[1][0] - datapoints[0][0]) / datapoints[0][0]); var prvDelta = Math.abs((datapoints[1][0] - datapoints[0][0]) / datapoints[0][0]);
var nxtDelta = Math.abs((datapoints[1][0] - datapoints[2][0]) / datapoints[2][0]); var nxtDelta = Math.abs((datapoints[1][0] - datapoints[2][0]) / datapoints[2][0]);
if (prvDelta >= limit && nxtDelta < limit) if (prvDelta >= limit && nxtDelta < limit) {
datapoints[0][0] = datapoints[1][0]; datapoints[0][0] = datapoints[1][0];
}
// Check last point // Check last point
prvDelta = Math.abs((datapoints[LastIndx - 1][0] - datapoints[LastIndx - 2][0]) / datapoints[LastIndx - 2][0]); prvDelta = Math.abs((datapoints[LastIndx - 1][0] - datapoints[LastIndx - 2][0]) / datapoints[LastIndx - 2][0]);
nxtDelta = Math.abs((datapoints[LastIndx - 1][0] - datapoints[LastIndx][0]) / datapoints[LastIndx][0]); nxtDelta = Math.abs((datapoints[LastIndx - 1][0] - datapoints[LastIndx][0]) / datapoints[LastIndx][0]);
if (prvDelta >= limit && nxtDelta < limit) if (prvDelta >= limit && nxtDelta < limit) {
datapoints[LastIndx][0] = datapoints[LastIndx - 1][0]; datapoints[LastIndx][0] = datapoints[LastIndx - 1][0];
}
for (var i = 1; i < arrLength - 1; i++) { for (var i = 1; i < arrLength - 1; i++) {
prvDelta = Math.abs((datapoints[i][0] - datapoints[i - 1][0]) / datapoints[i - 1][0]); prvDelta = Math.abs((datapoints[i][0] - datapoints[i - 1][0]) / datapoints[i - 1][0]);
nxtDelta = Math.abs((datapoints[i][0] - datapoints[i + 1][0]) / datapoints[i + 1][0]); nxtDelta = Math.abs((datapoints[i][0] - datapoints[i + 1][0]) / datapoints[i + 1][0]);
if (prvDelta >= limit && nxtDelta >= limit) if (prvDelta >= limit && nxtDelta >= limit) {
datapoints[i][0] = (datapoints[i-1][0] + datapoints[i+1][0]) / 2; datapoints[i][0] = (datapoints[i-1][0] + datapoints[i+1][0]) / 2;
} }
}
return datapoints; return datapoints;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment