Closed GoogleCodeExporter closed 8 years ago
Mark,
Could you please provide an example in R which demonstrates the issue and your
solution.
Mant thanks
Markus
Original comment by markus.g...@googlemail.com
on 24 Jan 2013 at 11:26
Hi Markus,
Sorry, I probably wasn't very clear.
I just created a Google gadget as per the code below.
Column <- gvisColumnChart(df,
options=list(legend='none', width=300,
height=200))
plot(Column)
gadget <- createGoogleGadget(Column)
I used the createGoogleGadget function because I wanted an XML formatted
content, which I then return directly to the browser.
The javascript code in the browser accepts this gadget xml and gets the
contents of the the "Content" tag, which contains the html and javascript
code.
I then do a $('<id of dom element>').replaceWith(<html & javascript code
from Content tag>) and the chart is displayed on the page. Or at least it
would be if the function drawChartColumnChartID15fa166ce74() was called.
But it's not called because the google visualisation library is already
loaded (and drawChartColumnChartID15fa166ce74() is only called in the
callback of google.load)
My suggested fix is in gvis.R, where I've altered the function below to
generate the javascript code to check if google.visualization is already
loaded and if so call it.
jsDisplayChart <- '
// jsDisplayChart
function displayChart%s()
{
if (typeof google === "object" && typeof google.visualization === "object") {
drawChart%s();
} else {
google.load("visualization", "1", { packages:["%s"] %s});
google.setOnLoadCallback(drawChart%s);
}
}
'
jsDisplayChart <- sprintf(jsDisplayChart, chartid, chartid,
ifelse(!is.null(options$gvis$gvis.editor),'charteditor',
tolower(package)),
ifelse(!is.null(options$gvis$gvis.language),
paste(",'language':'",
options$gvis$gvis.language, "'", sep=""), ''),
chartid
)
Best regards
Mark
Original comment by mark.mel...@savageminds.com
on 25 Jan 2013 at 1:20
Thanks Mark, I updated gvis() with your suggestion.
Original comment by markus.g...@googlemail.com
on 26 Jan 2013 at 3:07
Thanks Markus.
BTW it's a nice package you've created.
Original comment by mark.mel...@savageminds.com
on 26 Jan 2013 at 3:44
Original issue reported on code.google.com by
mark.mel...@savageminds.com
on 24 Jan 2013 at 2:36