The code below randomly selects 5 points (from mtcars) to plot, then will draw a path along a random subset of those points.
Since the number of points included in the paths layer changes from run to run, segments are being added/removed from the plot. However, in some cases, segments that are supposed to be removed are remaining in the plot. This is made obvious because the underlying points have moved and there is a segment to/from nowhere despite the fact that rows in the paths layer dataset are merely a subset of those in the points layer.
Example:
This only appears to happen with SVG rendering. I haven't been able to reproduce when using canvas. Also, if you reproduce the error with SVG and switch to canvas and then back to SVG the extra line is removed.
Code to reproduce:
library(dplyr)
library(ggvis)
library(shiny)
server <- function(input, output) {
rData <- reactive({
#Randomly select 5 rows from mtcars to include in layer_points
input$runButton
rows <- 1:nrow(mtcars)
mtcars[sample(rows,5,replace=FALSE), ]
})
rData1 <- reactive({
#Randomly select rows to include in layer_lines
input$runButton
tempDf <- rData()
retDf <- tempDf[sample(c(TRUE,FALSE),5,replace=TRUE), ]
})
reactive({
rData %>%
ggvis(x=~disp,y=~mpg) %>%
layer_points() %>%
layer_paths(data=rData1,x=~disp,y=~mpg,inherit=FALSE)
}) %>%
bind_shiny("plot")
}
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("runButton","Run")
),
mainPanel(ggvisOutput("plot"))
)
)
shinyApp(ui = ui, server = server)
The code below randomly selects 5 points (from mtcars) to plot, then will draw a path along a random subset of those points.
Since the number of points included in the paths layer changes from run to run, segments are being added/removed from the plot. However, in some cases, segments that are supposed to be removed are remaining in the plot. This is made obvious because the underlying points have moved and there is a segment to/from nowhere despite the fact that rows in the paths layer dataset are merely a subset of those in the points layer.
Example:
This only appears to happen with SVG rendering. I haven't been able to reproduce when using canvas. Also, if you reproduce the error with SVG and switch to canvas and then back to SVG the extra line is removed.
Code to reproduce: