Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] PR #8372 to 5.x - adding mapLoaded event to tile_map visualization #8435

Merged
merged 1 commit into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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