Skip to content
Open
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
2 changes: 2 additions & 0 deletions public/lib/vectormap_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ module.controller('VectormapController', function ($scope) {
}

var geoCodeAggId = _.first(_.pluck($scope.vis.aggs.bySchemaName['segment'], 'id'));
var geoCodAgg = _.first($scope.vis.aggs.bySchemaName['segment']);
var metricsAgg = _.first($scope.vis.aggs.bySchemaName['metric']);
var buckets = resp.aggregations[geoCodeAggId] && resp.aggregations[geoCodeAggId].buckets;

$scope.filterField = geoCodAgg._opts.params.field;
$scope.data = {};

buckets.forEach(function (bucket) {
Expand Down
20 changes: 19 additions & 1 deletion public/lib/vectormap_directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ require('plugins/vectormap/lib/jvectormap/jquery-jvectormap.css');

var module = require('ui/modules').get('vectormap');

module.directive('vectormap', function () {
module.directive('vectormap', function (Private, getAppState, courier) {
function link (scope, element) {
const pushFilter = Private(require('ui/filter_bar/push_filter'))(getAppState());

function onSizeChange() {
return {
Expand Down Expand Up @@ -75,6 +76,23 @@ module.directive('vectormap', function () {

var count = _.isUndefined(scope.data[code]) ? 0 : scope.data[code];
el.html(el.html() + ": " + numeral(count).format(displayFormat(scope.options.tipNumberFormat)));
},
onRegionClick: function(event, code) {
if (!scope.$parent.filterField) {
return;
}
var count = _.isUndefined(scope.data[code]) ? 0 : scope.data[code];
if (count !== 0) {
courier.indexPatterns.getIds().then(function (indices) {
const field = scope.$parent.filterField;
const filter = {"match" : {}};
filter.match[field] = code;

for(var i = 0; i < indices.length; i++) {
pushFilter(filter, false, indices[i]);
}
});
}
}
});
});
Expand Down