【发布时间】:2020-08-31 19:16:51
【问题描述】:
我想在我闪亮的应用程序中显示一个信息按钮,用户可以单击该按钮并弹出一个文本(信息)框,其中包含一些文本。这是为了让用户单击按钮以获取有关我闪亮应用程序某些部分的一般描述。
出于某种原因,我无法在闪亮或闪亮的仪表板中找到它。有谁知道我如何制作按钮?谢谢。
【问题讨论】:
-
我可能会使用样式化的模式对话框来显示信息。
标签: r shiny shinydashboard
我想在我闪亮的应用程序中显示一个信息按钮,用户可以单击该按钮并弹出一个文本(信息)框,其中包含一些文本。这是为了让用户单击按钮以获取有关我闪亮应用程序某些部分的一般描述。
出于某种原因,我无法在闪亮或闪亮的仪表板中找到它。有谁知道我如何制作按钮?谢谢。
【问题讨论】:
标签: r shiny shinydashboard
这里有两种使用 shinyWidgets 包中的 'dropMenu()' 和 cmets 中建议的 modal dialogue 的可能性。在此示例中,仪表板标题中放置了一个按钮,用于打开信息面板,或者可以单击仪表板正文中的操作按钮以打开一个单独的窗口。
在仪表板标题中放置一个按钮将允许它持续存在,而不管激活的选项卡是什么。如果需要始终访问菜单,这可能会有所帮助。
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)
【讨论】:
构建了一个名为rintrojs 的简洁包,它使您能够描述闪亮应用程序的操作,您可以将任何对象包装到其中。更多示例可以在这里找到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)
【讨论】: