【发布时间】:2017-02-19 13:45:03
【问题描述】:
当用户将鼠标悬停在/单击数据表的行名称上时,我一直在尝试包含诸如工具提示或弹出框之类的附加信息,因此他们不必查找一些定义,我目前在不同的 tabPanel 上有。这是一个工作示例:
server.R:
library(shiny)
library(DT)
library(shinyBS)
# Define server for the Shiny app
shinyServer(function(input, output,session) {
tdata <- as.data.frame(iris)
# Render table here
output$mytable <- DT::renderDataTable(DT::datatable(
tdata[1:5,],
options = list(paging = FALSE, searching = FALSE, info = FALSE, sort = FALSE,
columnDefs=list(list(targets=1:4, class="dt-right")) ),
rownames = paste("rowname",1:5),
container = htmltools::withTags(table(
class = 'display',
thead(
tr(lapply(rep(c('ratios','name1', 'name2', 'name3','name4','name5'), 1),th))
)
))
))
}) # end of shinyServer function
ui.R:
library(shiny)
library(DT)
library(shinyBS)
shinyUI(
mainPanel(
DT::dataTableOutput("mytable")
)
)
请注意,我看到了以下讨论主题,但没有成功: R shiny mouseover text for table columns,还有 Add bootstrap tooltip to column header in shiny app 所以我在考虑 DT-package 选项中的一些东西,或者使用 shinyBS 包的东西(比如'bsTooltip')或者添加一些 HTML 或 JS。 Shiny 在数据表中似乎并不自然地支持此工具提示/弹出框功能...!?
【问题讨论】: