Commit 18276edd by Zachary Tong

refactor facet counting metric into facet if/else

parent a16b38a9
......@@ -78,6 +78,8 @@ angular.module('kibana.map2', [])
var request = $scope.ejs.Request().indices($scope.panel.index);
var metric = 'count';
//Use a regular term facet if there is no secondary field
if (typeof $scope.panel.secondaryfield === "undefined") {
var facet = $scope.ejs.TermsFacet('map')
......@@ -90,6 +92,8 @@ angular.module('kibana.map2', [])
ejs.RangeFilter($scope.time.field)
.from($scope.time.from)
.to($scope.time.to))));
metric = 'count';
} else {
//otherwise, use term stats
//NOTE: this will break if valueField is a geo_point
......@@ -104,6 +108,8 @@ angular.module('kibana.map2', [])
ejs.RangeFilter($scope.time.field)
.from($scope.time.from)
.to($scope.time.to))));
metric = 'total';
}
......@@ -122,17 +128,6 @@ angular.module('kibana.map2', [])
_.each(results.facets.map.terms, function (v) {
var metric = 'count';
//If it is a Term facet, use count, otherwise use Total
//May retool this to allow users to pick mean/median/etc
if (typeof $scope.panel.secondaryfield === "undefined") {
metric = 'count';
} else {
metric = 'total';
}
//FIX THIS
if (!$scope.isNumber(v.term)) {
$scope.data[v.term.toUpperCase()] = v[metric];
......@@ -359,9 +354,11 @@ angular.module('kibana.map2', [])
var path = d3.geo.path()
.projection(scope.projection);
console.log(scope.data);
//Geocoded points are decoded into lonlat
scope.points = _.map(scope.data, function (k, v) {
//console.log(k,v);
var decoded = geohash.decode(v);
return [decoded.longitude, decoded.latitude];
});
......
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