首页 > 解决方案 > 无法获取褪色的浮动ui对话框;不显示在闪亮

问题描述

我正在尝试在我的 R Shiny 地图上修复我的宽度。另外,我没有成功让面板褪色。我要复制的宽度和褪色面板位于此链接:

https://shiny.rstudio.com/gallery/superzip-example.html

我正在使用他们的样式 css 文件,此链接: https ://github.com/rstudio/shiny-examples/blob/master/063-superzip-example/styles.css

我已经写了我的代码:

library(shiny)
library(tidyverse)
library(leaflet.extras)
library(leaflet)
library(RColorBrewer)
library(scales)
library(lattice)
library(dplyr)


fake_data <- read.csv("https://raw.githubusercontent.com/gabrielburcea/stackoverflow_fake_data/master/gather_divided.csv")


# Define UI for application that draws a histogram
ui <- fluidPage(
    
    navbarPage("Covid-19 Symptom Tracker", id = "nav",
                 
                 tabPanel("Interactive map", 
                          div(class = "outer",
                              tags$head(
                                  tags$link(rel = "stylesheet", type = "text/css", href = "style.css")
                                  
                             ),
                              
                              leafletOutput("map", width = "100%", height = "96vh"), #height = "99vh"
                             
                              #Floating panel 
                              absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
                                            draggable = TRUE, top = 60, left = "auto", right = 20, bottom = "auto",
                                            width = 330, height = "auto",
                                            
                                            h4("SARS-Covid-19 symptoms"),
                                            
                                            selectInput("symptom", "Select symptom", c("Chills",
                                                                                       "Cough", "Diarrhoea",
                                                                                       "Fatigue",
                                                                                       "Headache",
                                                                                       "Loss of smell and taste",
                                                                                       "Muscle ache",
                                                                                       "Nasal congestion",
                                                                                       "Nausea and vomiting",
                                                                                       "Shortness of breath",
                                                                                       "Sore throat",
                                                                                       "Sputum",
                                                                                       "Temperature")
                                            ), 
                                            tags$div(id="cite",
                                                     'Data provided by Your.md'
                                            )
                              )))
    )

)

                                            
                                            
server <- function(input, output) {
    
    filtered_data <- reactive({
        fake_data %>% 
            dplyr::filter(Symptom %in% input$symptom)
    })
    
    output$map <- renderLeaflet({
        
        leaflet() %>%
            addTiles(urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
                     attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>') %>%
            addMarkers(data = filtered_data(), clusterOptions = markerClusterOptions())
        
    })
    
}



    # Run the application 
    shinyApp(ui = ui, server = server)

我使用的 css 样式(和他们的一样)在这里: https ://github.com/gabrielburcea/stackoverflow_fake_data/blob/master/style.css

我拥有的面板是这个,它与我提供的链接中的面板明显不同:

在此处输入图像描述

标签: htmlcssshinypanel

解决方案


我得到以下输出:

输出

当我运行你的代码时。我喜欢消失的浮动对话框。标题上有一些空白,当我完全缩小时还有更多。我觉得很好。另外,我通过记事本保存了 CSS 文件。如果您通过 RStudio 保存它,我认为这不会有任何区别。


推荐阅读