Skip to content

Commit

Permalink
other approach
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Feb 22, 2019
1 parent 2b8deb7 commit f83c14c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
20 changes: 7 additions & 13 deletions src/legacy/ui/public/vis/vis_types/vislib_vis_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export function VislibVisTypeProvider(Private, $rootScope, $timeout, $compile) {
return resolve();
}

this.vis.vislibVis = new vislib.Vis(this.chartEl, this.vis.params);
this.vis.vislibVis.on('brush', this.vis.API.events.brush);
this.vis.vislibVis.on('click', this.vis.API.events.filter);
this.vis.vislibVis.on('renderComplete', resolve);

this.vis.vislibVis.initVisConfig(esResponse, this.vis.getUiState());

if (this.vis.params.addLegend) {
$(this.container).attr('class', (i, cls) => {
return cls.replace(/visLib--legend-\S+/g, '');
Expand All @@ -83,20 +90,7 @@ export function VislibVisTypeProvider(Private, $rootScope, $timeout, $compile) {
this.$scope.$digest();
}

this.vis.vislibVis = new vislib.Vis(this.chartEl, this.vis.params);
this.vis.vislibVis.on('brush', this.vis.API.events.brush);
this.vis.vislibVis.on('click', this.vis.API.events.filter);
this.vis.vislibVis.on('renderComplete', resolve);
this.vis.vislibVis.render(esResponse, this.vis.getUiState());

if (this.vis.params.addLegend) {
this.$scope.refreshLegend++;
this.$scope.$digest();

// re-render after the legend is initialized to correctly take
// the legend height into account
this.vis.vislibVis.render(esResponse, this.vis.getUiState());
}
});
}

Expand Down
15 changes: 10 additions & 5 deletions src/legacy/ui/public/vislib/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export function VislibVisProvider(Private) {
hasLegend() {
return this.visConfigArgs.addLegend;
}

initVisConfig(data, uiState) {
this.data = data;

this.uiState = uiState;

this.visConfig = new VisConfig(this.visConfigArgs, this.data, this.uiState, this.el);
}

/**
* Renders the visualization
*
Expand All @@ -63,11 +72,7 @@ export function VislibVisProvider(Private) {
this._runOnHandler('destroy');
}

this.data = data;

this.uiState = uiState;

this.visConfig = new VisConfig(this.visConfigArgs, this.data, this.uiState, this.el);
this.initVisConfig(data, uiState);

this.handler = new Handler(this, this.visConfig);
this._runOnHandler('render');
Expand Down

0 comments on commit f83c14c

Please sign in to comment.