R 闪亮-侧边栏字幕和div()
我在我闪亮的应用程序中添加了一个“全部重置”按钮,第二个答案是。但是,重置操作按钮似乎只有在被包装在R 闪亮-侧边栏字幕和div(),r,shiny,shinyjs,R,Shiny,Shinyjs,我在我闪亮的应用程序中添加了一个“全部重置”按钮,第二个答案是。但是,重置操作按钮似乎只有在被包装在div()(原始答案没有)中时才起作用,但是当代码被包装在div()中时,我的边栏标题(橙色文本)消失。示例代码如下,如有任何帮助,将不胜感激 library(ggplot2) library(shiny) library(shinydashboard) library(shinyjs) sidebar <- dashboardSidebar( useShinyjs(), div(
div()
(原始答案没有)中时才起作用,但是当代码被包装在div()
中时,我的边栏标题(橙色文本)消失。示例代码如下,如有任何帮助,将不胜感激
library(ggplot2)
library(shiny)
library(shinydashboard)
library(shinyjs)
sidebar <- dashboardSidebar(
useShinyjs(),
div(
id = "form",
subtitle = h5("Subtitle 1", style="color:orange"),
textInput(inputId = "Init1", label = NULL, value = "1"),
subtitle = h5("Subtitle 2", style="color:orange"),
textInput(inputId = "Init2", label = "Lab1", value = "2"),
actionButton("resetAll", "Reset all")))
server <- function(input, output, session) {
observeEvent(input$resetAll, {
reset("form")})
df <- reactive({
data.frame(Nums = as.numeric(c(input$Init1, input$Init2)), y = 0)
})
output$plot2 <- renderPlot({
dat <- df()
ggplot(dat) +
geom_point(aes(x = Nums, y = y))
})}
ui <- dashboardPage(header = dashboardHeader(),
sidebar = sidebar,
body = dashboardBody(
mainPanel(plotOutput("plot2"))))
shinyApp(ui, server)
库(ggplot2)
图书馆(闪亮)
图书馆(shinydashboard)
图书馆(shinyjs)
侧边栏移除div,并使用reset(“侧边栏折叠”)
而不是reset(“表单”)
库(ggplot2)
图书馆(闪亮)
图书馆(shinydashboard)
图书馆(shinyjs)
边栏
library(ggplot2)
library(shiny)
library(shinydashboard)
library(shinyjs)
sidebar <- dashboardSidebar(
useShinyjs(),
subtitle = h5("Subtitle 1", style="color:orange"),
textInput(inputId = "Init1", label = NULL, value = "1"),
subtitle = h5("Subtitle 2", style="color:orange"),
textInput(inputId = "Init2", label = "Lab1", value = "2"),
actionButton("resetAll", "Reset all")
)
server <- function(input, output, session) {
observeEvent(input$resetAll, {
reset("sidebarCollapsed")}
)
df <- reactive({
data.frame(Nums = as.numeric(c(input$Init1, input$Init2)), y = 0)
})
output$plot2 <- renderPlot({
dat <- df()
ggplot(dat) +
geom_point(aes(x = Nums, y = y))
})}
ui <- dashboardPage(header = dashboardHeader(), sidebar = sidebar, body = dashboardBody(mainPanel(plotOutput("plot2"))))
shinyApp(ui, server)