jbkunst / highcharter

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

Charts with `highchartOutput2` not rendering #800

Open msaltieri opened 1 year ago

msaltieri commented 1 year ago

Hey @jbkunst, I appreciate your work on highcharter! I've encountered an issue with highchartOutput2 in Shiny where the charts aren't rendering. Please find below more details and a reproducible example. Would appreciate your help on this. Thanks!

Description

When using the highchartOutput2 function from the highcharter package in a Shiny application, the charts are not rendering properly. The issue can be reproduced with the provided example code.

Steps to Reproduce

  1. Run the code provided in a Shiny application.
  2. Open the application in a web browser.

Expected Behavior

The application should display a chart generated using highchartOutput2 with a line series.

Actual Behavior

The chart does not render properly and is not visible in the application.

Reproducible Example

library(shiny)
library(highcharter)

ui <- fluidPage(

  # Application title
  titlePanel("Testing Highchart 2"),

  fluidRow(
    column(
      width = 6,
      highchartOutput2("chart")
    )
  )

)

server <- function(input, output) {

  output$chart <- renderHighchart2(
    highchart2() |>
      hc_add_series(
        data = cumsum(rnorm(100)),
        step = "left"
      ) |>
      hc_plotOptions(
        line = list(
          marker = list(
            enabled = FALSE
          )
        )
      ) |>
      hc_tooltip(
        enabled = FALSE
      ) |>
      hc_legend(
        enabled = FALSE
      )
  )

}

# Run the application
shinyApp(ui = ui, server = server)

Environment

Additional Information

I have explored various configurations, and it seems that the only workaround to make the chart appear is by substituting highchartOutput2 with highchartOutput. This approach loads all the modules in the browser, which I initially wanted to avoid for performance reasons. Nevertheless, it would be helpful to have highchartOutput2 function properly render the chart while maintaining performance optimization. Thank you for your attention to this matter.