Skip to content

Commit

Permalink
Tilemap should notify correctly when it is ready
Browse files Browse the repository at this point in the history
This regression was introduced when extracting tilemap from vislib.
  • Loading branch information
thomasneirynck committed Jan 16, 2017
1 parent 84662fd commit 8d0e152
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/ui/public/vis_maps/maps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import $ from 'jquery';
import d3 from 'd3';
import MapsConfigProvider from './lib/maps_config';
import TileMapChartProvider from './visualizations/tile_map';
Expand Down Expand Up @@ -91,10 +92,13 @@ export default function MapsFactory(Private) {
}

this.layout.render();
// todo: title
const self = this;
this.charts = [];
d3.select(this.el).selectAll('.chart').each(function (chartData) {


let loadedCount = 0;
const chartSelection = d3.select(this.el).selectAll('.chart');
chartSelection.each(function (chartData) {
const chart = new TileMapChart(self, this, chartData);

self.activeEvents().forEach(function (event) {
Expand All @@ -103,6 +107,13 @@ export default function MapsFactory(Private) {

self.charts.push(chart);
chart.render();

chart.events.on('rendered', function () {
loadedCount++;
if (loadedCount === chartSelection.length) {
$(self.el).trigger('renderComplete');
}
});
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/ui/public/vis_maps/visualizations/_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ export default function MapFactory(Private, tilemapSettings) {

this._tileLayer.on('tileload', saturateTiles);
this._tileLayer.on('load', () => {
if (!self._events) return;

if (!self._events) {
return;
}

self._events.emit('rendered', {
chart: self._chartData,
Expand Down

0 comments on commit 8d0e152

Please sign in to comment.