我想要将一个闪亮的图形缩放到窗口的高度。当height = 100%
更可取时,此related SO question仅使用以像素为单位的绝对高度规范。我在文档中注意到,absolutePanel
可以通过它的top, bottom, left, right
参数实现这一点,但是这样就失去了侧面板,而且在任何情况下,绘图(缩放到宽度时)似乎都会忽略可用高度。
我猜这与html的怪癖有关,这意味着你需要用javascript的innerHeight
变量来获取高度。但我不清楚如何在shiny中实现一个解决方案来让ui.R
利用这一点。感谢您的指点。
用于开发的基本应用模型:
ui.R
library(shiny)
shinyServer(
function(input, output) {
output$myplot <- renderPlot({
hist(rnorm(1000))
})
}
)
。R server.R
library(shiny)
pageWithSidebar(
headerPanel("window height check"),
sidebarPanel(),
mainPanel(
plotOutput("myplot")
)
)
发布于 2014-11-07 00:56:19
使用CSS3。以视口单位http://caniuse.com/#feat=viewport-units声明您的高度。您应该能够使用plotOutput
中的height
参数来声明它们,但是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")
)
)
)
)
这在闪亮的浏览器中不起作用,但在主浏览器中应该可以正常工作。
https://stackoverflow.com/questions/26782041
复制相似问题