更改 Shiny 应用程序中内容窗格的背景颜色?

问题描述 投票:0回答:0

我使用 plotly 制作了一个闪亮的饼图应用程序。该应用程序显示有多少大豆从阿根廷罗萨里奥港出口到五十多个国家。通过在 URL 中添加“/?COUNTRY=X”来查询,并使用 iframe 显示在网站侧边栏中。一切正常,除了我网站的背景是黑色的,而且我无法让应用程序本身的内容面板变成黑色。 “内容窗格”是指饼图本身的背景及其下方出口商列表的背景。这些仍然是亮白色。

我已经尝试了很多东西 - 例如添加 style = "background-color: black;" 在 fluidPage 部分 - 但所建议的一切只会影响网页的背景而不影响内容窗格。工作代码如下,有人可以帮忙吗?

#### packages ####
library(plotly)
library(shiny)
library(shinythemes)


#### TO TEST LOCALLY, use "/?COUNTRY=X", eg http://localhost:PORT/?COUNTRY=CHINA (replace PORT with the appropriate port number). ####

#### load data ####
granos_exportados <- read.csv(file = "https://s3.us-east-2.amazonaws.com/ecotopia.today/Data/exportadores_rosario.csv")

#### shiny UI ####
ui <- fluidPage(theme = shinytheme("cyborg"),
  titlePanel(h3( "SOYBEANS", align = "center")),
  column(8, align="center",offset = 0,
         plotlyOutput("granos_exportados", width = "350px", height = "600px"))
)

#### shiny server or Backend ####
server <- function(input, output, session) {
  query <- reactive({ parseQueryString(session$clientData$url_search) })
  
  output$granos_exportados <- renderPlotly({
    df <- granos_exportados %>% 
      filter(COUNTRY == query()[['COUNTRY']]) %>% 
      gather(grain_exporter, quantity, -COUNTRY) %>% 
      mutate(quantity_percent = quantity/sum(quantity))
    
    plot_ly(df, labels = ~ grain_exporter, values = ~ quantity, type = 'pie',
            text = ~paste(round(quantity/1000, 2), " toneladas"), 
            textinfo = 'percent',
            textposition='inside', 
            hovertemplate = "%{label}<br>%{value:,.2f} toneladas de soja<extra></extra>",
            marker = list(colors = c("#267278","#65338D","#4770B3",'#D21F75','#383689','#50AED3','#48B24F',
                                     '#E57438','#569DD2','#569D79','#58595B','#E4B031','#84D2F4','#CAD93F',
                                     '#F5C8AF','#9AC4B3','#9E9EA2'),
                          line = list(color = '#FFFFFF', width = 1))) %>% 
      layout(title = paste("Port of Rosario to", unique(df$COUNTRY)),
             legend = list(orientation = "h",   # show entries horizontally
                           xanchor = "center",  # use center of legend as anchor
                           x = 0.5),autosize = T,xaxis = list(showticklabels = F)) %>% 
      plotly::config(displaylogo = F) %>% 
      htmlwidgets::onRender("function(el,x){el.on('plotly_legendclick', function(){ return false; })}")
  })
}

#### RUN THE APP ####
shinyApp(ui, server)

shiny background-color
© www.soinside.com 2019 - 2024. All rights reserved.