d3pie
d3pie copied to clipboard
Missing callback d3pie.renderingFinished
Hi there,
I`m trying to move graphs into iframe, but if I move it before it is fully rendered, d3pie could not find the graph in iframe to finish it.
It would be awesome to have a callback which will called after the d3pie chart is completed...
Thanks
Hey @ddeath - would the onload callback work for you? Do a search on this page for callbacks.onload: http://d3pie.org/#docs-api
Hi @benkeen thanks for reply, I tried that but the problem is that onload is called when svg is created. But, for example labels and lines has after creation opacity: 0 and it is transformed to opacity 1 after some time.
So when onload callback is called there is still possibility that opacity is set to 0...
Right now I am forced to do something like that:
var myInterval = setInterval(function (){
if ($('g[id$=labelGroup0-outer][style="opacity: 1;"]').length == number_of_graphs)
{
doSomething()
clearInterval(myInterval);
}
}, 100);
Yeah, bit ugly hey. But it's puzzling... looking through the code, here's the appropriate bit (see /d3pie-source/_labels.js lines 253 + 279-285):
var labelFadeInTime = (pie.options.effects.load.effect === "default") ? 400 : 1;
// ...
if (helpers.isFunction(pie.options.callbacks.onload)) {
setTimeout(function() {
try {
pie.options.callbacks.onload();
} catch (e) { }
}, labelFadeInTime);
}
So it should only fire after the labels have faded in.
Up :)