【问题标题】:R shiny gauge chartR 闪亮仪表盘
【发布时间】:2018-04-03 04:45:28
【问题描述】:

有人可以帮我在 R Shiny 中绘制一个仪表图吗?我不需要它是动态的,而是要有一个我分配的 KPI,并在我运行应用程序时显示它。它应该是红色的从 0 到 0.3,黄色从 0.3 到 0.5,绿色从 0.5 到 1。

【问题讨论】:

    标签: r shiny gauge flexdashboard


    【解决方案1】:

    flexdashboard 提供了这样的仪表图:

    library(shiny)
    library(flexdashboard)
    
    ui <- fluidPage(
      numericInput("value", label = "Select value", min = 0, max = 1, value = 0.5, step = 0.1),
      gaugeOutput("gauge")
    )
    
    server <- function(input, output) {
    
      output$gauge = renderGauge({
        gauge(input$value, 
              min = 0, 
              max = 1, 
              sectors = gaugeSectors(success = c(0.5, 1), 
                                     warning = c(0.3, 0.5),
                                     danger = c(0, 0.3)))
      })
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

      【解决方案2】:

      你也可以使用C3

      #devtools::install_github("FrissAnalytics/shinyJsTutorials/widgets/C3")
      library(C3)
      library(shiny)
      
      runApp(list(
        ui = bootstrapPage(
          # example use of the automatically generated output function
          column(6,C3GaugeOutput("gauge1"))
        ),
        server = function(input, output) {
      
          # reactive that generates a random value for the gauge
          value = reactive({
            invalidateLater(1000)
            round(runif(1,0,100),2)
          })
      
          # example use of the automatically generated render function
          output$gauge1 <- renderC3Gauge({ 
            # C3Gauge widget
            C3Gauge(value())
          })
        }
      ))
      

      【讨论】:

        猜你喜欢
        • 2019-02-12
        • 1970-01-01
        • 1970-01-01
        • 2015-04-22
        • 1970-01-01
        • 2016-05-02
        • 2018-07-07
        • 2019-02-23
        • 1970-01-01
        相关资源
        最近更新 更多