[英]How to make an infomation button in shiny dashboard
我想在我的 shiny 應用程序中顯示一個信息按鈕,用戶可以單擊該按鈕,然后會彈出一個文本(信息)框,其中包含一些文本。 這是為了讓用戶單擊按鈕以獲取有關我的 shiny 應用程序某些部分的一般描述。
出於某種原因,我在 shiny 或 shinydashboard 中找不到它。 有誰知道我如何制作按鈕? 謝謝。
以下是使用來自shinyWidgets package 的 'dropMenu()' 和評論中建議的模態對話的 2 種可能性。 在此示例中,儀表板 header 中放置了一個按鈕,該按鈕可打開信息面板,或者可以單擊儀表板主體中的操作按鈕以顯示單獨的 window。
在儀表板 header 中放置一個按鈕將允許它持續存在,無論激活的選項卡如何。 如果需要始終訪問菜單,這可能會有所幫助。
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader( title = "app",
tags$li(class = "dropdown",
dropMenu(
dropdownButton("Info", status = 'success', icon = icon('info')),
h3(strong('Information')),
br(),
h5('This is really helpful'),
textInput('text', 'You can also put UI elements here'),
placement = "bottom",
arrow = TRUE)
)
)
,
dashboardSidebar(),
dashboardBody(actionButton('help', 'Help'))
)
server <- function(input, output) {
observeEvent(input$help,{
showModal(modalDialog(
title = "Help!",
"Information",
textInput('text2', 'You can also put UI elements here')
))
})
}
shinyApp(ui, server)
有一個整潔的 package 被構建稱為rintrojs
,它使您能夠描述 shiny 應用程序的操作,您可以將任何 object 包裝到其中。 更多示例可以在這里找到https://github.com/carlganz/rintrojs
library(shiny)
library(rintrojs)
ui <- fluidPage(
introjsUI(),
column(2,
br(),
actionButton("help", "About this Page")
),
column(2,
introBox(
selectInput("Task", label = "Select Task",choices = c("Please select","Upload","Analyze Data")),
data.step = 1,data.intro = "This is the selectInput called Task, you do xyz with this"
)
),
column(2,
introBox(
selectInput(
"breaks", "Breaks",
c("Sturges",
"Scott",
"Freedman-Diaconis",
"[Custom]" = "custom")),
data.step = 2,data.intro = "This is the selectInput called breaks, you do xyz with this"
)
),
column(2,
introBox(
sliderInput("breakCount", "Break Count", min=1, max=1000, value=10),
data.step = 3,data.intro = "This is the sliderInput called breakCount, you do xyz with this"
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
observeEvent(input$help,
introjs(session, options = list("showBullets"="false", "showProgress"="true",
"showStepNumbers"="false","nextLabel"="Next","prevLabel"="Prev","skipLabel"="Skip"))
)
}
# Run the application
shinyApp(ui = ui, server = server)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.