Shiny: Gauge from flexdashboard in Shiny App

蹲街弑〆低调 提交于 2019-12-21 17:09:44

问题


Is it possible to embed the gauge from flexdashboard (picture below) in Shiny App (shinydashboard or shiny)?

The example code within a Shiny flexdashboard from the flexdashboard website:

```{r}
renderGauge({
  rate <- computeContactRate(input$region)
  gauge(rate, min = 0, max = 100, symbol = '%', gaugeSectors(
    success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
  ))
})
```

Here is my failed attempt:

library(shiny)
library(shinydashboard)
#library(flexdashboard)


ui <-dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    column(6,box(flexdashboard::gaugeOutput("plt1"),width=12,title="Gauge Graph",background ="green"))))

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

  output$plt1 <- flexdashboard::renderGauge({
      gauge(56, min = 0, max = 100, symbol = '%', label = paste("Test Label"),gaugeSectors(
        success = c(100, 6), warning = c(5,1), danger = c(0, 1), colors = c("#CC6699")
      ))

    })
})

shinyApp(ui = ui, server = server)

Thanks for any tips!


回答1:


(Posted solution on behalf of the OP).

I forgot to remove # from #library(flexdashboard), therefore the function gauge could not be find and gauge could not be rendered...



来源:https://stackoverflow.com/questions/42363577/shiny-gauge-from-flexdashboard-in-shiny-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!