Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hit counters to histogram #29

Merged
merged 1 commit into from
Apr 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions panels/histogram/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<div>
<span ng-repeat='series in legend' style='display:inline-block;padding-right:5px'>
<div style="display:inline-block;background:{{series.color}};height:10px;width:10px"></div>
<div class='small' style='display:inline-block'>{{series.label}} / {{panel.interval}}</div>
</span>
<div class='small' style='display:inline-block'>{{series.label}} ({{series.hits}})</div>
</span><span class="small"> per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> total)</span>
</div>
<div histogram params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
</kibana-panel>
12 changes: 8 additions & 4 deletions panels/histogram/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ angular.module('kibana.histogram', [])
.field($scope.time.field)
.interval($scope.panel.interval)
.facetFilter($scope.ejs.QueryFilter(v))
)
.facet($scope.ejs.QueryFacet("query"+_.indexOf(queries,v)).query(v)
).size(0)
})

Expand All @@ -101,30 +99,36 @@ angular.module('kibana.histogram', [])
// If this isn't a date histogram it must be a QueryFacet, get the
// count and return
if(v._type !== 'date_histogram') {
$scope.hits += v.count;
//$scope.hits += v.count;
return
}

// Null values at each end of the time range ensure we see entire range
if(_.isUndefined($scope.data[i]) || _segment == 0) {
var data = [[$scope.time.from.getTime(), null],[$scope.time.to.getTime(), null]];
var hits = 0;
} else {
var data = $scope.data[i].data
var hits = $scope.data[i].hits
}

// Assemble segments
var segment_data = [];
_.each(v.entries, function(v, k) {
segment_data.push([v['time'],v['count']])
hits += v['count'];
$scope.hits += v['count'];
});

data.splice.apply(data,[1,0].concat(segment_data))


// Create the flot series
var series = {
data: {
label: $scope.panel.query[i].label || "query"+(parseInt(i)+1),
data: data,
hits: hits
},
};

Expand Down Expand Up @@ -255,7 +259,7 @@ angular.module('kibana.histogram', [])

scope.legend = [];
_.each(plot.getData(),function(series) {
scope.legend.push(_.pick(series,'label','color'))
scope.legend.push(_.pick(series,'label','color','hits'))
})

// Work around for missing legend at initialization
Expand Down