闪亮:闪亮应用程序中来自 flexdashboard 的仪表
Shiny: Gauge from flexdashboard in Shiny App
是否可以在 Shiny
应用程序(shinydashboard
或 shiny
)中嵌入来自 flexdashboard
(下图)的仪表?
Shiny flexdashboard
中的示例代码来自 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)
))
})
```
这是我失败的尝试:
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)
感谢任何提示!
(代表OP发布解决方案).
我忘记从 #library(flexdashboard)
中删除 #
,因此找不到函数 gauge
并且无法呈现仪表...
是否可以在 Shiny
应用程序(shinydashboard
或 shiny
)中嵌入来自 flexdashboard
(下图)的仪表?
Shiny flexdashboard
中的示例代码来自 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)
))
})
```
这是我失败的尝试:
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)
感谢任何提示!
(代表OP发布解决方案).
我忘记从 #library(flexdashboard)
中删除 #
,因此找不到函数 gauge
并且无法呈现仪表...