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

Bar does not update but append svg when changing the input #2

Closed
sakritz opened this issue Jul 5, 2022 · 2 comments
Closed

Bar does not update but append svg when changing the input #2

sakritz opened this issue Jul 5, 2022 · 2 comments

Comments

@sakritz
Copy link

sakritz commented Jul 5, 2022

Let me start off by saying that I really love the simple elegance of these bar charts!

However, I'm having some trouble with dynamic inputs because the bar is not updated/replaced when changing the input but instead a second bar appears below the first one (and so on).

Below is a simple reprex:

library(shiny)
library(tidyverse)

ui <- fluidPage(
  fluidPage(
    selectInput("Input", label="choose", choices=c("mpg", "cyl")),
    fluidRow(barOutput("bar")
    )
  )
)

server <- function(input,output,session)({
  
  output$bar <- renderBar({
    
    dt <- mtcars %>% 
      add_rownames(var = "rowname") %>% 
      select(rowname, input$Input)
    cols = map(rev(colorRampPalette(c("#FFFFFF", "#000000"))(nrow(dt))), as.character())
    names(cols) <- dt$rowname

    bar(data = dt, colors = cols)
    
  })
})

shinyApp(ui = ui, server = server)
@pvictor
Copy link
Member

pvictor commented Jul 5, 2022

Indeed, thanks for reporting it. Re-install from GitHub it should works, let me know.
All credits for these charts goes to proportions-chart library !

Victor

@sakritz
Copy link
Author

sakritz commented Jul 5, 2022

Works perfectly! Thanks for the quick fix!

@sakritz sakritz closed this as completed Jul 5, 2022
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

2 participants