3

I am developing a Shiny app with plenty of plots. Whenever I change some input, plots are not shown for a very short time before they are plotted and instead a rather prominent error message in red is shown. How this looks can be seen here.

There are certainly solutions to solve this problem, see for example here. Also, Joe Cheng from RStudio spends the last ten minutes of his talk at the Shiny Developer Conference on a solution with the function req() (see here). However, the latter didn't quite solve the issue on first try and the former requires more work because I have to add if clauses to every plot.

For now, I think I could actually live with the error message because the plot is shown fairly quickly thereafter. However, is there any chance to change the color. If this would be grey and dark blue, it would be much more unobtrusive.

Tonio Liebrand
  • 17,189
  • 4
  • 39
  • 59
Christoph_J
  • 6,804
  • 8
  • 44
  • 58

1 Answers1

8

If you inspect the element you see that the class of the error is shiny-output-error, so you change the color with css, see below:

Css code would read:

.shiny-output-error{color: grey;}

and you can include it in shiny via tags$head(tags$style(..)) in ui.R.

Reproducible example:

library(shiny)
library(rhandsontable)
ui <- fluidPage(
  tags$head(tags$style(".shiny-output-error{color: grey;}")),
  rHandsontableOutput("table")
)

server <- function(input, output, session) {
  output$table <- renderRHandsontable({
    rhandsontable(NULL)
  })
}

runApp(shinyApp(ui, server), launch.browser = TRUE)
Tonio Liebrand
  • 17,189
  • 4
  • 39
  • 59