我想将闪亮的绘图缩放到窗口的高度.这个相关的SO问题仅使用绝对高度规格(以像素为单位),当a height = 100%
更为可取时.我在文档中注意到absolutePanel
可以用它的top, bottom, left, right
参数实现这一点,但是你丢失了侧面板,并且无论如何情节(缩放到宽度)似乎忽略了可用的高度.
我猜这与html怪癖有关,这意味着你需要用javascript innerHeight
变量获得高度.但我不清楚如何实现闪亮的解决方案ui.R
以利用它.感谢任何指针.
开发的基本应用程序模型:
ui.R
library(shiny)
shinyServer(
function(input, output) {
output$myplot <- renderPlot({
hist(rnorm(1000))
})
}
)
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
pageWithSidebar(
headerPanel("window height check"),
sidebarPanel(),
mainPanel(
plotOutput("myplot")
)
)
Run Code Online (Sandbox Code Playgroud)
jdh*_*son 28
使用CSS3.以视口单位http://caniuse.com/#feat=viewport-units声明您的高度.您应该能够使用height
参数声明它们plotOutput
但是shiny::validateCssUnit
不识别它们,因此您可以在样式标题中声明它们:
library(shiny)
runApp(
list(server= function(input, output) {
output$myplot <- renderPlot({
hist(rnorm(1000))
})
}
, ui = pageWithSidebar(
headerPanel("window height check"),
sidebarPanel(
tags$head(tags$style("#myplot{height:100vh !important;}"))
),
mainPanel(
plotOutput("myplot")
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
这不会在闪亮的浏览器中工作,但应该在主浏览器中正常工作.