Gauge bar in Shiny

I'm building a shiny dashboard and was wondering how I'd code this gauge bar. Is there a Shiny function or JS code that can create a bar like this that is filled according to whether input data is "Not at all", "1 or 2 days", "3 or 4 days", etc.



I know that you can code up a gauge chart like this, but I wanted a bar instead of this chart.


...

Hi,

The HTML « meter »element is basically a gauge.

https://www.w3schools.com/tags/tag_meter.asp

Hi David,

That looks like what I want but I don't know how to incorporate this HTML into my shiny dashboard.

Is there a shiny function for this meter?

library(shiny)

myGauge <- function(id, label, value) {
  tagList(
    tags$label(
      `for` = id,
      label
    ),
    tags$meter(
      id = id,
      value = value
    )
  )
}

ui <- fluidPage(
  myGauge("test", "test",0.5)
)

server <- function(input, output, session) {}

shinyApp(ui, server)
1 Like

This topic was automatically closed 7 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.