0

I try to set a picture as tooltip.

Everything works fine with ScatterChart (I use example code from http://cran.r-project.org/web/packages/googleVis/vignettes/Using_Roles_via_googleVis.html). But when I try to use ColumnChart (or any other types) it doesn't work, I see only standard tooltip. What's the problem?

This code works:

df <- data.frame(year=1:11,pop=1:11, pop.html.tooltip=letters[1:11])
df$pop.html.tooltip[1]<-'<a href="http://www.geckoanalytics.ru"><img src="http://www.geckoanalytics.ru/images/giraf.jpg" /></a>'
plot(gvisScatterChart(df,options=list(tooltip="{isHtml:'True'}")))

This code doesn't work:

 df <- data.frame(year=1:11,pop=1:11, pop.html.tooltip=letters[1:11])
 df$pop.html.tooltip[1]<-'<a href="http://www.geckoanalytics.ru"><img src="http://www.geckoanalytics.ru/images/giraf.jpg" /></a>'
 plot(gvisColumnChart(df,options=list(tooltip="{isHtml:'True'}")))
zx8754
  • 52,746
  • 12
  • 114
  • 209

1 Answers1

2

gvisColumnChart in googleVis version: 0.4.7 has the following interface:

gvisColumnChart(data, xvar = "", yvar = "", options = list(), chartid)

To make tooltips work you need to pass a vector of column names to be plotted in the yvar argument:

plot(gvisColumnChart(df,
                     xvar='year',
                     yvar=c('pop','pop.html.tooltip'),
                     options=list(tooltip="{isHtml:'True'}")))