Commit ced5f479 by Rashid Khan

Implemented segmented loading in histogram panel

parent 4d375bd0
......@@ -45,13 +45,15 @@ angular.module('kibana.histogram', [])
$scope.get_data();
}
$scope.get_data = function() {
$scope.get_data = function(segment) {
// Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return
_segment = _.isUndefined(segment) ? 0 : segment
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index);
var request = $scope.ejs.Request().indices($scope.panel.index[_segment]);
// Build the question part of the query
var queries = [];
......@@ -81,25 +83,37 @@ angular.module('kibana.histogram', [])
results.then(function(results) {
$scope.panel.loading = false;
$scope.hits = results.hits.total;
if(_segment == 0)
$scope.data = [];
_.each(results.facets, function(v, k) {
// Null values at each end of the time range ensure we see entire range
if(_.isUndefined($scope.data[k]) || _segment == 0) {
var data = [[$scope.time.from.getTime(), null]];
} else {
var data = $scope.data[k].data
}
_.each(v.entries, function(v, k) {
data.push([v['time'],v['count']])
});
data.push([$scope.time.to.getTime(), null])
var series = { data: {
var series = {
data: {
label: $scope.panel.query[k].label || k,
data: data,
}};
}
};
if (!(_.isUndefined($scope.panel.query[k].color)))
series.data.color = $scope.panel.query[k].color;
$scope.data.push(series.data)
$scope.data[k] = series.data
});
$scope.$emit('render')
if(_segment < $scope.panel.index.length-1)
$scope.get_data(_segment+1)
});
}
......
......@@ -182,7 +182,7 @@ angular.module('kibana.timepicker', [])
// in a single object. Not sure if I like this.
if($scope.panel.timed_indices) {
indices($scope.time.from,$scope.time.to).then(function (p) {
$scope.time.index = p.join();
$scope.time.index = p;
eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)
});
} else {
......@@ -207,7 +207,7 @@ angular.module('kibana.timepicker', [])
});
return all_indices().then(function(p) {
var indices = _.intersection(p,possible);
var indices = _.intersection(possible,p);
indices.reverse();
return indices.length == 0 ? [$scope.panel.defaultindex] : indices;
})
......
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