Last data update: 2014.03.03

R: Create a bootstrap tooltip
tooltipR Documentation

Create a bootstrap tooltip

Description

Create bootstrap tooltips for any HTML element to be used in shiny applications.

Usage

tooltip(refId, text, attr = NULL, animation = TRUE, delay = 100,
  html = TRUE, placement = "auto", trigger = "hover")

Arguments

refId

character (required): id of the element the tooltip is to be attached to.

text

character: Text to be displayed in the tooltip.

attr

character: Attach tooltip to all elements with attribute attr='refId'.

animation

logical: Apply a CSS fade transition to the tooltip.

delay

numeric: Delay showing and hiding the tooltip (ms).

html

logical: Insert HTML into the tooltip.

placement

character: How to position the tooltip - top | bottom | left | right | auto. When 'auto' is specified, it will dynamically reorient the tooltip. For example, if placement is 'auto left', the tooltip will display to the left when possible, otherwise it will display right.

trigger

character: How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.

Examples

# javascript code
tt <- tooltip("elementId", "This is a tooltip.")
str(tt)

# example app
## Not run: 
shinyApp(
ui = fluidPage(
  jscolorInput(inputId = "col", label = "JSColor Picker",
               value = "21BF6B", position = "right",
               mode = "HVS", close = TRUE),
  tooltip("col", "This is a JScolor widget"),

  checkboxInput("cbox", "Checkbox", FALSE),
  tooltip("cbox", "This is a checkbox"),

  checkboxGroupInput("cboxg", "Checkbox group", selected = "a",
                     choices = c("a" = "a",
                                 "b" = "b",
                                 "c" = "c")),
  tooltip("cboxg", "This is a <b>checkbox group</b>", html = TRUE),

  selectInput("select", "Selectinput", selected = "a", choices = c("a"="a", "b"="b")),
  tooltip("select", "This is a text input field", attr = "for", placement = "right"),

  passwordInput("pwIn", "Passwordinput"),
  tooltip("pwIn", "This is a password input field"),

  plotOutput("plot")
),
server = function(input, output) {
  output$plot <- renderPlot({
    plot(cars, col = input$col, cex = 2, pch = 16)
 })
})

## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RLumShiny)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RLumShiny/tooltip.Rd_%03d_medium.png", width=480, height=480)
> ### Name: tooltip
> ### Title: Create a bootstrap tooltip
> ### Aliases: tooltip
> 
> ### ** Examples
> 
> # javascript code
> tt <- tooltip("elementId", "This is a tooltip.")
> str(tt)
List of 1
 $ :List of 3
  ..$ name    : chr "head"
  ..$ attribs : list()
  ..$ children:List of 1
  .. ..$ :List of 3
  .. .. ..$ name    : chr "script"
  .. .. ..$ attribs : list()
  .. .. ..$ children:List of 1
  .. .. .. ..$ :Classes 'html', 'character'  atomic [1:1] $(window).load(function(){ $('#elementId').tooltip({ html: true, trigger: 'hover', title: 'This is a tooltip.', animation: true, delay: {'show': 100, 'hide': 100}, placement: 'auto' }); })
  .. .. .. .. .. ..- attr(*, "html")= logi TRUE
  .. .. ..- attr(*, "class")= chr "shiny.tag"
  ..- attr(*, "class")= chr "shiny.tag"
 - attr(*, "class")= chr [1:2] "shiny.tag.list" "list"
> 
> # example app
> ## Not run: 
> ##D shinyApp(
> ##D ui = fluidPage(
> ##D   jscolorInput(inputId = "col", label = "JSColor Picker",
> ##D                value = "21BF6B", position = "right",
> ##D                mode = "HVS", close = TRUE),
> ##D   tooltip("col", "This is a JScolor widget"),
> ##D 
> ##D   checkboxInput("cbox", "Checkbox", FALSE),
> ##D   tooltip("cbox", "This is a checkbox"),
> ##D 
> ##D   checkboxGroupInput("cboxg", "Checkbox group", selected = "a",
> ##D                      choices = c("a" = "a",
> ##D                                  "b" = "b",
> ##D                                  "c" = "c")),
> ##D   tooltip("cboxg", "This is a <b>checkbox group</b>", html = TRUE),
> ##D 
> ##D   selectInput("select", "Selectinput", selected = "a", choices = c("a"="a", "b"="b")),
> ##D   tooltip("select", "This is a text input field", attr = "for", placement = "right"),
> ##D 
> ##D   passwordInput("pwIn", "Passwordinput"),
> ##D   tooltip("pwIn", "This is a password input field"),
> ##D 
> ##D   plotOutput("plot")
> ##D ),
> ##D server = function(input, output) {
> ##D   output$plot <- renderPlot({
> ##D     plot(cars, col = input$col, cex = 2, pch = 16)
> ##D  })
> ##D })
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>