Plotly + Shiny Dashboard: Graph Misbehaving

I’m creating a simple plotly graph. The problem is when I unselect the checkboxes, that’s when the graph remains.

This is what it looks like when I check the boxes:

and this is what it looks like when I uncheck it:

Here is my code:


column(width = 3,
tabBox(width = NULL,
actionLink(“selectallcrops”, “Select/Deselect All”, icon = icon(“check-square”)),
checkboxGroupInput(“crops”, “Choose Option(s):”, crops)))),
column(width = 9,
box(width = NULL, plotlyOutput(‘plot1’, height = “700px”), collapsed = F, title = “Figure”,
status = “warning”, solidHeader = T, height = “760px”))


s.df is the dataset

output$plot1 <- renderPlotly({
need(length(input$crops) > 0, “INSTRUCTIONS: \n\n1) Select Crops Of Interest.\n2) Use ‘Farm’ tab to refine results.\n3) Hover over graph to see values.”)

s.df <- subset(s.df, Crop %in% input$crops)

if(input$metric == 'Acreage') {
  p <- plot_ly(s.df, x = ~Farm, y = ~Acreage, color =~Crop) %>% layout(barmode = "stack", margin = list(b = 140))


I got the same problem.

Try to use the ‘need’ command I think it will solve your problem.
For example:
need(input$checkboxID != “None”," your message"),