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

adding mapLoaded event to tile_map visualization #8372

Merged
merged 3 commits into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 10 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,22 @@ export default function HandlerBaseClass(Private) {
});

// render the chart(s)
selection.selectAll('.chart')
.each(function (chartData) {
this.loadedCount = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to expose this on this? I would rather it just be local variable.

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', () => {
self.loadedCount++;
if (self.loadedCount === chartSelection.length) {
charts[0].events.emit('renderComplete');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is using charts[0] in a comment in the code? I would expect this to happen at a higher level.

}
});

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