Help on Progress/live counters for a shiny dashboard

Hi all,
I wanted to add a live counters/progress bar to my dashboard which i will be getting from a excel sheet. The excel sheet will have just the total records number . I had to get the count and add to dashboard. Above the progress bar i am displaying "Total_counts 2021" .Below the bar i should display the counts from excel sheet. Based on the counts my bar has to be displayed. I amnt sure how much will be the count by end of this year. For say if i have 5000 count as of today and 10000 by end of October the bar has to move/increase. I am not sure how i have to do this . With the below code it isnt even printing the value from excel. Can you please help on this.

library(shinydashboard)
library(shiny) # Shiny web app
library(DT) # for data tables
library(shinyWidgets)
library(dplyr)
library(readxl)
ui <- dashboardPage(
dashboardHeader(disable = TRUE),
dashboardSidebar(disable = TRUE),
dashboardBody(
fluidPage(
column(width = 3,tags$b("Total_counts 2021"), br(),
progressBar(id = "count", value = 100)),
verbatimTextOutput("num")
) ))
server <- function(input, output,session) {
tbl1 <- read_excel('test1.xlsx')
output$num <- renderPrint({
tbl1()
})}

# run the app

shinyApp(ui, server)

Please help me on this
Thank you..

  1. You need to wrap your data in a reactive()
  2. You probably don't want to use renderPrint. I put the output in a valueBox widget. For more options see:
    Shiny Dashboard Structure
library(shinydashboard)
library(shiny) # Shiny web app
library(DT) # for data tables
library(shinyWidgets)
library(dplyr)
library(readxl)

ui <- dashboardPage(
  dashboardHeader(disable = TRUE),
  dashboardSidebar(disable = TRUE),
  dashboardBody(
    fluidPage(
      valueBoxOutput("total_counts")
    )
  )
)
  
  server <- function(input, output, session) {
    data <- reactive({
      sum(mtcars$mpg) #data <- read_excel('test1.xlsx') 
    })
    
    output$total_counts <- renderValueBox({
      valueBox(
        data(),
        "Total Counts 2021"
      )
    })
  }
  
shinyApp(ui, server)

Thank you for your response. when i run your code it works fine. But I replaced mtcars data set with my excel sheet which just has total count in single cell.
data <- reactive({
read_excel('test1.xlsx')
})
It is not getting my count from excel.
So instead of having valuebox i just need the progress bar. Sorry i didnt explain it clearly.
Based on the counts my bar graph has to be displayed. I am not sure how much will be the count by end of this year. For say if i have 5000 count as of today and 10000 by end of October the bar has to move/increase. By the end of year it could be 30000. The bar graph has to move to the end when i run in December . For now i will be running my app manually.
when i cheeked sliderinput option we have to mention the end value right.
Sorry I am new to shiny..

image

Thank you. I got the counts reading from excel . How can i convert it to showing it as bargraph

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.