【发布时间】:2017-11-03 14:53:21
【问题描述】:
我希望将闪亮的输出高度和宽度调整为当前窗口大小。我尝试使用以下但没有用。
ShinyUi <- fluidPage(
# Application title
titlePanel("title"),
sidebarLayout(
sidebarPanel(
... inputs ...
),
mainPanel(
plotlyOutput("distPlot", height = 'auto', width = 'auto')
)
))
ShinyServer <- function(input, output, session) {
output$distPlot <- renderPlotly({
p <- ggplot(dataShow, aes(x=dataShow$X, y=dataShow$Y)) +
geom_point(shape=1, alpha = 0.5, color = "grey50")
ggplotly(p)
})
}
# Run the application
shinyApp(ui = ShinyUi, server = ShinyServer)
您是否知道可能在服务器功能中使用任何其他选项来代替上述 UI 功能用法?
【问题讨论】:
-
你已经在使用
fluidPage()了吗? -
@BigDataScientist 请查看更新帖子中包含的代码结构。
-
shiny-plotly output height and width adjusted to the current window size是什么意思?你想让它占据你屏幕尺寸的一定比例吗? -
@SBista 它应该根据可用的窗口属性调整大小。或者换句话说,它应该一直占据窗口区域的 75%。为了更清晰的画面,我在增加浏览器窗口大小之前和之后都添加了数字。
-
一种乏味且需要
js的方法是获取窗口大小并将其传递给ggplotly函数。参考this链接获取窗口大小。
标签: r ggplot2 shiny plotly ropensci