Skip to content
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

issues when rendering an r2d3-based package's plots in shiny #99

Open
feddelegrand7 opened this issue Oct 23, 2022 · 0 comments
Open

issues when rendering an r2d3-based package's plots in shiny #99

feddelegrand7 opened this issue Oct 23, 2022 · 0 comments

Comments

@feddelegrand7
Copy link

Hi,

Thank you for the great package. It's really a breeze to integrate D3 with R. In this context, I've developed a small package that outputs some D3 basic plots. Unfortunately, when I tried to use the package in shiny using D3output and renderD3, I encountered the following issue:

  • When modifying a Shiny Input, which the D3 plot relies on, the D3 plot is again rendered (which is perfect), but instead of getting a new plot, I get an overlay of the old plot and new plot(s). What's also interesting is that when I resize the window, the old plots disappear and I get only the last one. (See example below).

The plots generated by ddplot are normal D3.js graphics, so in my understanding it should work normally in Shiny. Do you have an idea please, maybe I'm using the r2d3 API wrongly.

Thanks in advance :)

library(shiny)
library(r2d3)
library(ddplot)

ui <- fluidPage(
  inputPanel(
    sliderInput("bar_max", label = "Max:",
      min = 0, max = 100, value = 1, step = 1)
  ),
  d3Output("plot")
)

server <- function(input, output) {
  
  
  output$plot <- renderD3({
    
    barChart(
      data  = mtcars,
      x = "am", 
      y = "mpg", 
      fill = "red",
      yticks = input$bar_max
    )
  })
}

shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant