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

echarts in modal windows depending on input change does not flush properly #482

Closed
Patrikios opened this issue Nov 4, 2022 · 1 comment

Comments

@Patrikios
Copy link

Reprex under:

> version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          2.2                         
year           2022                        
month          10                          
day            31                          
svn rev        83211                       
language       R                           
version.string R version 4.2.2 (2022-10-31)
nickname       Innocent and Trusting   
    
> packageVersion("echarts4r")
[1] ‘0.4.4’

> packageVersion("shiny")
[1] ‘1.7.3’
app <- shinyApp(
  ui = fluidPage(
    selectInput(
      "species",
      "Select spiecies",
      sort(unique(iris$Species)),
      "virginica"
    )
  ),
  server = function(input, output) {
    observeEvent(input$species, {
      showModal(modalDialog(
        echarts4rOutput("plot"),
        easyClose = TRUE,
        footer = NULL
      ))
    })

    output$plot <- renderEcharts4r({
      subset(iris, Species == input$species) |>
        e_charts(Sepal.Length) |>
        e_line(Sepal.Width) |>
        e_tooltip(trigger = "axis")
    })
  }
)

runApp(app)

The default select input "virginica" dependent output renders Okay (as it is the first render outcome cached???) however the other 2 Species render only after, for a brief moment, the outcome of "virginica" is displyed, only then the correct output is to be seen.

Obviously, this happens only in modal dialogues, when you bind output directly into fluidPage, it works as expected.

How can I flush before rendering? Something like JS function:

flushEchart = function() {
                          Shiny.setInputValue('unknown_proper_echart_input_value', 'null');
                        }

?

@Patrikios
Copy link
Author

solved by suggestion as can be seen @ rstudio/shiny#3731 (comment)

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