Commit 322fa427 by Rashid Khan

Added scale-to-seconds transformation

parent baabc298
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
<input type="text" class="input-mini" ng-model="panel.scale"> <input type="text" class="input-mini" ng-model="panel.scale">
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Seconds <tip>Normalize intervals to per-second</tip></label><input type="checkbox" ng-model="panel.scaleSeconds" ng-checked="panel.scaleSeconds">
</div>
<div class="editor-option">
<label class="small">Derivative <tip>Plot the change per interval in the series</tip></label><input type="checkbox" ng-model="panel.derivative" ng-checked="panel.derivative" ng-change="set_refresh(true)"> <label class="small">Derivative <tip>Plot the change per interval in the series</tip></label><input type="checkbox" ng-model="panel.derivative" ng-checked="panel.derivative" ng-change="set_refresh(true)">
</div> </div>
</div> </div>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<span ng-show="panel.legend_counts"> ({{series.hits}})</span> <span ng-show="panel.legend_counts"> ({{series.hits}})</span>
</span> </span>
</span> </span>
<span ng-show="panel.legend" class="small"><span ng-show="panel.derivative">change in </span><span class="strong" ng-show="panel.value_field && panel.mode != 'count'">{{panel.value_field}}</span> {{panel.mode}} per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> hits)</span> <span ng-show="panel.legend" class="small"><span ng-show="panel.derivative">change in </span><span class="strong" ng-show="panel.value_field && panel.mode != 'count'">{{panel.value_field}}</span> {{panel.mode}} per <strong ng-hide="panel.scaleSeconds">{{panel.interval}}</strong><strong ng-show="panel.scaleSeconds">1s</strong> | (<strong>{{hits}}</strong> hits)</span>
</div> </div>
<form class="form-inline bordered histogram-options" ng-show="options"> <form class="form-inline bordered histogram-options" ng-show="options">
<span> <span>
......
...@@ -438,6 +438,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -438,6 +438,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}); });
}; };
var scaleSeconds = function(series,interval) {
return _.map(series,function(p) {
return [p[0],p[1]/kbn.interval_to_seconds(interval)];
});
};
var derivative = function(series) { var derivative = function(series) {
return _.map(series, function(p,i) { return _.map(series, function(p,i) {
var _v; var _v;
...@@ -565,6 +571,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -565,6 +571,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
if(scope.panel.scale !== 1) { if(scope.panel.scale !== 1) {
_d = scale(_d,scope.panel.scale); _d = scale(_d,scope.panel.scale);
} }
if(scope.panel.scaleSeconds) {
_d = scaleSeconds(_d,scope.panel.interval);
}
scope.data[i].data = _d; scope.data[i].data = _d;
} }
......
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