helgasoft / echarty

Minimal R/Shiny Interface to ECharts.js
https://helgasoft.github.io/echarty/
87 stars 3 forks source link

No handler for mouseover #25

Closed milesmedina closed 1 year ago

milesmedina commented 1 year ago

Hi, I am having a similar issue to the one posted by joachim-hansson on Jun 18.

The app closes as soon as I mouseover data in the chart, and I get this warning:

Warning: Error in : No handler registered for type gam_mouseover:echartyParse 3: runApp 2: print.shiny.appobj 1: Error in (function (name, val, shinysession) : No handler registered for type gam_mouseover:echartyParse

I have tried adding a mouseover handler as suggested in the Jun 18 issue, but it has no effect.

Likewise I get the same warning/crash when I run this demo from the documentation (including the mouseover handler suggested in response to the Jun 18 issue):

ui <- fluidPage(ecs.output('plot'), textOutput('out1') )
server <- function(input, output, session) {
  output$plot <- ecs.render({
    p <- mtcars |> group_by(cyl) |> ec.init(dataZoom= list(type= 'inside'))
    p$x$on <- list(                     # event(s) with Javascript handler
      list(event= 'legendselectchanged',
           handler= htmlwidgets::JS("(evt) => Shiny.setInputValue('result1',evt.name);"))
    )
    p$x$capture <- 'datazoom'
    p
  })
  observeEvent(input$plot_datazoom, {   # captured event
    output$out1 <- renderText({ paste('Zoom.start:',input$plot_datazoom$batch$start,'%') })
  })
  observeEvent(input$plot_mouseover, {  # built-in event
    output$out1 <- renderText({ toString(input$plot_mouseover) })
  })
  observeEvent(input$result1, {
    output$out1 <- renderText({ paste('legend:',input$result1) }) 
  })
  observeEvent(input$plot_mouseover, {   # mouseover handler
    cat('\nMover:', toString(input$plot_mouseover$data))
  })
}
shinyApp(ui, server)

I am running R 4.3.1, echarty 1.5.4, shiny 1.7.5.

helgasoft commented 1 year ago

@milesmedina, the documentation demo you used is a good test. Got it replicated - in R console only. I work mostly in RStudio where it does not happen. The obvious suspect is HTMLWidgets.shinyMode which somehow does not get set (in timely manner maybe?). I have no control over HTMLWidgets.shinyMode and hope the bug remains only in v.1.5.4 and does not happen again. The new build 1.5.4.01, just uploaded, works fine.

milesmedina commented 1 year ago

Thanks! I downloaded 1.5.4.01 and the issue is resolved. fyi, I also use RStudio and this is where I discovered the issue.