Css 是否可以将ShinyWidgets中progressBar()的颜色更改为自定义颜色?
我想将progressBar()颜色从shinyWidgets更改为自定义颜色。我知道有许多默认颜色可以随状态更改,但我想将其更改为不可用的颜色 我是CSS的新手,所以我检查了git存储库本身,看看是否可以覆盖CSS。我试图用以下内容覆盖CSS(在progressBar()之前添加): 但它不起作用。Css 是否可以将ShinyWidgets中progressBar()的颜色更改为自定义颜色?,css,r,shiny,Css,R,Shiny,我想将progressBar()颜色从shinyWidgets更改为自定义颜色。我知道有许多默认颜色可以随状态更改,但我想将其更改为不可用的颜色 我是CSS的新手,所以我检查了git存储库本身,看看是否可以覆盖CSS。我试图用以下内容覆盖CSS(在progressBar()之前添加): 但它不起作用。 有人知道怎么做吗?谢谢。您的解决方案几乎可以正常工作,但是您应该修改进度条类的属性,例如: tags$head(tags$style(HTML('.progress-bar {background
有人知道怎么做吗?谢谢。您的解决方案几乎可以正常工作,但是您应该修改
进度条
类的属性,例如:
tags$head(tags$style(HTML('.progress-bar {background-color: red;}')))
我通过从中获取示例并将Sys.sleep
语句修改为60秒来发现这一点,这样我们可以更轻松地检查页面
下面给出了一个工作示例,希望对您有所帮助
server您可以使用自定义的状态
并定义相应的CSS,如下所示:
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
column(
width = 7,
tags$b("Other options"), br(),
progressBar(
id = "pb2",
value = 0,
total = 100,
title = "",
display_pct = TRUE,
status = "custom"
),
tags$style(".progress-bar-custom {background-color: #25c484;}"),
actionButton(
inputId = "go",
label = "Launch calculation"
)
)
)
server <- function(input, output, session) {
observeEvent(input$go, {
for (i in 1:100) {
updateProgressBar(
session = session,
id = "pb2",
value = i, total = 100
)
Sys.sleep(0.1)
}
})
}
shinyApp(ui = ui, server = server)
库(“闪亮”)
图书馆(“shinyWidgets”)
ui您可以添加一个最小的可复制应用程序,以便更容易测试/演示解决方案吗?当单击“启动计算”时,我得到以下错误:警告:updateProgressBar中的错误:未使用的参数(title=paste(“进程”,trunc(I/10)))
更新包?你使用哪个版本?shinyWidgets_0.4.1
谢谢,我使用开发版本,我的坏,我编辑我的答案删除这个参数很好。非常感谢。
server <- function(input, output) {
output$plot <- renderPlot({
input$goPlot # Re-run when button is clicked
# Create 0-row data frame which will be used to store data
dat <- data.frame(x = numeric(0), y = numeric(0))
withProgress(message = 'Making plot', value = 0, {
# Number of times we'll go through the loop
n <- 10
for (i in 1:n) {
# Each time through the loop, add another row of data. This is
# a stand-in for a long-running computation.
dat <- rbind(dat, data.frame(x = rnorm(1), y = rnorm(1)))
# Increment the progress bar, and update the detail text.
incProgress(1/n, detail = paste("Doing part", i))
# Pause for 0.1 seconds to simulate a long computation.
Sys.sleep(0.5)
}
})
plot(dat$x, dat$y)
})
}
ui <- shinyUI(basicPage(
tags$head(tags$style(HTML('.progress-bar {background-color: red;}'))),
plotOutput('plot', width = "300px", height = "300px"),
actionButton('goPlot', 'Go plot')
))
shinyApp(ui = ui, server = server)
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
column(
width = 7,
tags$b("Other options"), br(),
progressBar(
id = "pb2",
value = 0,
total = 100,
title = "",
display_pct = TRUE,
status = "custom"
),
tags$style(".progress-bar-custom {background-color: #25c484;}"),
actionButton(
inputId = "go",
label = "Launch calculation"
)
)
)
server <- function(input, output, session) {
observeEvent(input$go, {
for (i in 1:100) {
updateProgressBar(
session = session,
id = "pb2",
value = i, total = 100
)
Sys.sleep(0.1)
}
})
}
shinyApp(ui = ui, server = server)