![](/img/trans.png)
[英]How to display graphs one below another in the same tab in Shiny Dashboard?
[英]How to go from one tab panel to another in bs4 dashboard in shiny r
我想使用 updatebs4TabSetPanel() 使用 bs4TabSetPanel 中的單選按鈕更新選項卡面板。 我在 shiny 儀表板中多次執行此操作,但是我無法在 bs4Dash 中執行此操作。 我正在上傳示例代碼。 任何幫助是極大的贊賞。
library(shiny)
library(shinydashboard)
home<-bs4TabSetPanel(
id = "tabset1",
side = "left",
bs4TabPanel(
tabName = "Tab 1",
active = TRUE,
fluidRow(
box(radioButtons("abc", label = "Please select an option",
choices = c("Go to tab 2" = "G2", "Go to tab 3" = "G3"), selected = character()))
)
),
bs4TabPanel(
tabName = "Tab 2",
active = FALSE,
fluidRow(
h1("Welcome to tab 2")
)
),
bs4TabPanel(
tabName = "Tab 3",
active = FALSE,
fluidRow(
h1("Welcome to tab 3")
)
)
)
ui<- bs4DashPage(
navbar = bs4DashNavbar(),
sidebar = bs4DashSidebar(),
controlbar = bs4DashControlbar(),
footer = bs4DashFooter(),
title = "test",
body = bs4DashBody(
home
)
)
server<- function(input, output, session){
observeEvent(input$abc,{
if (input$abc == "G2"){
updatebs4TabSetPanel(session, "tabset1", selected = "Tab 2")
} else{
updatebs4TabSetPanel(session, "tabset1", selected = "Tab 3")
}
})
}
shinyApp(ui,server)
嗨 @Bijurika 在 bs4Dash 中,您需要使用選項卡的數字 position 而不是選項卡名稱。
這應該可行,我只是將 'selected = "Tab 2"' 更改為 'selected = 2' (對於 "Tab 3" 也是如此)
library(shiny)
library(shinydashboard)
library(bs4Dash)
home<-bs4TabSetPanel(
id = "tabset1",
side = "left",
bs4TabPanel(
tabName = "Tab 1",
active = TRUE,
fluidRow(
box(radioButtons("abc", label = "Please select an option",
choices = c("Go to tab 2" = "G2", "Go to tab 3" = "G3"), selected = character()))
)
),
bs4TabPanel(
tabName = "Tab 2",
active = FALSE,
fluidRow(
h1("Welcome to tab 2")
)
),
bs4TabPanel(
tabName = "Tab 3",
active = FALSE,
fluidRow(
h1("Welcome to tab 3")
)
)
)
ui<- bs4DashPage(
navbar = bs4DashNavbar(),
sidebar = bs4DashSidebar(),
controlbar = bs4DashControlbar(),
footer = bs4DashFooter(),
title = "test",
body = bs4DashBody(
home
)
)
server<- function(input, output, session){
observeEvent(input$abc,{
if (input$abc == "G2"){
updatebs4TabSetPanel(session, "tabset1", selected = 2)
} else{
updatebs4TabSetPanel(session, "tabset1", selected = 3)
}
})
}
shinyApp(ui,server)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.