r语言 - 根据tabPanel选择改变shinydashboard侧边栏的内容



我有闪亮的应用程序下面有3个不同的标签,一个侧边栏和一个右侧边栏。我希望每次移动到另一个选项卡时,两个侧边栏的内容都可以更改并显示不同的小部件。在注释出的行中,您可以看到我想要显示的不同小部件。

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shiny)

shinyApp(
ui = tags$body(class="skin-blue sidebar-mini control-sidebar-open",dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = dashboardHeader(title = "Investment Advisor Monitoring - Insider Trading",titleWidth = 450),

sidebar = dashboardSidebar(minified = F, collapsed = F,
h4("Investment Selected"),
textInput("StockTicker", "Enter Stock Symbol", value = "NFLX")
#textInput("StockTicker2", "Enter Stock Symbol 2", value = "NFLX")
#textInput("StockTicker3", "Enter Stock Symbol 3", value = "NFLX")

),
body = dashboardBody(
h3('Results'),
tabsetPanel(
tabPanel("Insider Training"),
tabPanel("Switching"),
tabPanel("Tax Loss Harvesting")

)

),
controlbar = dashboardControlbar(width = 300,
h4("Insider Trading Parameters"),              


selectInput("InsiderTradingModel", "Insider Trading Model",
c("Dynamic" = "Dynamic",
"AI based" = "AIbased"))
#selectInput("InsiderTradingModel2", "Insider Trading Model 2",
#           c("Dynamic" = "Dynamic",
#            "AI based" = "AIbased"))
#selectInput("InsiderTradingModel3", "Insider Trading Model 3",
#           c("Dynamic" = "Dynamic",
#            "AI based" = "AIbased"))
),
title = "DashboardPage"
)),
server = function(input, output) { 

}
)

也许你正在寻找这样的东西

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = tags$body(class="skin-blue sidebar-mini control-sidebar-open",dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = dashboardHeader(title = "Investment Advisor Monitoring - Insider Trading",titleWidth = 450),

sidebar = dashboardSidebar(minified = F, collapsed = F,
h4("Investment Selected"),
uiOutput("mytab11"), uiOutput("mytab12")

#textInput("StockTicker3", "Enter Stock Symbol 3", value = "AMZN")
),
body = dashboardBody(
h3('Results'),
tabsetPanel(id = "tabs",
tabPanel("InsiderTraining"),
tabPanel("Switching"),
tabPanel("Tax Loss Harvesting")
)
),
controlbar = dashboardControlbar(width = 300,
h4("Insider Trading Parameters"),              
uiOutput("mytab21"), uiOutput("mytab22")

#selectInput("InsiderTradingModel3", "Insider Trading Model 3",
#           c("Dynamic" = "Dynamic",
#            "AI based" = "AIbased"))
),
title = "DashboardPage"
)),
server = function(input, output) { 

output$mytab11 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="InsiderTraining"',
textInput("StockTicker", "Enter Stock Symbol", value = "NFLX"),
sliderInput('periods','Periods',min=1,max=120,value=60),
selectInput("mtvar", "Choose a variable", choices = colnames(mtcars))
))
})
output$mytab12 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
textInput("StockTicker2", "Enter Stock Symbol", value = "APPL"),
selectInput("cvar", "Choose a variable", choices = colnames(cars))
))
})      

output$mytab21 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="InsiderTraining"',
selectInput("InsiderTradingModel", "Insider Trading Model",
c("Dynamic" = "Dynamic",
"AI based" = "AIbased")),
#textInput("StockTicker", "Enter Stock Symbol", value = "NFLX"),
selectInput("ivar", "Choose a variable", choices = colnames(iris))
))
})
output$mytab22 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
selectInput("InsiderTradingModel2", "Insider Trading Model 2",
c("Dynamic" = "Dynamic",
"BI based" = "BIbased")),
sliderInput('periodss','Periods',min=1,max=100,value=30),
selectInput("pvar", "Choose a variable", choices = colnames(pressure))
))
})      
}
)

相关内容

  • 没有找到相关文章

最新更新