2014-02-20 3 views
12

Shiny에서 사용자 인터페이스의 배경색을 변경하는 방법을 찾았습니다. 내가 찾은 철회는 또한 내가 tableOutput으로 보여주고있는 테이블의 배경을 채색한다는 것입니다. 여기 나는 더미 예제를 보여줍니다.R Shiny : 표의 배경색을 변경하는 방법

ui.R

shinyUI (pageWithSidebar (
headerPanel ("더미"),
sidebarPanel ( 태그 $의 시간()),

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 (function (input, output) {output $ dummy < - renderTable ({ data.frame (A = 1 : 4, B = 2 : 5, C = rep ("aaa", 4)) })}는)

는 내가 얻을 것은이

enter image description here

내가있다 (나는 그것을 다시 GIMP를 사용) 좀하고 싶습니다 어떤

enter image description here

도움을 주신 모든 분들께 감사드립니다.

답변

12

해결책은 shiny google group에 주어졌다 : 나는 또한 HTML 테이블 및 삽입을 생성하는 판더에게 패키지를 사용하는 방법을 보여줍니다 반짝 구글 그룹에서이 토론을 읽는 당신을 초대

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)) }) 
    } 

) 
) 

반짝 이는 응용 프로그램에서. 이렇게하면 스타일을보다 유연하게 제어 할 수 있습니다.

+1

좋은 접근 방식이지만 테이블 오른쪽의 모든 공간을 빨간색으로 채 웁니다. 테이블 너비에 맞게 조정되는 솔루션은 무엇입니까? – Rufo

+1

@Rufo 좋은 질문입니다. jQuery에서만 테이블에 스타일을 추가 할 수 없었지만 왜 작동하지 않는지 이해할 수 없습니다. –

+1

@Rufo 지금 내 대답을 수정했습니다. –

관련 문제