【发布时间】:2018-04-17 09:26:51
【问题描述】:
【问题讨论】:
【问题讨论】:
这类似于@LyzanderR 的答案,但使用更简单的代码并且不使用任何额外的包
library(shiny)
mycss <- "
.irs-bar,
.irs-bar-edge,
.irs-single,
.irs-grid-pol {
background: red;
border-color: red;
}
"
ui <- fluidPage(
tags$style(mycss),
sliderInput("num", "Number", 0, 10, 5)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
【讨论】:
这不是最简单的任务,但它可能会发生。您需要做的就是更改闪亮默认使用的默认引导主题的 CSS。我将使用tableHTML(允许您从 ui 中向闪亮添加 CSS 文件)向您展示要更改的 CSS:
library(tableHTML)
ui <- fluidPage(
tags$style(make_css(list('.irs-bar',
c('border-top', 'border-bottom', 'background'),
rep('red', 3)),
list('.irs-bar-edge',
c('background', 'border'),
c('red', '0px !important')),
list('.irs-single',
'background',
'red'))),
sliderInput("obs", "Number of observations:",
min = 0, max = 1000, value = 500
),
plotOutput("distPlot")
)
# Server logic
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
# Complete app with UI and server components
shinyApp(ui, server)
}
正如您在上面看到的(在make_css 函数中),您需要更改.irs-bar、.irs-bar-edge 和.irs-single 并添加您想要的任何颜色。我用的是标准的红色。如果您想了解更多信息,可以在 tableHTML::make_css here 上找到教程。
【讨论】: