diff --git a/src/ui/public/vislib/lib/handler/handler.js b/src/ui/public/vislib/lib/handler/handler.js index 18aa28ab5686b..76d05d91316d6 100644 --- a/src/ui/public/vislib/lib/handler/handler.js +++ b/src/ui/public/vislib/lib/handler/handler.js @@ -116,14 +116,23 @@ export default function HandlerBaseClass(Private) { }); // render the chart(s) - selection.selectAll('.chart') - .each(function (chartData) { + let loadedCount = 0; + const chartSelection = selection.selectAll('.chart'); + chartSelection.each(function (chartData) { const chart = new self.ChartClass(self, this, chartData); self.vis.activeEvents().forEach(function (event) { self.enable(event, chart); }); + chart.events.on('rendered', () => { + loadedCount++; + if (loadedCount === chartSelection.length) { + // events from all charts are propagated to vis, we only need to fire renderComplete on one (first) + charts[0].events.emit('renderComplete'); + } + }); + charts.push(chart); chart.render(); }); diff --git a/src/ui/public/vislib/visualizations/_map.js b/src/ui/public/vislib/visualizations/_map.js index 1b138c338a33f..7d724aee693f8 100644 --- a/src/ui/public/vislib/visualizations/_map.js +++ b/src/ui/public/vislib/visualizations/_map.js @@ -211,6 +211,17 @@ export default function MapFactory(Private, tilemap, $sanitize) { this._tileLayer.on('tileload', saturateTiles); + this._tileLayer.on('load', () => { + if (!self._events) return; + + self._events.emit('rendered', { + chart: self._chartData, + map: self.map, + center: self._mapCenter, + zoom: self._mapZoom, + }); + }); + this.map.on('unload', function () { self._tileLayer.off('tileload', saturateTiles); }); diff --git a/src/ui/public/vislib/visualizations/area_chart.js b/src/ui/public/vislib/visualizations/area_chart.js index c7599800d4c25..04528482c3776 100644 --- a/src/ui/public/vislib/visualizations/area_chart.js +++ b/src/ui/public/vislib/visualizations/area_chart.js @@ -365,6 +365,10 @@ export default function AreaChartFactory(Private) { timeMarker.render(svg); } + self.events.emit('rendered', { + chart: data + }); + return svg; }); }; diff --git a/src/ui/public/vislib/visualizations/column_chart.js b/src/ui/public/vislib/visualizations/column_chart.js index 172fef57fd57b..c587025f85564 100644 --- a/src/ui/public/vislib/visualizations/column_chart.js +++ b/src/ui/public/vislib/visualizations/column_chart.js @@ -315,6 +315,10 @@ export default function ColumnChartFactory(Private) { timeMarker.render(svg); } + self.events.emit('rendered', { + chart: data + }); + return svg; }); }; diff --git a/src/ui/public/vislib/visualizations/line_chart.js b/src/ui/public/vislib/visualizations/line_chart.js index 867a503056a37..d1721c59dc63b 100644 --- a/src/ui/public/vislib/visualizations/line_chart.js +++ b/src/ui/public/vislib/visualizations/line_chart.js @@ -339,6 +339,10 @@ export default function LineChartFactory(Private) { timeMarker.render(svg); } + self.events.emit('rendered', { + chart: data + }); + return svg; }); }; diff --git a/src/ui/public/vislib/visualizations/pie_chart.js b/src/ui/public/vislib/visualizations/pie_chart.js index e3ad68584c7be..ac467990b2661 100644 --- a/src/ui/public/vislib/visualizations/pie_chart.js +++ b/src/ui/public/vislib/visualizations/pie_chart.js @@ -202,6 +202,10 @@ export default function PieChartFactory(Private) { const path = self.addPath(width, height, svg, slices); self.addPathEvents(path); + self.events.emit('rendered', { + chart: data + }); + return svg; }); };