Skip to content

Commit

Permalink
Backport PR elastic#8372
Browse files Browse the repository at this point in the history
---------

**Commit 1:**
adding mapLoaded event to tile_map visualization

* Original sha: 0f673d7c14ee9fa638b7f284f5254ef570f17c93 [formerly e198f41]
* Authored by ppisljar <[email protected]> on 2016-09-20T10:22:43Z

**Commit 2:**
adding rendered event to each chart and renderComplete to vis

* Original sha: 39530305081240930e33369de64db51fd68e7fc5 [formerly 8324f5a]
* Authored by ppisljar <[email protected]> on 2016-09-20T17:54:52Z

**Commit 3:**
fixing based on Spencers comments

* Original sha: fabc53d93bde22909ee696a5d18ce21434e0d638 [formerly b4780fe]
* Authored by ppisljar <[email protected]> on 2016-09-22T07:24:19Z


Former-commit-id: c064f87
  • Loading branch information
elastic-jasper committed Sep 22, 2016
1 parent f303ed2 commit 7de19b7
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 7de19b7

Please sign in to comment.