Skip to content

Commit

Permalink
Added zoom links to histogram and zoom event to timepicker. Issue #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Mar 13, 2013
1 parent 87c0a0e commit f5302fc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
5 changes: 4 additions & 1 deletion panels/histogram/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ <h6>Query</h6>
<label class="small">Time correction</label>
<select ng-change="$emit('render')" ng-model="panel.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
</div>
<div class="span2">
<label class="small">Zoom Links</label><input type="checkbox" ng-model="panel.zoomlinks" ng-checked="panel.zoomlinks">
</div>
</div>
<h5>Panel Spy</h5>
<div class="row-fluid">
<div class="span2">
<label class="small"> Spyable </label><input type="checkbox" ng-model="panel.spyable" ng-checked="panel.spyable">
<label class="small">Spyable</label><input type="checkbox" ng-model="panel.spyable" ng-checked="panel.spyable">
</div>
<div class="span9 small">
The panel spy shows 'behind the scenes' information about a panel. It can
Expand Down
4 changes: 4 additions & 0 deletions panels/histogram/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
<span ng-show="panel.spyable" style="position:absolute;right:0px;top:0px" class='panelextra pointer'>
<i bs-modal="'partials/modal.html'" class="icon-eye-open"></i>
</span>
<center ng-show='panel.zoomlinks && data'>
<a class='small' ng-click='zoom(0.5)'><i class='icon-zoom-in'></i> Zoom In</a>
<a class='small' ng-click='zoom(2)'><i class='icon-zoom-out'></i> Zoom Out</a>
</center>
<div histogram params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
</kibana-panel>
21 changes: 14 additions & 7 deletions panels/histogram/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ angular.module('kibana.histogram', [])

// Set and populate defaults
var _d = {
query : [ {query: "*", label:"Query"} ],
interval: secondsToHms(calculate_interval($scope.from,$scope.to,40,0)/1000),
show : ['bars','y-axis','x-axis','legend'],
fill : 3,
timezone: 'browser', // browser, utc or a standard timezone
spyable : true,
group : "default",
query : [ {query: "*", label:"Query"} ],
interval : secondsToHms(calculate_interval($scope.from,$scope.to,40,0)/1000),
show : ['bars','y-axis','x-axis','legend'],
fill : 3,
timezone : 'browser', // browser, utc or a standard timezone
spyable : true,
zoomlinks : true,
group : "default",
}
_.defaults($scope.panel,_d)

Expand Down Expand Up @@ -123,6 +124,12 @@ angular.module('kibana.histogram', [])
});
}

// function $scope.zoom
// factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan
$scope.zoom = function(factor) {
eventBus.broadcast($scope.$id,$scope.panel.group,'zoom',factor)
}

// I really don't like this function, too much dom manip. Break out into directive?
$scope.populate_modal = function(request) {
$scope.modal = {
Expand Down
17 changes: 17 additions & 0 deletions panels/timepicker/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ angular.module('kibana.timepicker', [])
$scope.time_apply()
});

eventBus.register($scope,"zoom", function(event,factor) {
var _timespan = ($scope.time.to.getTime() - $scope.time.from.getTime());
try {
if($scope.panel.mode != 'absolute') {
$scope.panel.mode = 'since'
set_timepicker(new Date($scope.time.to.getTime() - _timespan*factor),$scope.time.to)
} else {
var _center = $scope.time.to - _timespan/2
set_timepicker(new Date(_center - (_timespan*factor)/2),
new Date(_center + (_timespan*factor)/2))
}
} catch (e) {
console.log(e)
}
$scope.time_apply();
});

$scope.$on('render', function (){
$scope.time_apply();
});
Expand Down

0 comments on commit f5302fc

Please sign in to comment.