-
Notifications
You must be signed in to change notification settings - Fork 298
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
[WIP] progress bar in infoBox #135
base: main
Are you sure you want to change the base?
Changes from 4 commits
543ee4d
53160e1
c8fe446
4613d28
c4b6eb9
f689436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, | |
|
||
#' Create an info box for the main body of a dashboard. | ||
#' | ||
#' An info box displays a large icon on the left side, and a title, value | ||
#' @description An info box displays a large icon on the left side, and a title, value | ||
#' (usually a number), and an optional smaller subtitle on the right side. Info | ||
#' boxes are meant to be placed in the main body of a dashboard. | ||
#' | ||
|
@@ -58,14 +58,18 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, | |
#' content; the icon will use the same color with a slightly darkened | ||
#' background. | ||
#' @param href An optional URL to link to. | ||
#' @param progressBar If \code{FALSE} (the default), does not add a progress bar | ||
#' below the \code{value} parameter. | ||
#' @param progressBarValue A numeric value to display in the progress bar. Must | ||
#' be between zero percent and 100 percent (without the percent sign). See examples. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could just say, "Must be between 0 and 100." |
||
#' | ||
#' @family boxes | ||
#' @seealso \code{\link{box}} for usage examples. | ||
#' | ||
#' @export | ||
infoBox <- function(title, value = NULL, subtitle = NULL, | ||
icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, | ||
fill = FALSE) { | ||
fill = FALSE, progressBar = FALSE, progressBarValue = NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be better as just a single argument, like |
||
|
||
validateColor(color) | ||
tagAssert(icon, type = "i") | ||
|
@@ -83,7 +87,12 @@ infoBox <- function(title, value = NULL, subtitle = NULL, | |
div(class = "info-box-content", | ||
span(class = "info-box-text", title), | ||
if (!is.null(value)) span(class = "info-box-number", value), | ||
if (!is.null(subtitle)) p(subtitle) | ||
# if (progressBar) div(class = "progress", div(class = "progress-bar", style = progressBarValue)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extraneous comments? |
||
# if (progressBar) div(class = "progress", div(class = "progress-bar", style = | ||
# paste0("width: ", progressBarValue, "%; height: 2px;"))), | ||
|
||
if (progressBar) div(class = "progress", progressBarValue), | ||
if (!is.null(subtitle)) span(class = "progress-description", subtitle) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
# A dashboard body with a row of infoBoxes and valueBoxes, and two rows of other boxes | ||
|
||
library(shiny) | ||
library(shinydashboard) | ||
|
||
body <- dashboardBody( | ||
|
||
# infoBoxes | ||
# infoBoxes -> first row | ||
fluidRow( | ||
infoBox( | ||
"Orders", uiOutput("orderNum2"), "Subtitle", icon = icon("credit-card") | ||
"Orders", uiOutput("orderNum2"), subtitle = "Test", icon = icon("credit-card"), | ||
progressBar = T, fill = T, progressBarValue = uiOutput("progressBarValue") | ||
), | ||
infoBox( | ||
"Approval Rating", "60%", icon = icon("line-chart"), color = "green", | ||
fill = TRUE | ||
"Approval Rating", "60%", icon = icon("line-chart"), color = "green", fill = TRUE | ||
), | ||
infoBox( | ||
"Progress", uiOutput("progress2"), icon = icon("users"), color = "purple" | ||
) | ||
), | ||
|
||
# valueBoxes | ||
# valueBoxes -> second row | ||
fluidRow( | ||
valueBox( | ||
uiOutput("orderNum"), "New Orders", icon = icon("credit-card"), | ||
|
@@ -90,6 +92,17 @@ server <- function(input, output) { | |
paste0(input$progress, "%") | ||
}) | ||
|
||
output$progressBarValue <- renderUI({ | ||
# input$progress | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra comments? |
||
# numberPercent <- paste0("width: ", input$progress, "%") | ||
# div(class = "progress", div(class = "progress-bar", style = numberPercent)) | ||
|
||
div(class = "progress-bar", style = paste0("width: ", input$progress, "%; height: 2px;")) | ||
# tagList(style = paste0("width: ", input$progress, "%; height: 2px;")) | ||
|
||
# paste0("width: ", input$progress, "%; height: 2px;") | ||
}) | ||
|
||
output$status <- renderText({ | ||
paste0("There are ", input$orders, | ||
" orders, and so the current progress is ", input$progress, "%.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is unneeded.