Skip to content

Commit

Permalink
Merge pull request elastic#8435 from elastic/jasper/backport/8372/5.x
Browse files Browse the repository at this point in the history
[backport] PR elastic#8372 to 5.x
  • Loading branch information
ppisljar authored Sep 22, 2016
2 parents c1c9986 + c064f87 commit 4752dbb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ui/public/vislib/lib/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
11 changes: 11 additions & 0 deletions src/ui/public/vislib/visualizations/_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/vislib/visualizations/area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ export default function AreaChartFactory(Private) {
timeMarker.render(svg);
}

self.events.emit('rendered', {
chart: data
});

return svg;
});
};
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/vislib/visualizations/column_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ export default function ColumnChartFactory(Private) {
timeMarker.render(svg);
}

self.events.emit('rendered', {
chart: data
});

return svg;
});
};
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/vislib/visualizations/line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ export default function LineChartFactory(Private) {
timeMarker.render(svg);
}

self.events.emit('rendered', {
chart: data
});

return svg;
});
};
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/vislib/visualizations/pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
};
Expand Down

0 comments on commit 4752dbb

Please sign in to comment.