7

I am having a problem with my Shiny App, specifically a problem between flexdashboard gauges and googleAnalyticsR.

When I initially load the app with the values pre populated, the gauges appear with the appropriate color. enter image description here

However, immediately after I log in and create my authorization token for Google Analytics (googleAuthR) the color on the gauge bars disappears. enter image description here

Below is the stripped back version of the app I am working on which showcases this problem. I have tried multiple different methods of loading packages (such as this, and this), but I have had no luck. There are no errors in the Chrome or R console, so I am not sure why the Google Authentication would cause the graphs to lose their color, but not the values.

library(shiny)
library(shinydashboard)
library(googleAnalyticsR)
library(googleAuthR)
library(flexdashboard)


ui <- shinyUI(dashboardPage(

  dashboardHeader(title = "Test"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Test", tabName = "Test", icon = icon("dashboard"))
    )
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "Test",
              fluidRow(

                titlePanel("Test"),
                sidebarPanel(
                  helpText("Start by logging in to your Google Analytics account."),
                  googleAuthUI("login"),
                  br()
                ),
                mainPanel(
                  column( width = 4,
                          flexdashboard::gaugeOutput("outputBox1")
                  ),column( width = 4,
                            flexdashboard::gaugeOutput("outputBox2")
                  ),column( width = 4,
                            flexdashboard::gaugeOutput("outputBox3")
                  )
                )
              ))
      ))))


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

  token <- callModule(googleAuth, "login")


  output$outputBox1 <- renderGauge({ 
    flexdashboard::gauge(15.8513963, min = 0, max = 100, symbol = '%', gaugeSectors(
      success = c(71, 100), warning = c(39, 50), danger = c(0, 39)
    ))
  })
  output$outputBox2 <- renderGauge({ 
    flexdashboard::gauge(80.1935234, min = 0, max = 100, symbol = '%', gaugeSectors(
      success = c(71, 100), warning = c(39, 50), danger = c(0, 39)
    ))
  }) 
  output$outputBox3 <- renderGauge({ 
    flexdashboard::gauge(5.869565, min = 0, max = 100, symbol = '%', gaugeSectors(
      success = c(71, 100), warning = c(39, 50), danger = c(0, 39)
    ))

  }) 
})

# Run the application 
shinyApp(ui = ui, server = server)
sdhaus
  • 1,866
  • 13
  • 20

0 Answers0