簡體   English   中英

R Shiny:如何更改表格的背景顏色

[英]R Shiny: How to change background color of a table

我發現如何在Shiny中更改用戶界面的背景顏色。 我發現的撤銷是它還使用tableOutput顯示我正在顯示的表格的背景。 這里我展示一個虛擬的例子。

ui.R

shinyUI(pageWithSidebar(
headerPanel( “假”),
sidebarPanel(標記為$ hr()),

mainPanel中(

 # This is what I use to change the background color list(tags$head(tags$style("body {background-color: #ADD8E6; }"))), tableOutput("dummy") ) )) 

server.R

shinyServer(函數(輸入,輸出){output $ dummy < - renderTable({data.frame(A = 1:4,B = 2:5,C = rep(“aaa”,4))})})

我得到的就是這個

在此輸入圖像描述

我想得到什么(我使用GIMP重新創建)是

在此輸入圖像描述

謝謝大家的幫助!

已經在閃亮的谷歌群體上給出了一個解決方案:

runApp(
  list(ui = bootstrapPage(pageWithSidebar(
    headerPanel("Rummy"),
    sidebarPanel( tags$hr() ),

    mainPanel(

      tableOutput("dummy"),
      # change style:    
      tags$head(tags$style("#dummy table {background-color: red; }", media="screen", type="text/css"))
    )

  )
  )

  ,
  server = function(input, output) {
    output$dummy <- renderTable({ data.frame(A=1:4,B=2:5,C=rep("aaa",4)) }) 
  }

  )
)

我還邀請您閱讀有關閃亮的Google群組的討論,該群組展示了如何使用pander包生成html表格並將其插入閃亮的應用程序中。 這樣可以更靈活地控制樣式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM