d3pie icon indicating copy to clipboard operation
d3pie copied to clipboard

Missing callback d3pie.renderingFinished

Open ddeath opened this issue 10 years ago • 4 comments
trafficstars

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

ddeath avatar Apr 08 '15 18:04 ddeath

Hey @ddeath - would the onload callback work for you? Do a search on this page for callbacks.onload: http://d3pie.org/#docs-api

benkeen avatar Apr 22 '15 04:04 benkeen

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);

ddeath avatar Apr 22 '15 10:04 ddeath

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.

benkeen avatar Apr 23 '15 04:04 benkeen

Up :)

kobleistvan avatar Apr 05 '17 15:04 kobleistvan