2015-11-24 24 views
8

मान लें, मुझे एक साधारण चमकदार एप्लिकेशन मिला है और मैं साइडबार पैनल पृष्ठभूमि बदलना चाहता हूं। मैंने सीएसएस के साथ प्रयास किया है, लेकिन मैंने केवल पूरी पृष्ठभूमि को बदलने में कामयाब रहा है। क्या आप मेरी मदद कर सकते हैं?आर चमकदार - साइडबार पैनल की पृष्ठभूमि

मेरे ui.R:

library(shiny) 

    shinyUI(fluidPage(
     includeCSS("www/moj_styl.css"), 

     titlePanel("Hello Shiny!"), 

     sidebarLayout(
     sidebarPanel(
      sliderInput("bins", 
         "Number of bins:", 
         min = 1, 
         max = 50, 
         value = 30) 
     ), 

     mainPanel(
      plotOutput("distPlot") 
     ) 
    ) 
    )) 

और मेरे server.R:

library(shiny) 

    shinyServer(function(input, output) { 

     output$distPlot <- renderPlot({ 
     x <- faithful[, 2] # Old Faithful Geyser data 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 

    }) 

और moj_styl.css:

body { 
     background-color: #dec4de; 
    } 

    body, label, input, button, select { 
     font-family: 'Arial'; 
    } 

उत्तर

7

इस प्रयास करें चाहते हैं:

library(shiny) 

ui <- shinyUI(fluidPage(
    tags$head(tags$style(
    HTML(' 
     #sidebar { 
      background-color: #dec4de; 
     } 

     body, label, input, button, select { 
      font-family: "Arial"; 
     }') 
)), 
    titlePanel("Hello Shiny!"), 

    sidebarLayout(
    sidebarPanel(id="sidebar", 
     sliderInput("bins", 
        "Number of bins:", 
        min = 1, 
        max = 50, 
        value = 30) 
    ), 

    mainPanel(
     plotOutput("distPlot") 
    ) 
) 
)) 

server <- shinyServer(function(input, output) { 

    output$distPlot <- renderPlot({ 
    x <- faithful[, 2] # Old Faithful Geyser data 
    bins <- seq(min(x), max(x), length.out = input$bins + 1) 

    hist(x, breaks = bins, col = 'darkgray', border = 'white') 
    }) 

}) 

shinyApp(ui=ui,server=server) 

साइडबार से 'कॉल-SM-4' किसी अन्य attributs नहीं है जब इतना प्रारंभ आप या तो jQuery का उपयोग कर सकते हैं और कुछ तर्क यह पता लगाने के लिए कर सकते हैं कि रंग के लिए प्रोपर कॉलम कौन सा है (ताकि हम केवल साइडबार की पृष्ठभूमि सेट कर सकें), या आप कॉलम में घोंसला वाले फॉर्म को आईडी दे सकते हैं और इसकी पृष्ठभूमि को रंग सकते हैं प्रपत्र।

4

यह कहीं न कहीं एक जवाब है कि अगर मैं कर सकते हैं इसे खोजें। (मुझे पता है क्योंकि जब मैं अपने साइडबार के पृष्ठभूमि रंग को बदलना चाहता था तो मुझे जवाब मिला)। आपको जो चाहिए उसे प्राप्त करने के लिए आप tags$style() फ़ंक्शन का उपयोग कर सकते हैं। मैं ठीक से याद नहीं कर सकता अगर आप शरीर या कुएं को रंगना चाहते हैं, (जाहिर है मैंने दोनों किया), लेकिन आप अपना परिणाम प्राप्त होने तक थोड़ा सा खेल सकते हैं।

sidebarPanel(
    tags$style(".well {background-color:[your_color];}"), 
    ...) 

बाहर कर देता है तो आप सिर्फ बदलने के लिए .well

+0

मुझे लगता है कि ये लिंक हैं जो मुझे मेरे समाधान के लिए प्रेरित करते हैं: http://stackoverflow.com/questions/19777515/r-shiny-mainpanel-display-style-and-font; http://stackoverflow.com/questions/19798048/r-shiny-how-do-you-change-the-background-color-of-the-header – Benjamin

+0

शायद यह जानना अच्छा होगा कि '[]' को छोड़ना होगा और यह कि आप हेक्स-रंगों का उपयोग भी कर सकते हैं जैसे कि '# 003399' – 5th

संबंधित मुद्दे