Search code examples
rshinyplotlyshinydashboard

R/ShinyApp not showing plot_ly in browser but show only graph in viewer pane


I am facing the same issue as mentioned in R/Shiny plots do not show in the browser

But in my case reactivePlot() is not working.It shows

error i.e "reactivePlot is deprecated. Please use renderPlot instead."

The code doesn't throw any error. It works fine. Issue is only with displaying plotly graph in the browser. I tried it on all browser, graph is displayed on viewer pane instead of the browser, although If I plot other chart like barplot it easily get displayed on the browser. I am not able to resolve the issue!! Help me out!! Thanks in advance!!!!


Solution

  • Just an example that how it solved my problem.

    ui <- dashboardPage(
      dashboardHeader(title = "Basic dashboard"),
      dashboardSidebar(),
      dashboardBody(
       fluidRow(
        box(plotlyOutput("plot1", height = "400px", width = "600px"))   
       )
      )
    )
    server <- function(input, output) {
    set.seed(100)
    d <- diamonds[sample(nrow(diamonds), 1000), ]
    output$plot1 <- renderPlotly({
      plot_ly(d, x = ~carat, y = ~price, color = ~carat,
            size = ~carat, text = ~paste("Clarity: ", clarity))    
     })
    }
    shinyApp(ui = ui, server = server)