d3scatter icon indicating copy to clipboard operation
d3scatter copied to clipboard

destroy legend to avoid overplotting it

Open bjstubbs opened this issue 5 years ago • 0 comments

There seems to be an issue with the legend being overplotted instead of being replaced when you programmatically change the color variable. I think this change fixes it.

This should demonstrate the behavior. I love this package. Thank you for your hard work!

library(shiny)
library(d3scatter)
library(crosstalk)
library(DT)
library(ggplot2)

mysamp=sample(1:nrow(diamonds),1000)
myd=diamonds[mysamp,]
sharedD=SharedData$new(myd)

runapp<-function(){
shinyApp(
	ui <- fluidPage(
	    titlePanel("crosstalkd3Select"),
            sidebarLayout(position = "left",
                sidebarPanel(width=2, selectInput("filterVar","Filter Column",names(myd))),
            mainPanel("",width=10,
		d3scatterOutput("scatter1"),
		dataTableOutput('mytable')
		 
))),

	server <- function(input, output, session) {

	    output$scatter1 <- renderD3scatter({
		colVar=input$filterVar
		d3scatter(sharedD, ~carat, ~price,as.formula(paste0("~",colVar)))}) 
	    output$mytable = renderDataTable(sharedD,options = list(scrollX = TRUE,pageLength=5),server=FALSE)
	}
)}
runapp()

bjstubbs avatar Oct 22 '18 20:10 bjstubbs