如何解决Flexdashboard - 传单不是全屏
我正在处理 uber dataset。我希望地图完全适合屏幕。这是我的代码目前的样子:
问题是,如果您启用垂直布局:滚动,则传单会产生问题。
title: "random"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
runtime: shiny
shinyApp(
fluidPage(
leafletoutput(outputId = "df_map",height = 1300),absolutePanel(
draggable = TRUE,top = "15%",left = "auto",right = "5%",class = "card",bottom = "auto",width = '20%',height = 'auto',fixed = TRUE,p(strong("Please select the parameters")),pickerInput(inputId = "BaseInput",label = "Base selection:",choices = unique(yr_2014$Base),multiple = F,options = list(`actions-Box` = TRUE),selected =unique(yr_2014$Base) ),pickerInput(inputId = "MonthInput",label = "Month selection:",choices = unique(yr_2014$month),selected = unique(yr_2014$month)),sliderInput(inputId = "DayInput","Day Selection",min=1,max=31,value=c(1,31),sep=""),sliderInput(inputId = "HourInput","Hour Selection",min=0,max=23,value=c(0,23),sep="")
)
),server = function(input,output,session) {
df_maps <- reactive({
yr_2014 %>%
dplyr::filter(Base %in% input$BaseInput,month %in% input$MonthInput,day >= input$DayInput[1],day <= input$DayInput[2],hour>=input$HourInput[1],hour<=input$HourInput[2])
})
output$df_map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addFullscreenControl(pseudoFullscreen =F) %>%
addCircles(data = df_maps(),lng = ~Lon,lat = ~Lat,weight = 15,radius = 15)
})
}
)
请告诉我如何修复它
解决方法
您可以根据自己的选择调整 height
中的 width
和 leafletOutput
。
leafletOutput(outputId = "df_map",height = 800,width = 1000),
完整代码:
library(shiny)
library(leaflet.extras)
library(shinyWidgets)
shinyApp(
fluidPage(
leafletOutput(outputId = "df_map",absolutePanel(
draggable = TRUE,top = "15%",left = "auto",right = "5%",class = "card",bottom = "auto",width = '20%',height = 'auto',fixed = TRUE,p(strong("Please select the parameters")),pickerInput(inputId = "BaseInput",label = "Base selection:",choices = unique(yr_2014$Base),multiple = F,options = list(`actions-box` = TRUE),selected =unique(yr_2014$Base) ),pickerInput(inputId = "MonthInput",label = "Month selection:",choices = unique(yr_2014$month),selected = unique(yr_2014$month)),sliderInput(inputId = "DayInput","Day Selection",min=1,max=31,value=c(1,31),sep=""),sliderInput(inputId = "HourInput","Hour Selection",min=0,max=23,value=c(0,23),sep="")
)
),server = function(input,output,session) {
df_maps <- reactive({
yr_2014 %>%
dplyr::filter(Base %in% input$BaseInput,month %in% input$MonthInput,day >= input$DayInput[1],day <= input$DayInput[2],hour>=input$HourInput[1],hour<=input$HourInput[2])
})
output$df_map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addFullscreenControl(pseudoFullscreen =F) %>%
addCircles(data = df_maps(),lng = ~Lon,lat = ~Lat,weight = 15,radius = 15)
})
}
)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。