Skip to content

Commit

Permalink
adding rendered event to each chart and renderComplete to vis
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Sep 20, 2016
1 parent e198f41 commit 8324f5a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
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;
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');
}
});

charts.push(chart);
chart.render();
});
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vislib/visualizations/_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function MapFactory(Private, tilemap, $sanitize) {
this._tileLayer.on('load', () => {
if (!self._events) return;

self._events.emit('mapLoaded', {
self._events.emit('rendered', {
chart: self._chartData,
map: self.map,
center: self._mapCenter,
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 8324f5a

Please sign in to comment.