Last active
January 29, 2016 17:36
-
-
Save artemklevtsov/d280c4343b052c2aaaef to your computer and use it in GitHub Desktop.
Bootstrap progress bar widget for the Shiny framework. Source: http://getbootstrap.com/components/#progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prgoressBar <- function(value = 0, label = FALSE, color = "aqua", size = NULL, | |
striped = FALSE, active = FALSE, vertical = FALSE) { | |
stopifnot(is.numeric(value)) | |
if (value < 0 || value > 100) | |
stop("'value' should be in the range from 0 to 100", call. = FALSE) | |
if (!(color %in% shinydashboard:::validColors || color %in% shinydashboard:::validStatuses)) | |
stop("'color' should be a valid status or color.", call. = FALSE) | |
if (!is.null(size)) | |
size <- match.arg(size, c("sm", "xs", "xxs")) | |
text_value <- paste0(value, "%") | |
if (vertical) | |
style <- htmltools::css(height = text_value, `min-height` = "2em") | |
else | |
style <- htmltools::css(width = text_value, `min-width` = "2em") | |
htmltools::tags$div( | |
class = "progress", | |
class = if (!is.null(size)) paste0("progress-", size), | |
class = if (vertical) "vertical", | |
class = if (active) "active", | |
htmltools::tags$div( | |
class = "progress-bar", | |
class = paste0("progress-bar-", color), | |
class = if (striped) "progress-bar-striped", | |
style = style, | |
role = "progressbar", | |
`aria-valuenow` = value, | |
`aria-valuemin` = 0, | |
`aria-valuemax` = 100, | |
htmltools::tags$span(class = if (!label) "sr-only", text_value) | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Examples: