I figured this out after stumbling https://github.com/mages/googleVis/issues/34
Here is how you can achieve this. It basically involves modifying the gVisTimeline call to send tooltips to generate a function.
- save the original gvis.R from the source package to your working folder ( https://cran.r-project.org/web/packages/googleVis/index.html is available)
save and load this modified version in the same folder (it adds the "tooltips" parameter to the gvisCheckTimelineData and gvisTimeline functions):
gvisTimeline <- function(data, rowlabel="", barlabel="", tooltip="", start="",end="", options=list(), chartid){ my.type <- "Timeline" dataName <- deparse(substitute(data)) my.options <- list(gvis=modifyList(list(width=600, height=200),options), dataName=dataName,data=list(rowlabel=rowlabel, barlabel=barlabel,tooltip=tooltip, start=start, end=end,allowed=c("number", "string", "date", "datetime")) ) checked.data <- gvisCheckTimelineData(data, rl=rowlabel, bl=barlabel, tt=tooltip, start=start, end=end) output <- gvisChart(type=my.type, checked.data=checked.data, options=my.options,chartid=chartid, package="timeline") return(output) } gvisCheckTimelineData <- function(data, rl, bl, tt, start, end){ if(any(c(rl, bl, tt, start, end) %in% "")) return(data) else return(data[, c(rl, bl, tt, start, end)]) }
Add tools to your timeline input (you need to call x.tooltips, where x is your event or barclab vector) and a tooltip parameter for the gVisTimeline function. Download the RJSONIO package (required for the function inside googleVis) and googleVis and enjoy the hints:
library(googleVis) library(RJSONIO) source("gvis_orig.R") source("gvis_mod_for_tooltips.R") datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)), Name=c("Washington", "Adams", "Jefferson", "Adams", "Jefferson", "Burr"), start=as.Date(x=rep(c("1789-03-29", "1797-02-03", "1801-02-03"),2)), end=as.Date(x=rep(c("1797-02-03", "1801-02-03", "1809-02-03"),2)), Position.html.tooltip=c(rep("cats",6))) Timeline <- gvisTimeline(datTL, rowlabel="Name", barlabel="Position", start="start", end="end", tooltip="Position.html.tooltip") plot(Timeline)

For HTML hints, just use the HTML code as a string in datTL (instead of "cats") and add the option line options=list(tooltip="{isHtml:'true'}") to gVisTimeline call:
library(googleVis) library(RJSONIO) source("gvis_orig.R") source("gvis_mod_for_tooltips.R") datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)), Name=c("Washington", "Adams", "Jefferson", "Adams", "Jefferson", "Burr"), start=as.Date(x=rep(c("1789-03-29", "1797-02-03", "1801-02-03"),2)), end=as.Date(x=rep(c("1797-02-03", "1801-02-03", "1809-02-03"),2)), Position.html.tooltip=c(rep('<a href="http://www.r-project.com"><img src="http://www.r-project.org/Rlogo.jpg" alt="R logo" /></a>',6))) Timeline <- gvisTimeline(datTL, rowlabel="Name", barlabel="Position", start="start", end="end", tooltip="Position.html.tooltip", options=list(tooltip="{isHtml:'true'}")) plot(Timeline)

Respectfully,
Sandro
source share