سؤال

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"))
هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top