Ich versuche, ein Grundstück in eine Box in einer glänzenden App zu legen. Die Größe der Zeichnung ändert sich so, dass ich gerade die Höhe der Box definiere, was keine Lösung ist. Ich möchte ein vertikal scrollfähiges Diagramm, das seine Breite automatisch und die Höhe der Box der Höhe des Fensters anpasst. DieseAutomatische Anpassung der Grundstücksgröße in einem rollbaren Kasten in glänzendem
ist, was ich habe versucht:
library(shiny)
library(shinydashboard)
ui <-dashboardPage(
dashboardHeader(),
dashboardSidebar(sidebarMenu(
menuItem("Box Plot", tabName = "boxplot")
)),
dashboardBody(
tabItems(tabItem(tabName = "boxplot",
fluidPage(fluidRow(column(4),
column(8, box(title = "Box Plot", width = NULL,
solidHeader = TRUE, status = "primary", collapsible = TRUE,
plotOutput("plot1", inline=F, width="100%", height=1500), style = 'overflow-y: scroll;')
)))))))
server <- shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
x <- data.frame(matrix(rnorm(1000), ncol = 20))
input_data <- rnorm(ncol(x))
d <- data.frame(x)
plot.data <- gather(d, variable, value)
plot.data$test_data <- as.numeric(rep(input_data, each = nrow(x)))
p = ggplot(plot.data, aes(x = 0, y=value)) +
geom_boxplot() +
geom_point(aes(x = 0, y = test_data), color = "red") +
facet_wrap(~variable, scales = "free_y", switch = "y", nrow = 1) +
xlab("") + ylab("") +
theme(legend.position="none") + theme_bw() + theme(axis.text.x=element_blank(),
axis.text.y=element_text(angle=90),
axis.ticks.x=element_blank())
print(p, vp=viewport(angle=270, width = unit(3, "npc"), height = unit(0.32, "npc")))
})
})
shinyApp(ui = ui, server = server)
Dies kann durch Einstellung der Box CSS-Eigenschaften nach Ihren Bedürfnissen erfolgen. Es ist überhaupt nicht mit R verwandt. Wenn Sie beispielsweise die Höhe auf 300 px einstellen möchten, nehmen Sie diesen Code. Die restlichen Schritte können mit JavaScript/jQuery und CSS durchgeführt werden. 'box (..., style = 'display: block; width: 100%; höhe: 300px; overflow-y: scroll;')' – nilsole