本文介绍了闪亮的多个选项卡和每个选项卡中的不同侧边栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试拥有多个选项卡,每个选项卡都有自己的侧边栏,我需要在第一个选项卡中使用 selectInput
,在第二个选项卡中使用 sliderInput
.
I am trying to have multiple tabs, each tab with its own sidebar, I need selectInput
in the first tab, and sliderInput
in the second tab.
谁能帮忙?
我的代码:
ui <- fluidPage(
headerPanel("Terrorism in The World"),
sidebarPanel(
selectInput("Country", "Select Country", choices = sort(unique(mydat$Country)), selected = "Iraq")
,sliderInput("year", "Year:", min = 1968, max = 2009, value = 2009, sep='')
),
mainPanel(
tabsetPanel(
tabPanel("Map",htmlOutput("Attacks")),
tabPanel("plot",
fluidRow(
column(8, plotlyOutput("trendheatrPlot", height = "300px",width = 700)),
column(7, plotlyOutput("trendstakbarPlot", height = "300px",width = 700))
)
)
)
)
)
推荐答案
我做了一个简单的 UI 模板,你可以根据你的描述使用.我还将您的列规范从 8,7 更改为 7,5,因为闪亮的 UI 基于 12 网格系统.代码如下:
I made a simple UI template you can use based on your description. I also changed your column specification from 8,7 to 7,5 because shiny UI is based on 12 grid system. Here is the code:
library(shiny)
library(plotly)
shinyApp(
ui = fluidPage(
tabsetPanel(
tabPanel("Map", fluid = TRUE,
sidebarLayout(
sidebarPanel(selectInput("Country", "Select Country", choices = "", selected = "")),
mainPanel(
htmlOutput("Attacks")
)
)
),
tabPanel("plot", fluid = TRUE,
sidebarLayout(
sidebarPanel(sliderInput("year", "Year:", min = 1968, max = 2009, value = 2009, sep='')),
mainPanel(fluidRow(
column(7, plotlyOutput("")),
column(5, plotlyOutput(""))
)
)
)
)
)
),
server = function(input, output) {
}
)
这篇关于闪亮的多个选项卡和每个选项卡中的不同侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!