我的Shiny App出现问题,特别是flexdashboard gauges和googleAnalyticsR之间的问题。
当我最初使用预先填充的值加载应用程序时,仪表会显示相应的颜色。
但是,在我登录并为Google Analytics(googleAuthR)创建授权令牌后,测量条上的颜色立即消失。
以下是我正在处理的应用程序的剥离版本,它展示了这个问题。我尝试了多种不同的加载包的方法(例如this和this),但我没有运气。 Chrome或R控制台中没有错误,因此我不确定为什么Google身份验证会导致图形丢失颜色,而不会丢失值。
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)