Commit ced5f479 by Rashid Khan

Implemented segmented loading in histogram panel

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