我正在尝试调整条件面板的位置。现在,条件面板固定在浏览器的左边缘,我想将其稍微向右移动。我可以知道该怎么做吗?以下是我闪亮的应用程序的简化虚拟版。
用户界面
library(shiny)
library(dygraphs)
shinyUI(fluidPage(
titlePanel(p("Indicators (Dummy Ver.)"),
windowTitle = "Indicators"),
sidebarLayout(
conditionalPanel(condition="input.conditionedPanels==2",
tags$style(type="text/css", '#leftPanel { width:250px; float:left;}'),
id = "leftPanel",
radioButtons("timeInterval", label = h3("Time Interval"),
choices = c("Hourly","Daily"),
selected = "Hourly")
),
mainPanel(
tabsetPanel(
tabPanel("SNES", value=1,
dygraphOutput("tsPlot1"),
h3("Header"),
p("Descriptions")
),
tabPanel("MA", value=2,
dygraphOutput("tsPlot2"),
h3("Header"),
p("Descriptions")
),
id = "conditionedPanels"
)
)
)
))
服务器
library(shiny)
library(dygraphs)
library(xts)
x1 <- arima.sim(model=list(ar=c(.9,-.2)),n=100)
x2 <- arima.sim(model=list(ar=c(0.8,0.1)),n=100)
start <- as.POSIXct("2015-08-01 08:00")
interval <- 60
end <- start + as.difftime(99, units="hours")
timeSeq <- seq(from=start, by=interval*60, to=end)
shinyServer(
function(input, output){
SNES <- xts(x1, order.by = timeSeq)
names(SNES) <- c("Sentiment")
marine <- xts(x2, order.by = timeSeq)
names(SNES) <- c("Activities")
output$tsPlot1 <- renderDygraph({
dygraph(SNES,main="Sentiment",
ylab="Frequency") %>%
dyLegend(width = 760) %>%
dyRangeSelector(height = 20)
})
output$tsPlot2 <- renderDygraph({
dygraph(marine,main="Arrivals & Departures",
ylab="Frequency") %>%
dyLegend(width = 720) %>%
dyRangeSelector(height = 20)
})
}
)
@ulfelder,感谢您的建议。您的回答帮助我解决了问题。我们可以通过将条件面板的内容包装在一栏中来在浏览器边缘和文本之间创建间隙,如下面的代码所示。我们不需要添加额外的列。
sidebarLayout(
conditionalPanel(condition="input.conditionedPanels==2",
column(1,
tags$style(type="text/css", '#leftPanel { width:250px; float:left;}'),
id = "leftPanel",
radioButtons("timeInterval", label = h3("Time Interval"),
choices = c("Hourly","Daily"),
selected = "Hourly")
)
),
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句