gpt4 book ai didi

shiny - 如何将 ggvis 图表约束到 Shiny 的仪表板框和列?

转载 作者:行者123 更新时间:2023-12-01 09:09:58 25 4
gpt4 key购买 nike

我没有找到任何与我的问题和关键字相符的内容。我无法让 ggvis 图表将自己限制在 Shiny 仪表板的给定区域。示例应用程序 (Windows 7) 显示三个 ggvis 图,每个图都超出各自仪表板框和列的右边框 - 除非窗口非常宽。

想法?

library(shiny)
library(shinydashboard)
library(ggvis)

ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(
width = 4,
title = "fred",
ggvisOutput("plot1")
),

box(
width = 4,
title = "george",
ggvisOutput("plot2")
),

box(
width = 4,
title = "harold",
ggvisOutput("plot3")
)
)
)
)

server <- function(input, output) {
mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points() %>%
bind_shiny("plot1")

mtcars %>%
ggvis(~cyl, ~mpg) %>%
layer_points() %>%
bind_shiny("plot2")

mtcars %>%
ggvis(~disp, ~mpg) %>%
layer_points() %>%
bind_shiny("plot3")
}

shinyApp(ui, server)

最佳答案

您需要设置选项,说明宽度和高度是自动的。您可以按以下方式执行此操作:

mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points() %>%
set_options(width = "auto", height = "auto") %>%
bind_shiny("plot1")

关于shiny - 如何将 ggvis 图表约束到 Shiny 的仪表板框和列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31662632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com