Commit 291dd9bd authored by Torkel Ödegaard's avatar Torkel Ödegaard
Browse files

absolute time ranges (zoom in) works with influxdb

parent 549eeeb2
......@@ -207,8 +207,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.datasources = datasourceSrv.listOptions();
$scope.datasourceChanged();
$scope.get_data();
};
$scope.datasourceChanged = function() {
......@@ -225,12 +223,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.updateTimeRange = function () {
$scope.range = filterSrv.timeRange();
$scope.rangeUnparsed = filterSrv.timeRange(false);
$scope.resolution = ($(window).width() / ($scope.panel.span / 12)) / 2;
$scope.interval = '10m';
if ($scope.range) {
$scope.interval = kbn.secondsToHms(
kbn.calculate_interval($scope.range.from, $scope.range.to, $scope.panel.resolution, 0) / 1000
kbn.calculate_interval($scope.range.from, $scope.range.to, $scope.resolution, 0) / 1000
);
}
};
......@@ -247,7 +246,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
interval: $scope.interval,
targets: $scope.panel.targets,
format: $scope.panel.renderer === 'png' ? 'png' : 'json',
maxDataPoints: $scope.panel.span * 50,
maxDataPoints: $scope.resolution,
datasource: $scope.panel.datasource
};
......
......@@ -46,7 +46,7 @@
<ul class="grafana-segment-list" role="menu">
<li>
<a class="grafana-target-segment">
From series
from series
</a>
</li>
<li>
......@@ -59,7 +59,7 @@
</li>
<li>
<a class="grafana-target-segment">
Select
select
</a>
</li>
<li>
......@@ -72,7 +72,7 @@
</li>
<li>
<a class="grafana-target-segment">
Function
function
</a>
</li>
<li>
......@@ -88,5 +88,5 @@
</div>
<div class="editor-row" style="margin-top: 20px" ng-show="editor.index == 1">
<button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add target</button>
<button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button>
</div>
\ No newline at end of file
......@@ -86,7 +86,27 @@ function (angular, _) {
};
function getTimeFilter(options) {
return "time > now() - 6h";
var from = options.range.from;
var until = options.range.to;
if (_.isString(from)) {
return 'time > now() - ' + from.substring(4);
}
else {
from = to_utc_epoch_seconds(from);
}
if (until === 'now') {
return 'time > ' + from;
}
else {
until = to_utc_epoch_seconds(until);
return 'time > ' + from + ' and time < ' + until;
}
}
function to_utc_epoch_seconds(date) {
return (date.getTime() / 1000).toFixed(0) + 's';
}
......
Supports Markdown
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