4

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"))
Stephen Eglen
  • 591
  • 2
  • 15
jeroen81
  • 2,305
  • 5
  • 29
  • 41
  • Have you thought about using the gvis annotated timeline? – Seth Feb 18 '13 at 17:56
  • Did this get solved? I have the same problem (with a scatter chart)? I think the underlying google api allows at, as shown by the example at: https://developers.google.com/chart/interactive/docs/customizing_tooltip_content – Stephen Eglen Oct 02 '13 at 10:24

2 Answers2

6

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

pfifas
  • 592
  • 4
  • 11
0

I couldn't find a way (yet) to do this in googleVis. rCharts is another package that interfaces with javascript tools for interactive visualisation, and there seems to be flexibility there with tooltips: e.g. http://rcharts.io/viewer/?6644957#.Uk0xQIZDvb8

I did want to use this, but then couldn't work out how to get a log scale, so have instead gone with the SVGAnnotation package for now, to provide a svg.

Stephen Eglen
  • 591
  • 2
  • 15