-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progress-bar function #119
Comments
Has anyone put together a render function or something that can be used to increment these progress bars? |
@jackolney use it with the |
Ah of course, perfect thanks! |
Hi @artemklevtsov, |
Thanks @artemklevtsov I've got the progress bars to render with A reproducible example is below: my library(shiny)
library(shinydashboard)
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")
tags$div(
class = "progress",
class = if (!is.null(size)) paste0("progress-", size),
class = if (vertical) "vertical",
class = if (active) "active",
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,
tags$span(class = if (!label) "sr-only", text_value)
)
)
}
progressGroup <- function(text, value, min = 0, max = value, color = "aqua") {
stopifnot(is.character(text))
stopifnot(is.numeric(value))
if (value < min || value > max)
stop(sprintf("'value' should be in the range from %d to %d.", min, max), call. = FALSE)
tags$div(
class = "progress-group",
tags$span(class = "progress-text", text),
tags$span(class = "progress-number", sprintf("%d / %d", value, max)),
prgoressBar(round(value / max * 100), color = color, size = "sm")
)
}
shinyServer(function(input,output){
# Create some REACTIVE VALUES
progressValue <- reactiveValues()
progressValue$one <- 0
progressValue$two <- 0
progressValue$three <- 0
progressValue$four <- 0
# Render UI output
output$progressOne <- renderUI({
progressGroup(text = "Sample Parameter Space", value = progressValue$one, min = 0, max = 100, color = "aqua")
})
output$progressTwo <- renderUI({
progressGroup(text = "Evaluate Simulation Error", value = progressValue$two, min = 0, max = 100, color = "red")
})
output$progressThree <- renderUI({
progressGroup(text = "Resample top 10%", value = progressValue$three, min = 0, max = 100, color = "green")
})
output$progressFour <- renderUI({
progressGroup(text = "Compile Output", value = progressValue$four, min = 0, max = 100, color = "yellow")
})
# Then on action button, allow bar to move up.
observeEvent(input$goButton, {
for(i in 1:100) {
progressValue$one <- i
progressValue$two <- i
progressValue$three <- i
progressValue$four <- i
Sys.sleep(0.1)
}
})
})
And my library(shiny)
library(shinydashboard)
shinyUI(
dashboardPage(
dashboardHeader(title = "Playground App"),
dashboardSidebar(
sidebarMenu(
id = "sideBar",
menuItem("Progress Bar", tabName = "progress", icon = icon("home", class = "fa-lg fa-fw", lib = "font-awesome"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "progress",
column(width = 8,
box(width = NULL,
status = "primary",
solidHeader = TRUE,
collapsible = TRUE,
collapsed = FALSE,
title = "Calibration",
helpText("Progress Bar Demo."),
p(strong("Goal Completion"), class = "text-center"),
uiOutput(outputId = "progressOne"),
uiOutput(outputId = "progressTwo"),
uiOutput(outputId = "progressThree"),
uiOutput(outputId = "progressFour")
)
),
column(width = 4,
box(width = NULL,
status = "warning",
solidHeader = TRUE,
title = "Button",
actionButton("goButton", "HIT ME")
)
)
)
)
)
)
)
Thanks a lot in advance! |
Hi @dmpe, are you able to provide any insight into what I am doing wrong here with regards to animating progress bars? I know Winston is particularly busy right now, and that you are doing a look of good dev work on this package (thanks for that). I'm just super keen to incorporate all the great stuff from the latest builds of AdminLTE into my dashboards. Thanks! |
Just a quick update on this. I switched to editing the shiny |
The color/vertical/etc. setting is not working as expected in
If the navpage stuff is replaced by shinydashboardboday, it works perfectly. |
Hi,
|
According this: https://almsaeedstudio.com/themes/AdminLTE/pages/UI/general.html
Output with default params:
To reproduce examples from the AdminLTE docs:
Also may be helpful to add an appropriate render and output functions.
~~
wbr.
The text was updated successfully, but these errors were encountered: