So I’m basically trying to embed a Google Visualization chart within a Fancybox (JS pop-up). The chart shows correctly on the page.. but not within the fancybox. Any ideas?
Here’s the code i’m using
$(".class").fancybox(function() {
drawChart();
});
— edit —
$(".view_research").fancybox({
'onStart' : drawChart
});
** this edit does not work either, but at least uses one of the arguments allowed by fancybox
The fancybox loading image is displayed when I click the link.. but the actual pop-up never loads.
I should also note that if I remove the Google chart from the page that the pop-up is trying to load, the pop-up loads without a hitch.
Thanks in advance,
Phil
In order to get this to work you need to:
onCompleteoption of the fancybox callIt’s common enough with gviz for the div to be visible/drawn before trying to put a chart in it, else you can end up with some pretty odd looking charts (not sure what goes on when you try to render a chart in an invisible div..). The onComplete takes care of this. Using the gviz image library is a good workaround for that problem in other cases.
Anyway, here’s a working example of using fancybox and gviz (pie chart code taken from google code playground):