jbkunst / highcharter

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

enabling boost canvas fixes issue #755 and allows accessibility.js to be enabled automatically #780

Closed mrjoh3 closed 3 months ago

mrjoh3 commented 1 year ago

Issue #755 indicates there is a problem including the accessibility plugin or adding it via hc_add_dependency(name = "modules/accessibility.js"). Essentially if the accessibility.js module is included in any way the resulting charts do not render properly. With some testing I got very lucky and was able to find a fix with a small modification to the inst/htmlwidgets/highcharts.yaml file.

I suspected that there might be a clash with the boost.js module and disabling it did allow accessibility.js to work as expected. I then noticed that boost-canvas was also disabled and tried enabling it. This change enabled the accessibility module to work as expected.

For this PR I have not added a test due to the simplicity of the change (please advise if I should add one). I have run devtools::check(args = c('--no-build-vignettes')) which resulted in zero errors or warnings. I also modified the DESCRIPTION file as two packages were duplicated across the imports and suggests sections and this was causing a warning in the checks

Please see the code below which reproduces #755 but now works with these chages.

library(highcharter)

df <- data.frame(date = seq(as.Date('2022-01-01'), length.out = 10, by = 'month'),
                            value = rnorm(10))

hchart(df, 
         type = "line",
          hcaes(x = date, 
                    y = value),
       accessibility = list(
                  enabled = TRUE,
                  keyboardNavigation = list(enabled = TRUE),
                  linkedDescription = "My Chart"
                ))

PR task list:

humoroussmile commented 1 year ago

Thanks for looking deeper into this fix @mrjoh3! Unfortunately I'm still running into issues when I run the accessibility module in R Shiny with these changes. I installed your fork with devtools and I end up with the following error (in the browser console) which causes my application to crash when changing inputs:

Uncaught TypeError: a.id.indexOf is not a function

Any thoughts? I could provide a reprex if helpful.

mrjoh3 commented 1 year ago

@humoroussmile that's disappointing, in my example I only used Rmarkdown. I will try and reproduce the issue in a minimal shiny app. I should be fine for now without the reprex.

I think the issue has something to do with the order that modules are loaded and some are conflicting.

mrjoh3 commented 1 year ago

@humoroussmile I have tried this on a minimal shiny app but can't reproduce the problem you are having. Perhaps we should exchnage reprex's. The code below is my minimal shiny example but perhaps it is too simplistic. I am running R4.2.1 on ubuntu. Tomorrow I will test on a windows machine to see if there is a difference.

If you are able please send through a reprex and I will see if I have the same problem.

cheers

library(shiny)
library(highcharter)

ui <- fluidPage(

    titlePanel("Highcharts Accessibility Test"),
    highcharter::highchartOutput('chart')

)

# Define server logic required to draw a histogram
server <- function(input, output) {

  df <- data.frame(date = seq(as.Date('2022-01-01'), length.out = 10, by = 'month'),
                   value = rnorm(10))

    output$chart <- highcharter::renderHighchart({

      hchart(df, 
             type = "line",
             hcaes(x = date, 
                   y = value),
             accessibility = list(
               enabled = TRUE,
               keyboardNavigation = list(enabled = TRUE),
               linkedDescription = "My Chart"
             ))

    })
}

# Run the application 
shinyApp(ui = ui, server = server)
humoroussmile commented 1 year ago

@mrjoh3 I need to create a simpler reprex to generate this error. While your Shiny app works for me as well, my Shiny app (with various complexities) ceases to have functional UI input changes after switching tabs when using tabsetpanel. It may have something to do with a conflict with the shinyjs package as I don't seem to have any issues when I remove this, but I'm unsure at this time. Also, it appears to happen specifically in the browser, and not when run in an RStudio viewer window.

I'm working on a simpler version and will share with you soon.

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.