Skip to content

Commit

Permalink
Fitting data should respect filters (elastic#17727) (elastic#17729)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Apr 17, 2018
1 parent e3d2c40 commit f5765da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import _ from 'lodash';
import { GeohashLayer } from './geohash_layer';
import { BaseMapsVisualizationProvider } from './base_maps_visualization';
import { SearchSourceProvider } from 'ui/courier/data_source/search_source';
import { VisAggConfigProvider } from 'ui/vis/agg_config';
import './styles/_tilemap.less';

export function CoordinateMapsVisualizationProvider(Notifier, Private) {

const AggConfig = Private(VisAggConfigProvider);
const SearchSource = Private(SearchSourceProvider);
const BaseMapsVisualization = Private(BaseMapsVisualizationProvider);

class CoordinateMapsVisualization extends BaseMapsVisualization {
Expand Down Expand Up @@ -142,8 +140,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) {
async getGeohashBounds() {
const agg = this._getGeoHashAgg();
if (agg) {
const searchSource = new SearchSource();
searchSource.index(this.vis.indexPattern);
const searchSource = this.vis.API.createInheritedSearchSource(this.vis.searchSource);
searchSource.size(0);
searchSource.aggs(function () {
const geoBoundsAgg = new AggConfig(agg.vis, {
Expand Down
6 changes: 6 additions & 0 deletions src/ui/public/vis/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export function VisProvider(Private, Promise, indexPatterns, timefilter, getAppS
const appState = getAppState();
brushEvent(appState)(event);
}
},
createInheritedSearchSource: (parentSearchSource) => {
if (!parentSearchSource) {
throw new Error('Unable to inherit search source, visualize saved object does not have search source.');
}
return new SearchSource().inherits(parentSearchSource);
}
};
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ uiModules
});

$scope.vis = $scope.savedObj.vis;
$scope.vis.searchSource = $scope.savedObj.searchSource;

// Set the passed in uiState to the vis object. uiState reference should never be changed
if (!$scope.uiState) $scope.uiState = $scope.vis.getUiState();
Expand Down

0 comments on commit f5765da

Please sign in to comment.