Most of the settings for Dygraphs are CSS style. For example, here's how we can change the default tooltip behavior. With that in mind and a bit of help for the Dygraphs annotation documentation , we can do something similar for the first question.
# answers Qaru question # http://stackoverflow.com/questions/27671576/how-can-i-get-tooltips-showing-in-dygraphs-without-annotation # on how to customize annotations library(dygraphs) # question is two parts - let handle part 1 first dygraph(presidents, main = "Presidential Approval") %>% dyAxis("y", valueRange = c(0, 100)) %>% dyAnnotation("1950-7-1", text = "Korea", tooltip = "" # this is not necessary but think it better to be specific ,cssClass = "specialAnnotation") %>% # will leave this as before dyAnnotation("1965-1-1", text = "Vietnam", tooltip = "") -> dyG #this is a hack to set css directly # dyCSS designed to read a text css file dyG$x$css = " /* if cssClass not assigned use .dygraphDefaultAnnotation */ /* !important is critical for the rules to be applied */ .specialAnnotation { overflow: visible !important; width: initial !important; } "
for the second question, here is one way to achieve this
# now for part 2 dyG = dygraph(presidents, main = "Presidential Approval") %>% dyAxis("y", valueRange = c(0, 100)) tooltips = list( list(x = "1950-7-1", tooltip = "", text = "Korea") ,list(x = "1965-1-1", tooltip = "", text = "Vietnam") ) annotator <- function(x,y){ d = do.call(dyAnnotation,modifyList(list(dygraph=x),y)) return(d) } dyG = Reduce( annotator, tooltips, init=dyG )
timelyportfolio
source share