jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
718 stars 147 forks source link

Development version (version with hcpxy_update_point) causing error (didn't before) #725

Closed zross closed 2 years ago

zross commented 2 years ago

@jbkunst sorry to bother you. You very helpfully answered a question on stackoverflow related to selecting a point. You directed me to the function hcpxy_update_point which was working great!

But I'm seeing that even your simple example in that stackoverflow post no longer works -- I pasted it below. As a result our app, which was working, is no longer working.

I narrowed the issue to the development version by commenting out the hcpxy_update_point and using the CRAN version and the app works (except for the hcpxy_update_point - functionality).

I'm seeing commits in highcharter related to updating jQuery to v 3.5.1, could this be the issue?

library(shiny)
library(highcharter)

ui <- function(){
  div(
    selectInput('id', label = 'select', choices = 1:3, selected = 2),
    highchartOutput("plot")
  )
}

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

  output$plot <- renderHighchart({
    hc <- highchart() %>% 
      hc_chart(events = list(load = JS("function(){this.series[0].points[2].select()}"))) %>% 
      hc_add_series(
        data.frame(x = 1:3, y = 1:3),
        "scatter",
        hcaes(x, y),
        id = "someid",
        ) %>%
      hc_plotOptions(
        allowPointSelect = TRUE
      )

    hc
  })

  observeEvent(input$id, {

    id_0_based <- as.numeric(input$id) - 1

    highchartProxy("plot") %>%
      # set all points unselected `selected = FALSE`
      hcpxy_update_point(id = "someid", 0:2, selected = FALSE) %>% 
      # then set to selected the _selected_ point
      hcpxy_update_point(
        id = "someid",
        id_point = id_0_based, 
        selected = TRUE
        )
  })
}

shinyApp(ui, server)
jbkunst commented 2 years ago

Hi @zross

Sorry for the delay.

I could not replicate the error. Do you still have problems?

I'm not sure it's Jquery. What does the browser console show?

Regards,

zross commented 2 years ago

Hmmm! This seems to be working for me now. Odd since it wasn't just my local set up it was also a deployed shiny app, but I'm seeing that app is back up also. Thanks for looking into it, I don't know what the issue was. Oddly, as I mentioned above, the app was working with the non-development version of highcharter and not the dev version. In any case, this can be closed. Thanks again.