data(penguins, package = "palmerpenguins") 

hchart(
  penguins,
  "scatter",
  hcaes(x = flipper_length_mm, y = bill_length_mm, group = species) 
)

Babynames

PopularNames <- babynames %>%
  filter(year >= 2006, year <= 2015) %>%
  group_by(name, year) %>% #to combine counts across sexes
  summarize(n = sum(n)) %>% #to combine counts across sexes
  group_by(year) %>%
  slice_max(n) %>% #an alternative approach
  arrange(year)
## `summarise()` has grouped output by 'name'. You can override using the `.groups`
## argument.
PopularNames <- babynames %>%
  filter(sex == "F") %>%
  group_by(name) %>%
  summarize(total = sum(n)) %>%
  arrange(desc(total)) %>%
  head(10)

PopularNames %>% 
  ggplot(aes(x = name, y = total)) +
  geom_col()

PopularNames %>% 
  hchart("column", hcaes(x = name, y = total)) %>% 
  #hc_add_dependency(name = "modules/series-label.js") %>%
  hc_add_dependency(name = "modules/accessibility.js") %>%
  hc_add_dependency(name = "modules/exporting.js") %>%
  hc_add_dependency(name = "modules/export-data.js") 

Sonification

highchart() |>  
  hc_series(
    list(
      name = "Tokyo",
      data = c(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6)
    ),
    list(
      name = "London",
      data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8)
    )
  ) %>% 
  #hc_tooltip(formatter = JS("function () { return 'hello world'}"))  
  hc_plotOptions(series = list(point = list(events = list(
    click = JS("function() {alert('hello world')
    
    # chart.sonify({
    #         duration: 3000,
    #         order: 'sequential',
    #         pointPlayTime: 'x',
    #         afterSeriesWait: 1000,
    #         instruments: [{
    #             instrument: 'triangleMajor',
    #             instrumentMapping: {
    #                 volume: 0.8,
    #                 duration: 250,
    #                 pan: 'x',
    #                 frequency: 'y'
    #             },
    #             // Start at C5 note, end at C6
    #             instrumentOptions: {
    #                 minFrequency: 520,
    #                 maxFrequency: 1050
    #             }
    #         }]
        }"))))) %>%
  hc_add_dependency(name = "modules/sonification.js") 
PopularNames %>% 
  hchart("point", hcaes(x = name, y = total)) %>%
  hc_plotOptions(
    series = list(
      point = list(
        events = list(
          click = JS("function() {alert('hello')});"))))) %>% 
   hc_add_dependency(name = "modules/sonification.js")
                    #     event.point.sonify({
                    #     instruments: [{
                    #         instrument: 'triangleMajor',
                    #         instrumentMapping: {
                    #             volume: 0.2,
                    #             duration: 200,
                    #             pan: 'x',
                    #             frequency: 'y'
                    #         },
                    #         // Start at C5 note, end at C6
                    #         instrumentOptions: {
                    #             minFrequency: 520,
                    #             maxFrequency: 1050
                    #         }
                    #     }]
                    # });"))))) %>%
  #hc_add_event_point(series = "series", event = "click") 

Accessible Fruit Example

includeScript("https://code.highcharts.com/modules/accessibility.js")
data(mpg, package = "ggplot2")

hchart(mpg, "point", hcaes(displ, hwy),
  regression = TRUE,
  regressionSettings = list(type = "polynomial", order = 5, hideInLegend = TRUE)
) %>%
  hc_add_dependency("plugins/highcharts-regression.js")