Search code examples
rgoogle-visualizationgooglevis

Change tooltips via GoogleVis


The code below generates the graph I want to have. Except that I want to add values l to the tooltip. Currently I have no idea how to do this.

require(googleVis)

df <-  data.frame(x = c(1:5), y = c(10, 20 , 30, 40, 50), 
                  l = c("A", "B", "C", "D", "E"))

plot(gvisLineChart(df, xvar = "x", yvar = "y"))

Solution

  • I was also looking for a way to control tooltips in gvis charts. So after googling I stumbled upon this site GoogleVis vignette: Using Roles via googleVis. So it seems this issue has been fixed.

    Just took me a while to get this working for different chart types. Also when laying out your data, make sure it has columns alternating between, say, data and tooltips, data and tooltips,... that way it is possible to customize tooltips for multiple columns (it does not work if you just append - à la cbind - a set of tooltips columns to your data frame).