From 18276eddbfcca8418a7af6eed3f5a9c5849878f6 Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Mon, 15 Apr 2013 17:19:42 -0400 Subject: [PATCH] refactor facet counting metric into facet if/else --- panels/map2/module.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/panels/map2/module.js b/panels/map2/module.js index 09428dd81b8..607fcd4335c 100644 --- a/panels/map2/module.js +++ b/panels/map2/module.js @@ -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]; });