我一直在尝试使用timevis
中的bsModal
在shinyBS
图表中创建弹出功能。我尝试从https://cran.r-project.org/web/packages/timevis/timevis.pdf阅读timevis文档,尝试使用addItem
,但无法获得想要的工作。基本上,我想单击timevis图表中的某个项目并获得一个像bsModal
创建的弹出窗口,没有必要使用bsModal
,也许可以使用Java脚本实现某些目的吗?有什么建议么?我对Javascript和R都是陌生的。下面是一些代码,作为一个timevis
图表的示例,需要向其中添加弹出窗口。
非常感谢, 丹尼尔
library(shiny)
library(timevis)
data <- data.frame(id = 1:10,
content = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
title = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
start = c("06/12/2018", "08/12/2018", "21/11/2018", "16/01/2018", "15/03/2018","09/12/2018", "20/12/2018",
"25/11/2018", "01/01/2018", "02/03/2018"))
ui <-fluidPage(
sidebarLayout(sidebarPanel(),
mainPanel(
timevisOutput("timeline")
)))
server <- function(input, output, session) {
output$timeline <- renderTimevis({
timevis(data)
})
}
shinyApp(ui = ui, server = server)
答案 0 :(得分:0)
这是使用shiny::modalDialog
和input$appts_selected
的一个选项
library(shiny)
library(timevis)
data <- data.frame(
id = 1:3,
start = c("2015-04-04", "2015-04-05 11:00:00", "2015-04-06 15:00:00"),
end = c("2015-04-08", NA, NA),
content = c("<h2>Vacation!!!</h2>", "Acupuncture", "Massage"),
style = c("color: red;", NA, NA)
)
ui <- fluidPage(
timevisOutput("appts"),
div("Selected items:", textOutput("selected", inline = TRUE)),
div("Visible window:", textOutput("window", inline = TRUE)),
tableOutput("table")
)
server <- function(input, output) {
output$appts <- renderTimevis(
timevis(
data,
options = list(editable = TRUE, multiselect = TRUE, align = "center")
)
)
observeEvent(input$appts_selected, {
showModal(modalDialog(
title = "Somewhat important message",
paste(input$appts_selected, "has been selected"),
easyClose = TRUE,
footer = NULL
))
})
}
shinyApp(ui, server)