Skip to content

duplicate trace on replot #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wave-electron opened this issue Mar 16, 2017 · 2 comments
Closed

duplicate trace on replot #906

wave-electron opened this issue Mar 16, 2017 · 2 comments
Labels

Comments

@wave-electron
Copy link

wave-electron commented Mar 16, 2017

I've discovered a very annoying bug that duplicates the traces on the 2nd replot. It doesn't happen on the cran version only on dev.

With cran version you get the correct number of traces on replot.

screen shot 2017-03-17 at 9 18 01 am

This duplication occurs in the dev version

screen shot 2017-03-17 at 9 21 10 am

Here is the code snippet in Shiny I was using to reproduce the bug


server = function(input, output)  {
   
        # original plot
       output$plot1 <- renderPlotly({
                p <- plot_ly(type = "scatter") %>%
                        add_trace(p,x =c( 1, 2, 3 ),y =c(5, 6,7),mode = "lines", color="Original Trace 1") %>%
                        add_trace(p,x =c( 2, 3, 4 ),y =c(7, 8,9),mode = "lines",color = "Original Trace2") %>% 
                        layout(title = "original Plot",showlegend = TRUE)   
        })
        
        # create new plot
        observeEvent(input$newplot,{
         
                                output$plot1 <- renderPlotly({
                                    p <-  plot_ly(type="scatter") %>%
                                                add_trace(p, x =c(1,2,3 ),y =c(5,6,7),mode = "lines",color = "New Trace1") %>%
                                                add_trace(p,x =c( 2,3,4),y =c(7,8,9),mode = "lines",color = "New Trace2") %>% 
                                                layout(title = "New Plot",showlegend = TRUE) 
                                })
        }) 
        
        # clearplot
        observeEvent(input$clearplot,{
 
                                output$plot1 <- renderPlotly({
                                        plotly_empty()
                                })
        })
        
  
           
  }
               
                     

ui <- pageWithSidebar(
        
        headerPanel("Plotly version 4.5.6.9000 - bug (duplicate traces on replot)"),
        
        sidebarPanel(
                actionButton("newplot", "New plot"),
                actionButton("clearplot", "Clear plot")
        ),
        
        mainPanel(
                plotlyOutput("plot1", height = 500, width = 500)
        )
)
shinyApp(ui, server)

@cpsievert cpsievert added the bug label Mar 17, 2017
@fabiangehring
Copy link

+1 same issue with barplot

@wave-electron
Copy link
Author

The duplication problem is reproducible on at least candle, area, bar, line, box, scatter ... i suspect it happens regardless of chart type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants