如何将 ggvis 图表限制在其闪亮的仪表板框和列中?
How to constrain ggvis charts to their shinydashboard box and column?
我没有找到任何符合我的问题和关键字的内容。我无法让 ggvis 图表将自己限制在 shinydashboard 的给定区域。示例应用程序 (Windows 7) 显示了三个 ggvis 图,每个都超出了各自仪表板框和列的右边界 - 除非 window 非常宽..
想法?
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")
我没有找到任何符合我的问题和关键字的内容。我无法让 ggvis 图表将自己限制在 shinydashboard 的给定区域。示例应用程序 (Windows 7) 显示了三个 ggvis 图,每个都超出了各自仪表板框和列的右边界 - 除非 window 非常宽..
想法?
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")