Tôi muốn sử dụng khuôn khổ reactiveValue
, observe
, observeEvent
trong shiny
và shinydashboard
để có thể reactively thay đổi màu sắc của một hộp thông tin khi nhấp vào.reactively thay đổi màu sắc của một hộp thông tin, khi một nhấp chuột hoặc di chuột qua
Tôi cũng muốn hiển thị hình ảnh với một số văn bản trong hộp bật lên khi di chuột qua hộp thông tin.
Là một cơ sở mã như một ví dụ tái sản xuất, vui lòng xem this
Nhưng mã là availible dưới đây:
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Info boxes"),
dashboardSidebar(),
dashboardBody(
# infoBoxes with fill=FALSE
fluidRow(
# A static infoBox
infoBox("New Orders", 10 * 2, icon = icon("credit-card")),
# Dynamic infoBoxes
infoBoxOutput("progressBox"),
infoBoxOutput("approvalBox")
),
# infoBoxes with fill=TRUE
fluidRow(
infoBox("New Orders", 10 * 2, icon = icon("credit-card"), fill = TRUE),
infoBoxOutput("progressBox2"),
infoBoxOutput("approvalBox2")
),
fluidRow(
# Clicking this will increment the progress amount
box(width = 4, actionButton("count", "Increment progress"))
)
)
)
server <- function(input, output) {
output$progressBox <- renderInfoBox({
infoBox(
"Progress", paste0(25 + input$count, "%"), icon = icon("list"),
color = "purple"
)
})
output$approvalBox <- renderInfoBox({
infoBox(
"Approval", "80%", icon = icon("thumbs-up", lib = "glyphicon"),
color = "yellow"
)
})
# Same as above, but with fill=TRUE
output$progressBox2 <- renderInfoBox({
infoBox(
"Progress", paste0(25 + input$count, "%"), icon = icon("list"),
color = "purple", fill = TRUE
)
})
output$approvalBox2 <- renderInfoBox({
infoBox(
"Approval", "80%", icon = icon("thumbs-up", lib = "glyphicon"),
color = "yellow", fill = TRUE
)
})
}
shinyApp(ui, server)
Là có thể?
Hi h.l.m.Sure nó là có thể. Cuối cùng, Shiny đang tạo html và bạn có thể thêm nhiều HTML/Javascript/JQuery/CSS tùy thích. Chừng nào bạn không chạy nó với Máy chủ Sáng bóng, nó cho rằng rất nhiều điều đó cho chính nó khiến bạn gần như trắng tay. Xem ví dụ: http://stackoverflow.com/questions/23599268/include-a-javascript-file-in-shiny-app hoặc http://chrisbeeley.net/?p=481 nhưng sẵn sàng cho một cuộc lặn sâu hoặc dính vào cách SHINY. – irJvV