11

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!!!!

Community
  • 1
  • 1
Sachin Vardhan
  • 743
  • 1
  • 8
  • 19

2 Answers2

10

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)
Sachin Vardhan
  • 743
  • 1
  • 8
  • 19
0

I solved the problem using plotly() in the UI and renderPlotly() in the server.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100