2017-10-13 6 views
0

Ich habe ein Problem mit meiner Shiny App. Meine App hat eine valueBox, die gut funktionierte, bevor ich eine gauge aus dem flexdashboard Paket einführte.R Shiny valueBox und Messgerät arbeiten nicht zusammen

Mit der gauge meine WertBox nicht mehr in der Benutzeroberfläche gerendert.

Lesen andere Beiträge, ich denke, das ist ein Problem mit dem flexdashboard Paket.

Alle Arbeitsumgebungen würden sehr geschätzt.

Einige reproduzierbaren Code unten:

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


ui <-dashboardPage(
dashboardHeader(), 
dashboardSidebar(), 
dashboardBody(
fluidRow(
    valueBoxOutput("vbox1"), 
    column(6,box(plotOutput("plt1"),width=12,title="Gauge Graph",background ="green")), 

column(6,box(plotOutput("plt2"),width=12,title="Graph2",background="yellow")) 
), 
fluidRow(actionButton("plot","plot")) 
) 
) 

server <- shinyServer(function(input, output, session) { 
observeEvent(input$plot,{ 
output$plt1 <- renderPlot({ 
    flexdashboard::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") 
)) 

}) 
output$plt2 <- renderPlot({plot(runif(100),runif(100))}) 
}) 

output$vbox1 <- renderValueBox({ 
valueBox(
    "Gender", 
    input$count, 
    icon = icon("users") 
) 
}) 
}) 

shinyApp(ui = ui, server = server) 
+0

https://www.rdocumentation.org/packages/flexdashboard/versions/0.4/topics/gauge-shiny –

Antwort

1

könnten Sie flexdashboard Namespace verwenden stattdessen die Bibliothek der Beschaffung.

Man könnte so etwas tun:

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


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

     column(6,box(plotOutput("plt2"),width=12,title="Graph2",background="yellow")) 
    ), 
    fluidRow(actionButton("plot","plot")) 
) 
) 

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

    }) 
    output$plt2 <- renderPlot({plot(runif(100),runif(100))}) 
    }) 

    output$vbox1 <- renderValueBox({ 
    valueBox(
     "Gender", 
     input$count, 
     icon = icon("users") 
    ) 
    }) 
}) 

shinyApp(ui = ui, server = server) 

diesen Code verwenden die App wie folgt aussieht: enter image description here

Hoffe, es hilft!

Verwandte Themen