Highcharts Cookbook (R)

Zac Garland

2023-01-01

The goal of this document is to provide a fairly comprehensive translation of highcharts.js plots within R. It attempts to combine references found on the official highcharter website, in addition to filling in gaps with highcharts.js examples, and other plots.

It also provides a small extension to the highcharter library which allows anyone to create runtime like toggles within an existing highcharter plot definition within a statically rendered document (like an rmarkdown html output).

gapminder::gapminder |>
  mutate(iso_2 = countrycode::countrycode(country, "country.name", "iso2c")) |>
  filter(country != "Kuwait") |>
  gather(key, value, lifeExp:gdpPercap) |>
  hcmap(
    map = "custom/world",
    download_map_data = TRUE,
    joinBy = c("iso-a2", "iso_2"),
    name = "",
    nullColor = "transparent",
    borderColor = "black",
    value = "value"
  ) |>
  hc_colorAxis(minColor = "#e6ebf5",maxColor = getOption("highcharter.color_palette") %>% tail(1)) %>% 
  hc_title(text = "Gapminder Map Toggles") %>% 
  # hc_add_theme()
  add_multi_drop(
    c("year", "key"),
    c("2002", "lifeExp")
  )

This page is heavily influenced by Joshua Kunst’s blog, documentation, and issue responses.

Theme

Theme

thm <- hc_theme(
  colors = rev(c(
    "#003f5c", "#2f4b7c", "#665191", "#a05195", "#d45087", "#f95d6a",
    "#ff7c43", "#ffa600"
  )),style = list(fontSize = "1.2rem"), chart = list(
    backgroundColor = "var(--page-background)"
  ), xAxis = list(
    labels = list(style = list(color = "var(--text-color)")),
    gridLineDashStyle = "Dash",
    gridLineWidth = 1, gridLineColor = "var(--code-block-background)", lineColor = "var(--text-color)",
    minorGridLineColor = "var(--text-color)", tickColor = "var(--text-color)", tickWidth = 1,
    title = list(style = list(color = "var(--text-color)"))
  ), yAxis = list(
    labels = list(style = list(color = "var(--text-color)")),
    gridLineDashStyle = "Dash",
    gridLineWidth = 1, gridLineColor = "var(--code-block-background)", lineColor = "var(--text-color)",
    minorGridLineColor = "var(--text-color)", tickColor = "var(--text-color)", tickWidth = 1,
    title = list(style = list(color = "var(--text-color)"))
  ), legendBackgroundColor = "var(--page-background)",
  background2 = "var(--page-background)", dataLabelsColor = "var(--text-color)", textColor = "var(--text-color)",
  contrastTextColor = "var(--text-color)", maskColor = "rgba(255,255,255,0.3)",
  title = list(style = list(color = "var(--text-color)")), subtitle = list(
    style = list(color = "var(--text-color)")
  ), legend = list(
    itemStyle = list(
      color = "var(--text-color)"
    ), itemHoverStyle = list(color = "var(--text-color)"),
    itemHiddenStyle = list(color = "var(--text-color)")
  )
)

thm <- hc_theme_merge(
  hc_theme_darkunica(),
  thm
)

options(
  highcharter.theme = thm,
  highcharter.color_palette = rev(c(
    "#003f5c", "#2f4b7c", "#665191", "#a05195", "#d45087", "#f95d6a",
    "#ff7c43", "#ffa600"
  ))
)


highcharter::highcharts_demo()

Extending highcharter

Creating Multiple Toggles

One of the most difficult tasks I’ve ran into during my career was the need to create runtime interactivity… without runtime. In other words, finding a way to create the ability to toggle / filter / and select different series, within a statically rendered document.

Although I’ve approached this problem in multiple ways (many of them containing a lot of javascript code / very manual events and definitions), the below is the most seamless solution that I’ve come up with to date. It seems to work with multiple plot types, respects grouped data, and it allows you to go from a standard highcharts plot, to a ‘dashboard’ like plot with one line of code.

This makes these types of plots available to anyone that can define a highcharts plot :) - & there are a good amount of examples of those below.

tidy_employment_data <- fpp3::us_employment |>
  janitor::clean_names() |>
  as_tibble() |>
  filter(!str_detect(title, ":")) |>
  rename(value = employed) |>
  mutate(month = lubridate::as_date(month)) |>
  group_by(title) |>
  mutate(
    yoy = value / lag(value, 12) - 1,
    `Three year comp` = value / lag(value, 36) - 1
  ) |>
  gather(key, value, value:`Three year comp`)

tidy_employment_data |>
  mutate(month = datetime_to_timestamp(month)) |> # for highcharts date format
  highcharter::hchart("line", highcharter::hcaes(month, value, name = title)) |>
  hc_xAxis(type = "datetime") |>
  add_multi_drop(
    selectors = c("title", "key"),
    selected = c("Total Private", "Three year comp")
  )

the underlying function

# https://github.com/zac-garland/highchart.extensions/blob/master/R/add_multi_drop.R
add_multi_drop <- function(hc, selectors, selected = NULL) {
  # first we create a random id to ensure that if used multiple times, each selector / chart combo has a unique id
  rand_id_begin <- paste(sample(letters, 3, replace = FALSE),
    sample(letters, 4, replace = FALSE),
    sample(letters, 3, replace = FALSE),
    collapse = ""
  ) |> stringr::str_remove_all(" ")

  # next we generate the potential list options available in the chart (to ensure that we aren't passing in multiple data sets or trying to attach the data again to the web document)
  list_opts <- purrr::map(setNames(selectors, selectors), ~ {
    select_name <- .x
    hc$x$hc_opts$series |>
      purrr::map(~ {
        purrr::map(purrr::pluck(.x, "data"), ~ {
          purrr::pluck(.x, select_name)
        }) |>
          unlist()
      }) |>
      unlist() |>
      unique()
  })

  # generate the select html input elements with their corresponding options
  select_options <- list_opts |>
    purrr::imap(~ {
      htmltools::tags$select(
        style = "display:inline-block",
        id = paste0(.y, rand_id_begin),
        purrr::map(.x, ~ {
          if ((!is.null(selected) & .x %in% selected)) {
            htmltools::tags$option(value = ., ., `selected` = TRUE)
          } else {
            htmltools::tags$option(value = ., .)
          }
        })
      )
    })

  # generate variable declaration statement in javascript using R string interpolation (comparable to es7 `this var: ${var}`)
  names(list_opts) |>
    purrr::map_chr(~ {
      glue::glue("var select_{paste0(.x, rand_id_begin)} = document.getElementById('{paste0(.x, rand_id_begin)}');")
    }) |>
    paste(collapse = "") -> var_declaration

  # generate shared javascript filter (each chart should be aware of multiple inputs - and share the filter between onchange events)
  names(list_opts) |>
    purrr::map_chr(~ {
      glue::glue("obj.{.x} == select_{paste0(.x, rand_id_begin)}.value")
    }) |>
    paste(collapse = " & ") -> filter_declaration

  # generate the onchange events to monitor each of the inputs
  names(list_opts) |>
    purrr::map_chr(~ {
      glue::glue("select_{paste0(.x, rand_id_begin)}.onchange = updateChart;")
    }) |>
    paste(collapse = "") -> onchg_events

# create the javascript function for highcharts events, adding in the variable declaration, filters, and events generated from previous steps
  
js_fun <- "function(){{
  var this_chart = this;
  // create a cloned data set (to avoid highcharts mutate behavior)
  const cloneData = (sample) => {{ return JSON.parse(JSON.stringify(sample));}}
  // initialize empty array 
  const init_data = [];
  // loop over chart series and add to data array
  this_chart.options.series.map((series,index)=>{{
    init_data[index] = cloneData(series.data);
  }})

  // declare variables
  {var_declaration}

  // create shared updateChart function
  function updateChart(){{
      // map the series data to filter based on inputs
      init_data.map((series,index)=>{{
      new_data = series.filter(function(obj){{
        return {filter_declaration}
        }});
      // only draw if data is available post filter
      if(new_data.length>0){{
        this_chart.series[index].setData(new_data);
      }}

      }})
    // redraw chart
    this_chart.reflow();

  }}
  // add on change monitor events for dropdowns
  {onchg_events}
  // updateChart (for first run)
  updateChart();
}}"

# add javascript function as an onload event (so we filter down the data in the first view)
  highcharter::hc_chart(hc,
    events = list(
      load = highcharter::JS(glue::glue(js_fun))
    )
  ) |>
    htmltools::tagList(
      select_options, . # create a html fragment including the dropdowns and chart 
    ) |>
    htmltools::browsable() # create a browsable option (shows chart in rstudio or in render)
}

grouped data

gapminder::gapminder |>
  gather(key, value, lifeExp:pop) |>
  janitor::clean_names() %>% 
  hchart("scatter", hcaes(gdp_percap, value, group = continent, name = country)) |>
  add_multi_drop(
    c("year", "key")
  )

Charts

n <- 6

set.seed(123)

colors <- c("#d35400", "#2980b9", "#2ecc71", "#f1c40f", "#2c3e50", "#7f8c8d")
colors2 <- c("#000004", "#3B0F70", "#8C2981", "#DE4968", "#FE9F6D", "#FCFDBF")

df <- data.frame(x = seq_len(n) - 1) %>%
  mutate(
    y = 10 + x + 10 * sin(x - 1),
    z = 5 + (x * y) - median(x * y),
    e = 10 * abs(rnorm(length(x))) + 2,
    e = round(e, 1),
    low = y - e,
    high = y + e,
    value = round(y - 1),
    name = sample(fruit[str_length(fruit) <= 5], size = n),
    color = rep(colors, length.out = n)
  ) %>%
  mutate_if(is.numeric, round, 1) %>%
  select(-e)

catch_all_data <- df %>%
  mutate(
    # label = name,
    from = name[c(1, 1, 1, 2, 3, 4)],
    to = name[c(3, 4, 5, 3, 6, 6)],
    weight = c(1, 1, 1, 1, 2, 2)
  )

area

The area series type.

economics_long %>%
  mutate(date = datetime_to_timestamp(date)) %>%
  highcharter::hchart("area", hcaes(date, value01, group = variable)) %>%
  highcharter::hc_xAxis(type = "datetime") %>%
  hc_plotOptions(area = list(stacking = "normal")) %>%
  hc_legend(layout = "proximate", align = "right", labelFormatter = JS("function () {
           ydat = this.yData;
            return this.name + ' ' + ydat[ydat.length-1].toFixed(2);
        }"))

arearange

The area range series is a carteseian series with higher and lower values for each point along an X axis, where the area between the values is shaded.

jsonlite::fromJSON("https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/range.json") -> area_range_data

# area_range_data

highchart() %>%
  hc_add_series(data = as_tibble(area_range_data) %>% list_parse2(), type = "arearange") %>%
  hc_xAxis(
    type = "datetime"
  ) %>%
  hc_title(
    text = "Temperature variation by day"
  )

areaspline

The area spline series is an area series where the graph between the points is smoothed into a spline.

moose_and_deer <- tibble(
  year = c(2000:2020),
  Moose = c(
    38000, 37300, 37892, 38564, 36770, 36026, 34978, 35657, 35620, 35971, 36409, 36435, 34643, 34956, 33199, 31136, 30835, 31611, 30666, 30319, 31766
  ), Deer = c(
    22534, 23599, 24533, 25195, 25896, 27635, 29173, 32646, 35686, 37709, 39143, 36829, 35031, 36202, 35140, 33718, 37773, 42556, 43820, 46445, 50048
  )
) %>%
  gather(key, value, -year)



hchart(moose_and_deer, "areaspline", hcaes(x = year, y = value, group = key)) %>%
  hc_legend(
    layout = "vertical",
    align = "left", verticalAlign = "top",
    x = 120, y = 70, floating = TRUE,
    # backgroundColor = "var(--accent-color)",
    labels = list(style = list(color = "var(--page-background)"))
  ) %>%
  hc_title(text = "Moose and deer hunting in Norway 2000-2021") %>%
  hc_subtitle(text = "Source:SSB")

bar

A bar series is a special type of column series where the columns are horizontal.

palmerpenguins::penguins %>%
  group_by(species) %>%
  summarize(flipper_length = mean(flipper_length_mm, na.rm = TRUE)) %>%
  hchart("bar", hcaes(species, flipper_length, color = I(viridis::viridis(3)))) %>%
  hc_title(text = "Average Flipper Length by Penguin Species")

boxplot

A box plot is a convenient way of depicting groups of data through their five-number summaries: the smallest observation (sample minimum), lower quartile (Q1), median (Q2), upper quartile (Q3), and largest observation(sample maximum).

data(pokemon)

dat <- data_to_boxplot(pokemon, height, type_1, name = "height in meters")

highchart() %>%
  hc_xAxis(type = "category") %>%
  hc_add_series_list(dat)

bubble

A bubble series is a three dimensional series type where each point renders an X, Y and Z value. Each points is drawn as a bubble where the position along the X and Y axes mark the X and Y values, and the size of the bubble relates to the Z value.

structure(list(x = c(
  95, 86.5, 80.8, 80.4, 80.3, 78.4, 74.2,
  73.5, 71, 69.2, 68.6, 65.5, 65.4, 63.4, 64
), y = c(
  95, 102.9,
  91.5, 102.5, 86.1, 70.1, 68.5, 83.1, 93.2, 57.6, 20, 126.4, 50.8,
  51.8, 82.9
), z = c(
  13.8, 14.7, 15.8, 12, 11.8, 16.6, 14.5, 10,
  24.7, 10.4, 16, 35.3, 28.5, 15.4, 31.3
), name = c(
  "BE", "DE",
  "FI", "NL", "SE", "ES", "FR", "NO", "UK", "IT", "RU", "US", "HU",
  "PT", "NZ"
), country = c(
  "Belgium", "Germany", "Finland", "Netherlands",
  "Sweden", "Spain", "France", "Norway", "United Kingdom", "Italy",
  "Russia", "United States", "Hungary", "Portugal", "New Zealand"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(
  NA,
  -15L
)) -> sugar_and_fat


sugar_and_fat %>%
  hchart(., "bubble", hcaes(x = x, y = y, z = z)) %>%
  hc_plotOptions(
    series = list(
      dataLabels = list(enabled = TRUE, format = "{point.name}")
    )
  ) %>%
  hc_tooltip(
    headerFormat = "<table>",
    pointFormat = paste(
      '<tr><th colspan="2"><h3>{point.country}</h3></th></tr>',
      "<tr><th>Fat intake:</th><td>{point.x}g</td></tr>",
      "<tr><th>Sugar intake:</th><td>{point.y}g</td></tr>",
      "<tr><th>Obesity (adults):</th><td>{point.z}%</td></tr>"
    ),
    footerFormat = "</table>",
    useHTML = TRUE
  ) %>%
  hc_xAxis(
    plotLines = list(list(
      color = "var(--text-color)", dashStyle = "dot", value = 65,
      label = list(text = "Safe fat intake 65g/day", style = list(color = "var(--text-color)"), rotation = 0)
    ))
  ) %>%
  hc_yAxis(
    plotLines = list(list(
      color = "var(--text-color)", dashStyle = "dot", value = 50,
      label = list(text = "Safe sugar intake 50g/day", style = list(color = "var(--text-color)"), rotation = 0, align = "right")
    ))
  ) %>%
  hc_title(
    text = "Sugar and fat intake per country"
  ) %>%
  hc_subtitle(
    text = "Source: Euromonitor and OECD"
  )

bullet

A bullet graph is a variation of a bar graph. The bullet graph features a single measure, compares it to a target, and displays it in the context of qualitative ranges of performance that could be set using plotBands on yAxis.

df <- data.frame(
  y = sample(5:10),
  target = sample(5:10),
  x = LETTERS[1:6]
)

color_pal <- getOption("highcharter.color_palette")

hchart(df, "bullet", hcaes(x = x, y = y, target = target), color = "#000000") %>%
  hc_chart(inverted = TRUE) %>%
  hc_yAxis(
    min = 0,
    max = 10,
    gridLineWidth = 0,
    plotBands = list(
      list(from = 0, to = 7, color = color_pal[1]),
      list(from = 7, to = 9, color = color_pal[2]),
      list(from = 9, to = 10, color = color_pal[3])
    )
  ) %>%
  hc_xAxis(
    gridLineWidth = 0,
    gridLineColor = "transparent"
  ) %>%
  hc_plotOptions(
    series = list(
      pointPadding = 0.25,
      pointWidth = 15,
      borderWidth = 0,
      targetOptions = list(width = "200%")
    )
  )

column

Column series display one column per value along an X axis.

diamonds %>%
  group_by(cut, clarity) %>%
  summarize(price = mean(price, na.rm = TRUE)) %>%
  ungroup() %>%
  hchart("column", hcaes(cut, price, group = clarity))

columnpyramid

Column pyramid series display one pyramid per value along an X axis. To display horizontal pyramids, set chart.inverted to true.

diamonds %>%
  group_by(cut) %>%
  summarize(price = mean(price, na.rm = TRUE)) %>%
  ungroup() %>%
  hchart("columnpyramid", hcaes(cut, price, group = cut))

columnrange

The column range is a cartesian series type with higher and lower Y values along an X axis. To display horizontal bars, set chart.inverted to true.

structure(list(name = "Temperatures", data = list(structure(c(-13.9, -16.7, -4.7, -4.4, -2.1, 5.9, 6.5, 4.7, 4.3, -3.5, -9.8, -11.5, 5.2, 10.6, 11.6, 16.8, 27.2, 29.4, 29.1, 25.4, 21.6, 15.1, 12.5, 8.4), .Dim = c(12L, 2L)))), class = "data.frame", row.names = 1L) %>%
  pull(data) %>%
  as.data.frame() %>%
  list_parse2() %>%
  hchart(type = "columnrange") %>%
  hc_xAxis(categories = month.abb) %>%
  hc_chart(inverted = TRUE) %>%
  hc_plotOptions(columnrange = list(dataLabels = list(
    enabled = TRUE,
    format = "{y}°C"
  ))) %>%
  hc_legend(enabled = FALSE) %>%
  hc_title(text = "Temperature variation by month") %>%
  hc_subtitle(text = "Observed in Vik i Sogn, Norway, 2021 | Source: <a href=\"https://www.vikjavev.no/ver/\" target=\"_blank\">Vikjavev</a>")

dependencywheel

A dependency wheel chart is a type of flow diagram, where all nodes are laid out in a circle, and the flow between the are drawn as link bands.

arc_data <- structure(list(from = c(
  "Hamburg", "Hamburg", "Hamburg", "Hannover",
  "Hannover", "Berlin", "Berlin", "Berlin", "Berlin", "Berlin",
  "Berlin", "München", "München", "München", "München", "München",
  "Stuttgart", "Frankfurt", "Frankfurt", "Frankfurt", "Frankfurt",
  "Düsseldorf", "Düsseldorf", "Amsterdam", "Paris", "Paris",
  "Paris", "Paris", "Paris", "Paris", "Paris", "Paris", "Paris",
  "Nantes", "Bordeaux", "Nantes", "Milano", "Milano", "Milano",
  "Milano", "Milano", "Milano", "Torino", "Venezia", "Roma", "Roma",
  "Roma", "Catania"
), to = c(
  "Stuttgart", "Frankfurt", "München",
  "Wien", "München", "Wien", "München", "Stuttgart", "Frankfurt",
  "Köln", "Düsseldorf", "Düsseldorf", "Wien", "Frankfurt", "Köln",
  "Amsterdam", "Wien", "Wien", "Amsterdam", "Paris", "Budapest",
  "Wien", "Hamburg", "Paris", "Brest", "Nantes", "Bayonne", "Bordeaux",
  "Toulouse", "Montpellier", "Marseille", "Nice", "Milano", "Nice",
  "Lyon", "Lyon", "München", "Roma", "Bari", "Napoli", "Brindisi",
  "Lamezia Terme", "Roma", "Napoli", "Bari", "Catania", "Brindisi",
  "Milano"
), weight = c(
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
)), class = c(
  "tbl_df",
  "tbl", "data.frame"
), row.names = c(NA, -48L))

highchart() %>%
  hc_add_series(
    type = "dependencywheel",
    data = list_parse(arc_data)
  )

dumbbell

The dumbbell series is a cartesian series with higher and lower values for each point along an X axis, connected with a line between the values.

Requires highcharts-more.js and modules/dumbbell.js.

tibble(
  name = sample(letters, 10),
  high = rnorm(10),
  low = rnorm(10)
) %>%
  hchart("dumbbell", hcaes(x = name)) %>%
  hc_plotOptions(dumbbell = list(
    lowColor = "var(--text-color)"
  ))

errorbar

Error bars are a graphical representation of the variability of data and are used on graphs to indicate the error, or uncertainty in a reported measurement.

example_dat <- tibble(
  Type = c("Human", "High-Elf", "Orc"),
  key = c("World1", "World2", "World3")
) %>%
  expand.grid() %>%
  mutate(mean = runif(9, 5, 7)) %>%
  mutate(sd = runif(9, 0.5, 1))

hchart(
  example_dat,
  "column",
  hcaes(x = key, y = mean, group = Type),
  id = c("a", "b", "c")
) %>%
  hc_add_series(
    example_dat,
    "errorbar",
    hcaes(y = mean, x = key, low = mean - sd, high = mean + sd, group = Type),
    linkedTo = c("a", "b", "c"),
    enableMouseTracking = TRUE,
    showInLegend = FALSE
  ) %>%
  hc_plotOptions(
    errorbar = list(
      color = "var(--text-color)",
      # whiskerLength = 1,
      stemWidth = 1
    )
  )

funnel

Funnel charts are a type of chart often used to visualize stages in a sales project, where the top are the initial stages with the most clients. It requires that the modules/funnel.js file is loaded.

structure(list(name = c(
  "Website visits", "Downloads", "Requested price list",
  "Invoice sent", "Finalized"
), y = c(15654, 4064, 1987, 976, 846)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(
  NA,
  -5L
)) %>%
  hchart(type = "funnel")

gauge

Gauges are circular plots displaying one or more values with a dial pointing to values along the perimeter.

col_stops <- data.frame(
  q = c(0.15, 0.4, .8),
  c = c("#55BF3B", "#DDDF0D", "#DF5353"),
  stringsAsFactors = FALSE
)

highchart() %>%
  hc_chart(type = "solidgauge") %>%
  hc_pane(
    startAngle = -90,
    endAngle = 90,
    background = list(
      outerRadius = "100%",
      innerRadius = "60%",
      shape = "arc"
    )
  ) %>%
  hc_tooltip(enabled = FALSE) %>%
  hc_yAxis(
    stops = list_parse2(col_stops),
    lineWidth = 0,
    minorTickWidth = 0,
    tickAmount = 2,
    min = 0,
    max = 100,
    labels = list(y = 26, style = list(fontSize = "22px"))
  ) %>%
  hc_add_series(
    data = 90,
    dataLabels = list(
      y = -50,
      borderWidth = 0,
      useHTML = TRUE,
      style = list(fontSize = "40px")
    )
  ) %>%
  hc_size(height = 300)

heatmap

A heatmap is a graphical representation of data where the individual values contained in a matrix are represented as colors.

economics_long %>%
  mutate(date = as_factor(as.character(date))) %>%
  hchart("heatmap", hcaes(x = date, y = variable, value = value01)) %>%
  hc_size(width = 900)

Requires modules/heatmap.

histogram

A histogram is a column series which represents the distribution of the data set in the base series. Histogram splits data into bins and shows their frequencies.

x <- diamonds$price
hchart(x)
hchart(density(x), type = "area", color = "#B71C1C", name = "Price")

item

An item chart is an infographic chart where a number of items are laid out in either a rectangular or circular pattern. It can be used to visualize counts within a group, or for the circular pattern, typically a parliament.

df <- data.frame(
  stringsAsFactors = FALSE,
  name = c(
    "The Left",
    "Social Democratic Party",
    "Alliance 90/The Greens",
    "Free Democratic Party",
    "Christian Democratic Union",
    "Christian Social Union in Bavaria",
    "Alternative for Germany"
  ),
  count = c(69, 153, 67, 80, 200, 46, 94),
  col = c(
    "#BE3075", "#EB001F", "#64A12D", "#FFED00",
    "#000000", "#008AC5", "#009EE0"
  ),
  abbrv = c("DIE LINKE", "SPD", "GRÜNE", "FDP", "CDU", "CSU", "AfD")
)

hchart(
  df,
  "item",
  hcaes(
    name = name,
    y = count,
    label = abbrv,
    color = col
  ),
  name = "Representatives",
  showInLegend = TRUE,
  size = "100%",
  center = list("50%", "75%"),
  startAngle = -100,
  endAngle = 100
) %>%
  hc_title(text = "Item chart with different layout") %>%
  hc_legend(labelFormat = '{name} <span style="opacity: 0.4">{y}</span>')

The circular layout has much in common with a pie chart. Many of the item series options, like center, size and data label positioning, are inherited from the pie series and don’t apply for rectangular layouts.

line

A line series displays information as a series of data points connected by straight line segments.

data(economics_long, package = "ggplot2")

economics_long2 <- dplyr::filter(economics_long, variable %in% c("pop", "uempmed", "unemploy"))

hchart(economics_long2, "line", hcaes(x = date, y = value01, group = variable))

lollipop

The lollipop series is a carteseian series with a line anchored from the x axis and a dot at the end to mark the value.Requires highcharts-more.js, modules/dumbbell.js and modules/lollipop.js.

tibble(
  name = sample(letters, 10),
  # high = rnorm(10),
  low = rnorm(10)
) %>%
  hchart("lollipop", hcaes(x = name)) %>%
  hc_add_dependency("modules/lollipop.js")

organization

An organization chart is a diagram that shows the structure of an organization and the relationships and relative ranks of its parts and positions.

tibble(
  from = c("CEO", "CEO", "CTO"),
  to = c("CTO", "CMO", "Dev")
) %>%
  hchart("organization") %>% 
  hc_plotOptions(
    organization = list(dataLabels = list(color = "black")
  ))

packedbubble

A packed bubble series is a two dimensional series type, where each point renders a value in X, Y position. Each point is drawn as a bubble where the bubbles don’t overlap with each other and the radius of the bubble relates to the value.

gapminder::gapminder %>%
  filter(year == max(year)) %>%
  hchart("packedbubble", hcaes(name = country, value = pop, z = pop, group = continent), dataLabels = list(enabled = TRUE, format = "{point.country}", filter = list(property = "y", operator = ">", value = 31210042))) %>%
  hc_plotOptions(
    packedbubble = list(
      minSize = "30%", maxSize = "150%"
    )
  )
hc <- gapminder::gapminder %>%
  filter(year == max(year)) %>%
  select(country, pop, continent) %>%
  hchart("packedbubble", hcaes(name = country, value = pop, group = continent))

q95 <- as.numeric(quantile(gapminder::gapminder$pop, .95))

hc %>%
  hc_tooltip(
    useHTML = TRUE,
    pointFormat = "<b>{point.name}:</b> {point.value}"
  ) %>%
  hc_plotOptions(
    packedbubble = list(
      maxSize = "150%",
      zMin = 0,
      layoutAlgorithm = list(
        gravitationalConstant = 0.05,
        splitSeries = TRUE, ## TRUE to group points
        seriesInteraction = TRUE,
        dragBetweenSeries = TRUE,
        parentNodeLimit = TRUE
      ),
      dataLabels = list(
        enabled = TRUE,
        format = "{point.name}",
        filter = list(
          property = "y",
          operator = ">",
          value = q95
        ),
        color = "black",
        style = list(
          textOutline = "none",
          fontWeight = "normal"
        )
      )
    )
  )

pie

A pie chart is a circular graphic which is divided into slices to illustrate numerical proportion.

diamond_data <- count(diamonds, clarity) %>% mutate(pct = scales::percent(n / sum(n)))


hchart(
  diamond_data, "pie", hcaes(name = clarity, y = n),
  name = "Corte",
  innerSize = "80%",
  dataLabels = list(format = "{point.name}<br>({point.pct})")
) %>%
  hc_tooltip(
    useHTML = TRUE,
    style = list(fontSize = "30px"),
    headerFormat = "",
    pointFormat = "<div style='text-align: center;'> <b>{point.name}</b><br>{point.y} <br>{point.pct} </div>",
    positioner = JS(
      "function () {

        /* one of the most important parts! */
        xp =  this.chart.chartWidth/2 - this.label.width/2
        yp =  this.chart.chartHeight/2 - this.label.height/2

        return { x: xp, y: yp };

      }"
    ),
    shadow = FALSE,
    borderWidth = 0,
    backgroundColor = "transparent",
    hideDelay = 1000
  )

polygon

A polygon series can be used to draw any freeform shape in the cartesian coordinate system. A fill is applied with the color option, and stroke is applied through lineWidth and lineColor options.

hchart(structure(list(x = c(
  184L, 183L, 182L, 182L, 181L, 181L, 180L,
  180L, 180L, 180L, 180L, 179L, 179L, 178L, 178L, 177L, 177L, 176L,
  176L, 175L, 175L, 174L, 174L, 174L, 173L, 173L, 172L, 172L, 171L,
  171L, 171L, 170L, 170L, 170L, 170L, 169L, 169L, 169L, 169L, 168L,
  168L, 168L, 168L, 167L, 167L, 166L, 166L, 165L, 165L, 165L, 164L,
  164L, 163L, 162L, 159L
), y = c(
  87.9, 90.4, 89.9, 86.8, 89.2,
  89.9, 89.9, 89.9, 89.1, 80.7, 86.3, 88.4, 90.7, 84.1, 103.7,
  98.8, 103.2, 80.3, 91.1, 67, 93.7, 74.6, 84.7, 79.5, 73.6, 91.8,
  69.5, 74, 64.1, 88, 67.8, 58.8, 63.9, 74.7, 65.1, 93, 81.1, 64.9,
  71.9, 61.2, 65.9, 69.2, 56.5, 74.2, 60.5, 69.6, 74.7, 57.7, 58.4,
  61.8, 60.5, 69.1, 62.5, 59.5, 53.9
), name = c(
  "Netherlands",
  "Montenegro", "Estonia", "Denmark", "Iceland", "Czechia", "Serbia",
  "Sweden", "Norway", "Dominica", "Finland", "Bermuda", "Puerto Rico",
  "Belarus", "Cook Islands", "Niue", "American Samoa", "Russia",
  "Saint Lucia", "Senegal", "Tonga", "Algeria", "Argentina", "Portugal",
  "Mauritius", "Samoa", "Japan", "Bahrain", "Chad", "Tuvalu", "Sudan",
  "Eritrea", "Kenya", "Mongolia", "Nigeria", "Nauru", "Micronesia",
  "Ghana", "South Africa", "Vietnam", "Ivory Coast", "Maldives",
  "Ethiopia", "Ecuador", "Burundi", "India", "Brunei", "Bangladesh",
  "Madagascar", "Philippines", "Nepal", "Guatemala", "Yemen", "Laos",
  "Timor-Leste"
)), class = "data.frame", row.names = c(NA, 55L)), "scatter", hcaes(x, y,name = name)) %>%
  hc_add_series(type = "polygon", data = structure(c(
    163L, 162L, 162L, 163L, 164L, 170L, 181L, 182L, 173L,
    166L, 42L, 46L, 55L, 64L, 70L, 90L, 100L, 90L, 52L, 45L
  ), .Dim = c(
    10L,
    2L
  )), color = "#ffffff80", enableMouseTracking = FALSE) %>%
  hc_title(text = "average height and weight by country")

pyramid

A pyramid series is a special type of funnel, without neck and reversed by default.

structure(list(name = c(
  "Website visits", "Downloads", "Requested price list",
  "Invoice sent", "Finalized"
), y = c(15654, 4064, 1987, 976, 846)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(
  NA,
  -5L
)) %>%
  hchart(type = "pyramid")

sankey

A sankey diagram is a type of flow diagram, in which the width of the link between two nodes is shown proportionally to the flow quantity.

data(diamonds, package = "ggplot2")
diamonds2 <- select(diamonds, cut, color, clarity)
# data_to_sankey(diamonds2)



hchart(data_to_sankey(diamonds2), "sankey", name = "diamonds")

scatter

A scatter plot uses cartesian coordinates to display values for two variables for a set of data.

hchart(sample_n(diamonds, 1000), "scatter", hcaes(carat, price, group = clarity))

spline

A spline series is a special type of line series, where the segments between the data points are smoothed.

economics_long %>%
  group_by(variable) %>%
  sample_n(100) %>%
  arrange(date) %>%
  ungroup() %>%
  hchart("spline", hcaes(date, value01, group = variable))

streamgraph

A streamgraph is a type of stacked area graph which is displaced around acentral axis, resulting in a flowing, organic shape.

winter_olympics_data <- structure(list(medals = c(
  0L, 11L, 4L, 3L, 6L, 0L, 0L, 6L, 9L,
  7L, 8L, 10L, 5L, 5L, 7L, 9L, 13L, 7L, 7L, 6L, 12L, 7L, 9L, 5L,
  5L, 0L, 3L, 4L, 2L, 4L, 0L, 0L, 8L, 8L, 11L, 6L, 12L, 11L, 5L,
  6L, 7L, 1L, 10L, 21L, 9L, 17L, 17L, 23L, 16L, 17L, 0L, 2L, 5L,
  3L, 7L, 0L, 0L, 10L, 4L, 10L, 7L, 7L, 8L, 4L, 2L, 4L, 8L, 6L,
  4L, 3L, 3L, 7L, 14L, 11L, 15L, 0L, 17L, 15L, 10L, 15L, 0L, 0L,
  10L, 16L, 4L, 6L, 15L, 14L, 12L, 7L, 10L, 9L, 5L, 20L, 26L, 25L,
  25L, 19L, 23L, 26L, 0L, 4L, 6L, 12L, 4L, 0L, 0L, 9L, 11L, 7L,
  10L, 7L, 7L, 8L, 10L, 12L, 8L, 6L, 11L, 13L, 13L, 34L, 25L, 37L,
  28L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 5L, 14L,
  19L, 23L, 24L, 25L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 7L, 5L, 10L, 5L, 4L, 8L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 6L, 0L, 0L, 0L, 7L, 2L,
  8L, 9L, 0L, 0L, 0L, 0L, 0L, 0L, 26L, 24L, 29L, 36L, 29L, 30L,
  19L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 2L, 2L, 9L, 9L,
  6L, 4L, 0L, 7L, 4L, 4L, 11L, 8L, 9L, 8L, 24L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 1L, 2L, 3L, 1L, 4L, 4L, 5L, 4L, 2L, 2L, 5L, 14L,
  20L, 10L, 13L, 11L, 5L, 8L, 0L, 1L, 1L, 7L, 1L, 0L, 0L, 3L, 2L,
  3L, 4L, 3L, 3L, 1L, 3L, 2L, 4L, 5L, 7L, 13L, 15L, 17L, 24L, 26L,
  25L, 0L, 3L, 1L, 1L, 3L, 0L, 0L, 10L, 2L, 6L, 2L, 0L, 6L, 10L,
  5L, 5L, 5L, 15L, 3L, 9L, 7L, 11L, 14L, 9L, 11L, 0L, 4L, 1L, 0L,
  3L, 0L, 0L, 2L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 2L,
  1L, 2L, 1L, 1L, 4L, 0L, 3L, 1L, 1L, 1L, 0L, 0L, 5L, 1L, 0L, 3L,
  7L, 9L, 3L, 1L, 1L, 3L, 2L, 9L, 5L, 8L, 11L, 9L, 11L, 15L, 0L,
  0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 23L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 16L, 21L, 25L, 13L,
  16L, 27L, 22L, 25L, 29L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 23L, 18L, 13L, 22L, 15L, 33L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 1L, 0L, 0L, 0L, 3L, 0L, 1L, 1L, 1L, 7L, 5L, 10L, 2L,
  1L, 5L, 8L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 4L,
  3L, 1L, 1L, 6L, 3L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 1L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 2L, 2L, 6L, 6L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  3L, 3L, 8L, 8L, 11L, 11L, 9L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 6L, 6L, 4L, 11L,
  14L, 8L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 3L, 4L, 6L, 8L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L,
  2L, 1L, 1L, 3L, 6L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 2L, 0L, 0L, 1L, 1L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
  0L, 0L, 1L, 3L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 2L, 1L, 0L, 2L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 2L, 2L,
  3L, 3L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 2L, 4L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L,
  3L, 3L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 1L, 0L, 3L, 8L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 1L, 2L, 4L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 3L, 1L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 1L, 0L, 0L, 0L, 0L, 0L
), category = structure(c(
  1L, 2L, 3L,
  4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
  18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L,
  7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
  20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
  22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
  24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
  13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
  1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
  15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L,
  3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
  17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L,
  5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
  19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
  8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
  21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
  10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
  23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
  12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
  25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
  14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L,
  2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
  16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L,
  4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
  18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L,
  7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
  20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
  22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
  24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
  13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
  1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
  15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L,
  3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
  17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L,
  5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
  19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
  8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
  21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
  10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
  23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
  12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
  25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
  14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L,
  2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
  16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L,
  4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
  18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L,
  7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
  20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
  22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
  24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
  13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
  1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
  15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L,
  3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
  17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L,
  5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
  19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
  8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
  21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
  10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
  23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
  12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
  25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
  14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L,
  2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
  16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L,
  4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
  18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L,
  7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
  20L, 21L, 22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
  22L, 23L, 24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
  11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
  24L, 25L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
  13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L
), .Label = c(
  "", "1924 Chamonix", "1928 St. Moritz", "1932 Lake Placid",
  "1936 Garmisch-Partenkirchen", "1940 <i>Cancelled (Sapporo)</i>",
  "1944 <i>Cancelled (Cortina d'Ampezzo)</i>", "1948 St. Moritz",
  "1952 Oslo", "1956 Cortina d'Ampezzo", "1960 Squaw Valley", "1964 Innsbruck",
  "1968 Grenoble", "1972 Sapporo", "1976 Innsbruck", "1980 Lake Placid",
  "1984 Sarajevo", "1988 Calgary", "1992 Albertville", "1994 Lillehammer",
  "1998 Nagano", "2002 Salt Lake City", "2006 Turin", "2010 Vancouver",
  "2014 Sochi"
), class = "factor"), country = c(
  "Finland", "Finland",
  "Finland", "Finland", "Finland", "Finland", "Finland", "Finland",
  "Finland", "Finland", "Finland", "Finland", "Finland", "Finland",
  "Finland", "Finland", "Finland", "Finland", "Finland", "Finland",
  "Finland", "Finland", "Finland", "Finland", "Finland", "Austria",
  "Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
  "Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
  "Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
  "Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
  "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden",
  "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden",
  "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "Sweden",
  "Sweden", "Sweden", "Sweden", "Sweden", "Norway", "Norway", "Norway",
  "Norway", "Norway", "Norway", "Norway", "Norway", "Norway", "Norway",
  "Norway", "Norway", "Norway", "Norway", "Norway", "Norway", "Norway",
  "Norway", "Norway", "Norway", "Norway", "Norway", "Norway", "Norway",
  "Norway", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.",
  "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.",
  "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.", "U.S.",
  "U.S.", "U.S.", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "East Germany", "East Germany",
  "East Germany", "East Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "West Germany",
  "West Germany", "West Germany", "West Germany", "Germany", "Germany",
  "Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
  "Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
  "Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
  "Germany", "Germany", "Germany", "Germany", "Germany", "Netherlands",
  "Netherlands", "Netherlands", "Netherlands", "Netherlands", "Netherlands",
  "Netherlands", "Netherlands", "Netherlands", "Netherlands", "Netherlands",
  "Netherlands", "Netherlands", "Netherlands", "Netherlands", "Netherlands",
  "Netherlands", "Netherlands", "Netherlands", "Netherlands", "Netherlands",
  "Netherlands", "Netherlands", "Netherlands", "Netherlands", "Italy",
  "Italy", "Italy", "Italy", "Italy", "Italy", "Italy", "Italy",
  "Italy", "Italy", "Italy", "Italy", "Italy", "Italy", "Italy",
  "Italy", "Italy", "Italy", "Italy", "Italy", "Italy", "Italy",
  "Italy", "Italy", "Italy", "Canada", "Canada", "Canada", "Canada",
  "Canada", "Canada", "Canada", "Canada", "Canada", "Canada", "Canada",
  "Canada", "Canada", "Canada", "Canada", "Canada", "Canada", "Canada",
  "Canada", "Canada", "Canada", "Canada", "Canada", "Canada", "Canada",
  "Switzerland", "Switzerland", "Switzerland", "Switzerland", "Switzerland",
  "Switzerland", "Switzerland", "Switzerland", "Switzerland", "Switzerland",
  "Switzerland", "Switzerland", "Switzerland", "Switzerland", "Switzerland",
  "Switzerland", "Switzerland", "Switzerland", "Switzerland", "Switzerland",
  "Switzerland", "Switzerland", "Switzerland", "Switzerland", "Switzerland",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "Great Britain", "Great Britain", "Great Britain",
  "Great Britain", "France", "France", "France", "France", "France",
  "France", "France", "France", "France", "France", "France", "France",
  "France", "France", "France", "France", "France", "France", "France",
  "France", "France", "France", "France", "France", "France", "Hungary",
  "Hungary", "Hungary", "Hungary", "Hungary", "Hungary", "Hungary",
  "Hungary", "Hungary", "Hungary", "Hungary", "Hungary", "Hungary",
  "Hungary", "Hungary", "Hungary", "Hungary", "Hungary", "Hungary",
  "Hungary", "Hungary", "Hungary", "Hungary", "Hungary", "Hungary",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Unified Team", "Unified Team", "Unified Team",
  "Unified Team", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Soviet Union", "Soviet Union",
  "Soviet Union", "Soviet Union", "Russia", "Russia", "Russia",
  "Russia", "Russia", "Russia", "Russia", "Russia", "Russia", "Russia",
  "Russia", "Russia", "Russia", "Russia", "Russia", "Russia", "Russia",
  "Russia", "Russia", "Russia", "Russia", "Russia", "Russia", "Russia",
  "Russia", "Japan", "Japan", "Japan", "Japan", "Japan", "Japan",
  "Japan", "Japan", "Japan", "Japan", "Japan", "Japan", "Japan",
  "Japan", "Japan", "Japan", "Japan", "Japan", "Japan", "Japan",
  "Japan", "Japan", "Japan", "Japan", "Japan", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Czechoslovakia", "Czechoslovakia", "Czechoslovakia", "Czechoslovakia",
  "Poland", "Poland", "Poland", "Poland", "Poland", "Poland", "Poland",
  "Poland", "Poland", "Poland", "Poland", "Poland", "Poland", "Poland",
  "Poland", "Poland", "Poland", "Poland", "Poland", "Poland", "Poland",
  "Poland", "Poland", "Poland", "Poland", "Spain", "Spain", "Spain",
  "Spain", "Spain", "Spain", "Spain", "Spain", "Spain", "Spain",
  "Spain", "Spain", "Spain", "Spain", "Spain", "Spain", "Spain",
  "Spain", "Spain", "Spain", "Spain", "Spain", "Spain", "Spain",
  "Spain", "China", "China", "China", "China", "China", "China",
  "China", "China", "China", "China", "China", "China", "China",
  "China", "China", "China", "China", "China", "China", "China",
  "China", "China", "China", "China", "China", "South Korea", "South Korea",
  "South Korea", "South Korea", "South Korea", "South Korea", "South Korea",
  "South Korea", "South Korea", "South Korea", "South Korea", "South Korea",
  "South Korea", "South Korea", "South Korea", "South Korea", "South Korea",
  "South Korea", "South Korea", "South Korea", "South Korea", "South Korea",
  "South Korea", "South Korea", "South Korea", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Czech Republic", "Czech Republic", "Czech Republic", "Czech Republic",
  "Belarus", "Belarus", "Belarus", "Belarus", "Belarus", "Belarus",
  "Belarus", "Belarus", "Belarus", "Belarus", "Belarus", "Belarus",
  "Belarus", "Belarus", "Belarus", "Belarus", "Belarus", "Belarus",
  "Belarus", "Belarus", "Belarus", "Belarus", "Belarus", "Belarus",
  "Belarus", "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan",
  "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan",
  "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan",
  "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan",
  "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan", "Kazakhstan",
  "Kazakhstan", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria",
  "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria",
  "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria",
  "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria", "Bulgaria",
  "Bulgaria", "Bulgaria", "Bulgaria", "Denmark", "Denmark", "Denmark",
  "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark",
  "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark",
  "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark",
  "Denmark", "Denmark", "Denmark", "Denmark", "Ukraine", "Ukraine",
  "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine",
  "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine",
  "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine",
  "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Ukraine", "Australia",
  "Australia", "Australia", "Australia", "Australia", "Australia",
  "Australia", "Australia", "Australia", "Australia", "Australia",
  "Australia", "Australia", "Australia", "Australia", "Australia",
  "Australia", "Australia", "Australia", "Australia", "Australia",
  "Australia", "Australia", "Australia", "Australia", "Belgium",
  "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
  "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
  "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
  "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
  "Romania", "Romania", "Romania", "Romania", "Romania", "Romania",
  "Romania", "Romania", "Romania", "Romania", "Romania", "Romania",
  "Romania", "Romania", "Romania", "Romania", "Romania", "Romania",
  "Romania", "Romania", "Romania", "Romania", "Romania", "Romania",
  "Romania", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Liechtenstein", "Liechtenstein",
  "Liechtenstein", "Liechtenstein", "Yugoslavia", "Yugoslavia",
  "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia",
  "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia",
  "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia",
  "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia", "Yugoslavia",
  "Yugoslavia", "Yugoslavia", "Yugoslavia", "Luxembourg", "Luxembourg",
  "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg",
  "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg",
  "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg",
  "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg", "Luxembourg",
  "Luxembourg", "Luxembourg", "Luxembourg", "New Zealand", "New Zealand",
  "New Zealand", "New Zealand", "New Zealand", "New Zealand", "New Zealand",
  "New Zealand", "New Zealand", "New Zealand", "New Zealand", "New Zealand",
  "New Zealand", "New Zealand", "New Zealand", "New Zealand", "New Zealand",
  "New Zealand", "New Zealand", "New Zealand", "New Zealand", "New Zealand",
  "New Zealand", "New Zealand", "New Zealand", "North Korea", "North Korea",
  "North Korea", "North Korea", "North Korea", "North Korea", "North Korea",
  "North Korea", "North Korea", "North Korea", "North Korea", "North Korea",
  "North Korea", "North Korea", "North Korea", "North Korea", "North Korea",
  "North Korea", "North Korea", "North Korea", "North Korea", "North Korea",
  "North Korea", "North Korea", "North Korea", "Slovakia", "Slovakia",
  "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia",
  "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia",
  "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia",
  "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Slovakia", "Croatia",
  "Croatia", "Croatia", "Croatia", "Croatia", "Croatia", "Croatia",
  "Croatia", "Croatia", "Croatia", "Croatia", "Croatia", "Croatia",
  "Croatia", "Croatia", "Croatia", "Croatia", "Croatia", "Croatia",
  "Croatia", "Croatia", "Croatia", "Croatia", "Croatia", "Croatia",
  "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia",
  "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia",
  "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia",
  "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia", "Slovenia",
  "Slovenia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia",
  "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia",
  "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia",
  "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Latvia", "Estonia",
  "Estonia", "Estonia", "Estonia", "Estonia", "Estonia", "Estonia",
  "Estonia", "Estonia", "Estonia", "Estonia", "Estonia", "Estonia",
  "Estonia", "Estonia", "Estonia", "Estonia", "Estonia", "Estonia",
  "Estonia", "Estonia", "Estonia", "Estonia", "Estonia", "Estonia",
  "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan",
  "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan",
  "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan",
  "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan",
  "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan", "Uzbekistan"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(
  NA,
  -1100L
))
winter_olympics_data %>%
  hchart("streamgraph", hcaes(category, medals, group = country)) %>%
  hc_legend(enabled = FALSE) %>%
  hc_plotOptions(series = list(label = list(enabled = TRUE))) %>%
  hc_yAxis(visible = FALSE) %>%
  hc_xAxis(
    crosshair = TRUE,
    labels = list(
      align = "left",
      reserveSpace = FALSE,
      rotation = 270
    ), title = list(text = ""), lineWidth = 0,
    margin = 20,
    tickWidth = 0
  ) %>%
  hc_title(text = "Winter Olympics Medal Wins")

sunburst

A Sunburst displays hierarchical data, where a level in the hierarchy is represented by a circle. The center represents the root node of the tree. The visualization bears a resemblance to both treemap and pie charts.

library(dplyr)
data(gapminder, package = "gapminder")

gapminder_2007 <- gapminder::gapminder %>%
  filter(year == max(year)) %>%
  mutate(pop_mm = round(pop / 1e6))

dout <- data_to_hierarchical(gapminder_2007, c(continent, country), pop_mm)



hchart(dout, type = "sunburst")

tilemap

A tilemap series is a type of heatmap where the tile shapes are configurable.

structure(list(
  `hc-a2` = c(
    "AL", "AK", "AZ", "AR", "CA", "CO",
    "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS",
    "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE",
    "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA",
    "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI",
    "WY"
  ), name = c(
    "Alabama", "Alaska", "Arizona", "Arkansas", "California",
    "Colorado", "Connecticut", "Delaware", "District of Columbia",
    "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana",
    "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",
    "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri",
    "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey",
    "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
    "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina",
    "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia",
    "Washington", "West Virginia", "Wisconsin", "Wyoming"
  ), region = c(
    "South",
    "West", "West", "South", "West", "West", "Northeast", "South",
    "South", "South", "South", "West", "West", "Midwest", "Midwest",
    "Midwest", "Midwest", "South", "South", "Northeast", "South",
    "Northeast", "Midwest", "Midwest", "South", "Midwest", "West",
    "Midwest", "West", "Northeast", "Northeast", "West", "Northeast",
    "South", "Midwest", "Midwest", "South", "West", "Northeast",
    "Northeast", "South", "Midwest", "South", "South", "West", "Northeast",
    "South", "West", "South", "Midwest", "West"
  ), x = c(
    6, 0, 5,
    5, 5, 4, 3, 4, 4, 8, 7, 8, 3, 3, 3, 3, 5, 4, 6, 0, 4, 2, 2, 2,
    6, 4, 2, 4, 4, 1, 3, 6, 2, 5, 2, 3, 6, 4, 3, 2, 6, 3, 5, 7, 5,
    1, 5, 2, 4, 2, 3
  ), y = c(
    7, 0, 3, 6, 2, 3, 11, 9, 10, 8, 8, 0,
    2, 6, 7, 5, 5, 6, 5, 11, 8, 10, 7, 4, 6, 5, 2, 4, 2, 11, 10,
    3, 9, 9, 3, 8, 4, 1, 9, 11, 8, 4, 7, 4, 4, 10, 8, 1, 7, 5, 3
  ),
  value = c(
    4849377, 737732, 6745408, 2994079, 39250017, 5540545,
    3596677, 935614, 7288000, 20612439, 10310371, 1419561, 1634464,
    12801539, 6596855, 3107126, 2904021, 4413457, 4649676, 1330089,
    6016447, 6811779, 9928301, 5519952, 2984926, 6093000, 1023579,
    1881503, 2839099, 1326813, 8944469, 2085572, 19745289, 10146788,
    739482, 11614373, 3878051, 3970239, 12784227, 1055173, 4832482,
    853175, 6651194, 27862596, 2942902, 626011, 8411808, 7288000,
    1850326, 5778708, 584153
  )
), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -51L)) -> tile_map_usa


hchart(tile_map_usa, "tilemap", dataLabels = list(enabled = TRUE, format = "{point.hc-a2}")) %>%
  hc_chart(inverted = TRUE) %>%
  hc_colorAxis(
    dataClasses = list_parse(bind_rows(c(
      from = 0,
      to = 1000000,
      color = "#F9EDB3",
      name = "< 1M"
    ), c(
      from = 1000000,
      to = 5000000,
      color = "#FFC428",
      name = "1M - 5M"
    ), c(
      from = 5000000,
      to = 20000000,
      color = "#FF7987",
      name = "5M - 20M"
    ), c(
      from = 20000000,
      color = "#FF2371",
      name = "> 20M"
    )))
  ) %>%
  hc_title(
    text = "U.S. states by population in 2016"
  ) %>%
  hc_subtitle(
    text = "Source: Wikipedia"
  ) %>%
  hc_size(width = 600, height = 600)

timeline

The timeline series presents given events along a drawn line.

seq.Date(as.Date("1900-01-01"), as.Date("2000-01-01"), by = "year") %>%
  sample(10) %>%
  tibble(date = .) %>%
  mutate(date = datetime_to_timestamp(date)) %>%
  mutate(
    description = paste("event ", 1:nrow(.)),
    label = paste("event label", 1:nrow(.))
  ) %>%
  highcharter::hchart("timeline", hcaes(date), dataLabels = list(format = '<span style="color:{point.color}">● </span><span style="font-weight: bold;" >{point.x:%d %b %Y}</span><br/>{point.label} ', backgroundColor = "transparent",allowOverlap = FALSE)) %>%
  hc_xAxis(type = "datetime")

treemap

A treemap displays hierarchical data using nested rectangles. The data can be laid out in varying ways depending on options.

library(dplyr)
data(gapminder, package = "gapminder")

gapminder_2007 <- gapminder::gapminder %>%
  filter(year == max(year)) %>%
  mutate(pop_mm = round(pop / 1e6))

dout <- data_to_hierarchical(gapminder_2007, c(continent, country), pop_mm)



hchart(dout, type = "treemap")

vector

A vector plot is a type of cartesian chart where each point has an X and Y position, a length and a direction. Vectors are drawn as arrows.

vector_data <- structure(list(
  V1 = c(
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 10L, 10L, 10L, 10L, 10L,
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
    10L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 20L, 20L, 20L, 20L, 20L, 20L,
    20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
    25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
    25L, 25L, 25L, 25L, 25L, 25L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
    30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 35L,
    35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L,
    35L, 35L, 35L, 35L, 35L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L,
    40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 45L, 45L,
    45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L,
    45L, 45L, 45L, 45L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L,
    50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 55L, 55L, 55L,
    55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 55L,
    55L, 55L, 55L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L,
    60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 65L, 65L, 65L, 65L,
    65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L, 65L,
    65L, 65L, 70L, 70L, 70L, 70L, 70L, 70L, 70L, 70L, 70L, 70L, 70L,
    70L, 70L, 70L, 70L, 70L, 70L, 70L, 70L, 75L, 75L, 75L, 75L, 75L,
    75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L,
    75L, 80L, 80L, 80L, 80L, 80L, 80L, 80L, 80L, 80L, 80L, 80L, 80L,
    80L, 80L, 80L, 80L, 80L, 80L, 80L, 85L, 85L, 85L, 85L, 85L, 85L,
    85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L,
    90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L, 90L,
    90L, 90L, 90L, 90L, 90L, 90L, 95L, 95L, 95L, 95L, 95L, 95L, 95L,
    95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L
  ),
  V2 = c(
    5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L,
    60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L,
    25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L,
    85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L,
    50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L,
    15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L,
    75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L,
    40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L,
    5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L,
    65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L,
    30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L,
    90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L,
    55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L,
    20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L,
    80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L,
    45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L,
    10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L,
    70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L,
    35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L,
    95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L,
    60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L,
    25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L,
    85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L,
    50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L,
    15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L,
    75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L, 30L, 35L,
    40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L,
    5L, 10L, 15L, 20L, 25L, 30L, 35L, 40L, 45L, 50L, 55L, 60L,
    65L, 70L, 75L, 80L, 85L, 90L, 95L, 5L, 10L, 15L, 20L, 25L,
    30L, 35L, 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L,
    90L, 95L
  ), V3 = c(
    190L, 185L, 180L, 175L, 170L, 165L, 160L,
    155L, 150L, 145L, 140L, 135L, 130L, 125L, 120L, 115L, 110L,
    105L, 100L, 185L, 180L, 175L, 170L, 165L, 160L, 155L, 150L,
    145L, 140L, 135L, 130L, 125L, 120L, 115L, 110L, 105L, 100L,
    95L, 180L, 175L, 170L, 165L, 160L, 155L, 150L, 145L, 140L,
    135L, 130L, 125L, 120L, 115L, 110L, 105L, 100L, 95L, 90L,
    175L, 170L, 165L, 160L, 155L, 150L, 145L, 140L, 135L, 130L,
    125L, 120L, 115L, 110L, 105L, 100L, 95L, 90L, 85L, 170L,
    165L, 160L, 155L, 150L, 145L, 140L, 135L, 130L, 125L, 120L,
    115L, 110L, 105L, 100L, 95L, 90L, 85L, 80L, 165L, 160L, 155L,
    150L, 145L, 140L, 135L, 130L, 125L, 120L, 115L, 110L, 105L,
    100L, 95L, 90L, 85L, 80L, 75L, 160L, 155L, 150L, 145L, 140L,
    135L, 130L, 125L, 120L, 115L, 110L, 105L, 100L, 95L, 90L,
    85L, 80L, 75L, 70L, 155L, 150L, 145L, 140L, 135L, 130L, 125L,
    120L, 115L, 110L, 105L, 100L, 95L, 90L, 85L, 80L, 75L, 70L,
    65L, 150L, 145L, 140L, 135L, 130L, 125L, 120L, 115L, 110L,
    105L, 100L, 95L, 90L, 85L, 80L, 75L, 70L, 65L, 60L, 145L,
    140L, 135L, 130L, 125L, 120L, 115L, 110L, 105L, 100L, 95L,
    90L, 85L, 80L, 75L, 70L, 65L, 60L, 55L, 140L, 135L, 130L,
    125L, 120L, 115L, 110L, 105L, 100L, 95L, 90L, 85L, 80L, 75L,
    70L, 65L, 60L, 55L, 50L, 135L, 130L, 125L, 120L, 115L, 110L,
    105L, 100L, 95L, 90L, 85L, 80L, 75L, 70L, 65L, 60L, 55L,
    50L, 45L, 130L, 125L, 120L, 115L, 110L, 105L, 100L, 95L,
    90L, 85L, 80L, 75L, 70L, 65L, 60L, 55L, 50L, 45L, 40L, 125L,
    120L, 115L, 110L, 105L, 100L, 95L, 90L, 85L, 80L, 75L, 70L,
    65L, 60L, 55L, 50L, 45L, 40L, 35L, 120L, 115L, 110L, 105L,
    100L, 95L, 90L, 85L, 80L, 75L, 70L, 65L, 60L, 55L, 50L, 45L,
    40L, 35L, 30L, 115L, 110L, 105L, 100L, 95L, 90L, 85L, 80L,
    75L, 70L, 65L, 60L, 55L, 50L, 45L, 40L, 35L, 30L, 25L, 110L,
    105L, 100L, 95L, 90L, 85L, 80L, 75L, 70L, 65L, 60L, 55L,
    50L, 45L, 40L, 35L, 30L, 25L, 20L, 105L, 100L, 95L, 90L,
    85L, 80L, 75L, 70L, 65L, 60L, 55L, 50L, 45L, 40L, 35L, 30L,
    25L, 20L, 15L, 100L, 95L, 90L, 85L, 80L, 75L, 70L, 65L, 60L,
    55L, 50L, 45L, 40L, 35L, 30L, 25L, 20L, 15L, 10L
  ), V4 = c(
    18L,
    27L, 36L, 45L, 54L, 63L, 72L, 81L, 90L, 99L, 108L, 117L,
    126L, 135L, 144L, 153L, 162L, 171L, 180L, 27L, 36L, 45L,
    54L, 63L, 72L, 81L, 90L, 99L, 108L, 117L, 126L, 135L, 144L,
    153L, 162L, 171L, 180L, 189L, 36L, 45L, 54L, 63L, 72L, 81L,
    90L, 99L, 108L, 117L, 126L, 135L, 144L, 153L, 162L, 171L,
    180L, 189L, 198L, 45L, 54L, 63L, 72L, 81L, 90L, 99L, 108L,
    117L, 126L, 135L, 144L, 153L, 162L, 171L, 180L, 189L, 198L,
    207L, 54L, 63L, 72L, 81L, 90L, 99L, 108L, 117L, 126L, 135L,
    144L, 153L, 162L, 171L, 180L, 189L, 198L, 207L, 216L, 63L,
    72L, 81L, 90L, 99L, 108L, 117L, 126L, 135L, 144L, 153L, 162L,
    171L, 180L, 189L, 198L, 207L, 216L, 225L, 72L, 81L, 90L,
    99L, 108L, 117L, 126L, 135L, 144L, 153L, 162L, 171L, 180L,
    189L, 198L, 207L, 216L, 225L, 234L, 81L, 90L, 99L, 108L,
    117L, 126L, 135L, 144L, 153L, 162L, 171L, 180L, 189L, 198L,
    207L, 216L, 225L, 234L, 243L, 90L, 99L, 108L, 117L, 126L,
    135L, 144L, 153L, 162L, 171L, 180L, 189L, 198L, 207L, 216L,
    225L, 234L, 243L, 252L, 99L, 108L, 117L, 126L, 135L, 144L,
    153L, 162L, 171L, 180L, 189L, 198L, 207L, 216L, 225L, 234L,
    243L, 252L, 261L, 108L, 117L, 126L, 135L, 144L, 153L, 162L,
    171L, 180L, 189L, 198L, 207L, 216L, 225L, 234L, 243L, 252L,
    261L, 270L, 117L, 126L, 135L, 144L, 153L, 162L, 171L, 180L,
    189L, 198L, 207L, 216L, 225L, 234L, 243L, 252L, 261L, 270L,
    279L, 126L, 135L, 144L, 153L, 162L, 171L, 180L, 189L, 198L,
    207L, 216L, 225L, 234L, 243L, 252L, 261L, 270L, 279L, 288L,
    135L, 144L, 153L, 162L, 171L, 180L, 189L, 198L, 207L, 216L,
    225L, 234L, 243L, 252L, 261L, 270L, 279L, 288L, 297L, 144L,
    153L, 162L, 171L, 180L, 189L, 198L, 207L, 216L, 225L, 234L,
    243L, 252L, 261L, 270L, 279L, 288L, 297L, 306L, 153L, 162L,
    171L, 180L, 189L, 198L, 207L, 216L, 225L, 234L, 243L, 252L,
    261L, 270L, 279L, 288L, 297L, 306L, 315L, 162L, 171L, 180L,
    189L, 198L, 207L, 216L, 225L, 234L, 243L, 252L, 261L, 270L,
    279L, 288L, 297L, 306L, 315L, 324L, 171L, 180L, 189L, 198L,
    207L, 216L, 225L, 234L, 243L, 252L, 261L, 270L, 279L, 288L,
    297L, 306L, 315L, 324L, 333L, 180L, 189L, 198L, 207L, 216L,
    225L, 234L, 243L, 252L, 261L, 270L, 279L, 288L, 297L, 306L,
    315L, 324L, 333L, 342L
  )
), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -361L))
hchart(list_parse2(vector_data), type = "vector")

venn

A Venn diagram displays all possible logical relations between acollection of different sets. The sets are represented by circles, and the relation between the sets are displayed by the overlap or lack of overlap between them. The venn diagram is a special case of Euler diagrams, which can also be displayed by this series type.

highchart() %>%
  hc_chart(type = "venn") %>%
  hc_add_series(
    dataLabels = list(style = list(fontSize = "20px")),
    name = "Venn Diagram",
    data = list(
      list(
        name = "People who are<br>breaking my heart.",
        sets = list("A"), value = 5
      ),
      list(
        name = "People who are shaking<br> my confidence daily.",
        sets = list("B"), value = 5
      ),
      list(
        name = "Cecilia", sets = list("B", "A"), value = 1
      )
    )
  ) %>%
  hc_title(text = "Venn Diagram")
highchart() %>%
  hc_chart(type = "venn") %>%
  hc_add_series(
    name = "Euler Diagram",
    dataLabels = list(style = list(fontSize = "20px")),
    data = list(
      list(sets = list("A"), name = "Animals", value = 5),
      list(sets = list("B"), name = "Four Legs", value = 1),
      list(sets = list("B", "A"), value = 1),
      list(sets = list("C"), name = "Mineral", value = 2)
    )
  ) %>%
  hc_title(text = "Euler Diagram")

waterfall

A waterfall chart displays sequentially introduced positive or negative values in cumulative columns.

catch_all_data %>%
  hchart("waterfall", hcaes(color = color))

wordcloud

A word cloud is a visualization of a set of words, where the size and placement of a word is determined by how it is weighted.

tidytext::sentiments %>%
  filter(sentiment == "positive") %>%
  sample_n(200) %>%
  {
    bind_rows(., sample_n(., 100)) %>% bind_rows(sample_n(., 100))
  } %>%
  count(word) %>%
  hchart("wordcloud", hcaes(name = word, weight = n))

xrange

The X-range series displays ranges on the X axis, typically time intervals with a start and end date.

N <- 7

set.seed(1234)

df <- tibble(
  start = Sys.Date() + months(sample(10:20, size = N)),
  end = start + months(sample(1:3, size = N, replace = TRUE)),
  cat = rep(1:5, length.out = N) - 1,
  progress = round(stats::runif(N), 1)
) |>
  mutate_if(is.Date, datetime_to_timestamp)

hchart(
  df,
  "xrange",
  hcaes(x = start, x2 = end, y = cat, partialFill = progress),
  dataLabels = list(enabled = TRUE)
) %>%
  hc_xAxis(
    title = FALSE,
    type = "datetime"
  ) %>%
  hc_yAxis(
    title = FALSE,
    categories = c("Prototyping", "Development", "Testing", "Validation", "Modelling")
  )

grid

highchart() %>%
  hc_xAxis_multiples(structure(list(
    list(width = "50%"),
    list(opposite = FALSE, width = "45%", left = "55%")
  ), class = "hc_axis_list")) %>%
  hc_yAxis_multiples(structure(list(
    list(width = "32.68%", height = "100%"),
    list(opposite = TRUE, width = "65.36%", left = "32.68%", height = "49.505%", top = "0%"),
    list(opposite = TRUE, width = "65.36%", left = "32.68%", height = "49.505%", top = "50.495%")
  ), class = "hc_axis_list")) %>%
  hc_add_series(data = c(1, 3, 2), xAxis = 0, yAxis = 0) %>%
  hc_add_series(data = c(20, 40, 10), type = "area", xAxis = 1, yAxis = 1) %>%
  hc_add_series(data = c(200, 400, 500), xAxis = 1, yAxis = 2) %>%
  hc_add_series(data = c(500, 300, 400), type = "areaspline", xAxis = 1, yAxis = 2)
create_yaxis_horizontal <- function(naxis = 2, heights = 1, sep = 0.01, offset = 0, turnopposite = TRUE,
                                    ...) {
  pcnt <- function(x) paste0(x * 100, "%")
  heights <- rep(heights, length = naxis)
  heights <- (heights / sum(heights)) %>%
    map(function(x) {
      c(
        x,
        sep
      )
    }) %>%
    unlist() %>%
    head(-1) %>%
    {
      . / sum(.)
    } %>%
    round(5)
  tops <- cumsum(c(0, head(heights, -1)))
  tops <- pcnt(tops)
  heights <- pcnt(heights)
  dfaxis <- tibble(width = heights, left = tops, offset = offset)
  dfaxis <- dfaxis %>% dplyr::filter(seq_len(nrow(dfaxis)) %% 2 !=
    0)
  if (turnopposite) {
    ops <- rep_len(c(FALSE, TRUE), length.out = nrow(dfaxis))
    dfaxis <- dfaxis %>% mutate(opposite = ops)
  }
  dfaxis <- bind_cols(dfaxis, tibble(nid = seq(naxis), ...))
  axles <- list_parse(dfaxis)
  class(axles) <- "hc_axis_list"
  axles
}


highchart() %>%
  hc_xAxis_multiples(create_yaxis_horizontal(naxis = 3, turnopposite = FALSE)) %>%
  hc_yAxis_multiples(create_yaxis_horizontal(naxis = 3, lineWidth = 2, title = list(text = NULL), turnopposite = FALSE, opposite = c(FALSE, TRUE, TRUE))) %>%
  hc_add_series(data = c(1, 3, 2), xAxis = 0, yAxis = 0) %>%
  hc_add_series(data = c(20, 40, 10), type = "area", xAxis = 1, yAxis = 1) %>%
  hc_add_series(data = c(200, 400, 500), xAxis = 2, yAxis = 2) %>%
  hc_add_series(data = c(500, 300, 400), type = "areaspline", xAxis = 2, yAxis = 2)

charts with conflicts

These charts seem to run into javascript conflict errors when included with other highcharts plots, but otherwise are functional code.

arcdiagram

Arc diagram series is a chart drawing style in which the vertices of the chart are positioned along a line on the Euclidean plane and the edges are drawn as a semicircle in one of the two half-planes delimited by the line, or as smooth curves formed by sequences of semicircles.

arc_data <- structure(list(from = c(
  "Hamburg", "Hamburg", "Hamburg", "Hannover",
  "Hannover", "Berlin", "Berlin", "Berlin", "Berlin", "Berlin",
  "Berlin", "München", "München", "München", "München", "München",
  "Stuttgart", "Frankfurt", "Frankfurt", "Frankfurt", "Frankfurt",
  "Düsseldorf", "Düsseldorf", "Amsterdam", "Paris", "Paris",
  "Paris", "Paris", "Paris", "Paris", "Paris", "Paris", "Paris",
  "Nantes", "Bordeaux", "Nantes", "Milano", "Milano", "Milano",
  "Milano", "Milano", "Milano", "Torino", "Venezia", "Roma", "Roma",
  "Roma", "Catania"
), to = c(
  "Stuttgart", "Frankfurt", "München",
  "Wien", "München", "Wien", "München", "Stuttgart", "Frankfurt",
  "Köln", "Düsseldorf", "Düsseldorf", "Wien", "Frankfurt", "Köln",
  "Amsterdam", "Wien", "Wien", "Amsterdam", "Paris", "Budapest",
  "Wien", "Hamburg", "Paris", "Brest", "Nantes", "Bayonne", "Bordeaux",
  "Toulouse", "Montpellier", "Marseille", "Nice", "Milano", "Nice",
  "Lyon", "Lyon", "München", "Roma", "Bari", "Napoli", "Brindisi",
  "Lamezia Terme", "Roma", "Napoli", "Bari", "Catania", "Brindisi",
  "Milano"
), weight = c(
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
)), class = c(
  "tbl_df",
  "tbl", "data.frame"
), row.names = c(NA, -48L))

highchartzero() %>%
  hc_add_series(
    type = "arcdiagram", data = list_parse(arc_data),
    keys = c("from", "to", "weight")
  ) %>%
  hc_add_theme(hc_theme_darkunica()) %>%
  tagList(
    tags$script(src = "https://code.highcharts.com/modules/sankey.js"),
    tags$script(src = "https://code.highcharts.com/modules/arc-diagram.js"), .
  ) %>%
  htmltools::browsable()

bellcurve

A bell curve is an areaspline series which represents the probability density function of the normal distribution. It calculates mean and standard deviation of the base series data and plots the curve according to the calculated parameters.

c(
  3.5, 3, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.4, 3, 3, 4,
  4.4, 3.9, 3.5, 3.8, 3.8, 3.4, 3.7, 3.6, 3.3, 3.4, 3, 3.4, 3.5, 3.4, 3.2,
  3.1, 3.4, 4.1, 4.2, 3.1, 3.2, 3.5, 3.6, 3, 3.4, 3.5, 2.3, 3.2, 3.5, 3.8, 3,
  3.8, 3.2, 3.7, 3.3, 3.2, 3.2, 3.1, 2.3, 2.8, 2.8, 3.3, 2.4, 2.9, 2.7, 2, 3,
  2.2, 2.9, 2.9, 3.1, 3, 2.7, 2.2, 2.5, 3.2, 2.8, 2.5, 2.8, 2.9, 3, 2.8, 3,
  2.9, 2.6, 2.4, 2.4, 2.7, 2.7, 3, 3.4, 3.1, 2.3, 3, 2.5, 2.6, 3, 2.6, 2.3,
  2.7, 3, 2.9, 2.9, 2.5, 2.8, 3.3, 2.7, 3, 2.9, 3, 3, 2.5, 2.9, 2.5, 3.6,
  3.2, 2.7, 3, 2.5, 2.8, 3.2, 3, 3.8, 2.6, 2.2, 3.2, 2.8, 2.8, 2.7, 3.3, 3.2,
  2.8, 3, 2.8, 3, 2.8, 3.8, 2.8, 2.8, 2.6, 3, 3.4, 3.1, 3, 3.1, 3.1, 3.1, 2.7,
  3.2, 3.3, 3, 2.5, 3, 3.4, 3
) %>%
  {
    dat <- .
    highchartzero() %>%
      hc_yAxis_multiples(create_axis(naxis = 2, heights = c(2, 1))) %>%
      hc_xAxis_multiples(create_axis(naxis = 2, heights = c(2, 1))) %>%
      hc_add_series(data = dat, type = "scatter") %>%
      hc_add_series(data = dat, type = "bellcurve", baseSeries = 1, xAxis = 1, yAxis = 1) %>%
      hc_add_dependency("modules/histogram-bellcurve.js")
  }

networkgraph

A networkgraph is a type of relationship chart, where connnections(links) attracts nodes (points) and other nodes repulse each other.

data(karate, package = "igraphdata")
df <- igraph::as_data_frame(karate, what = "edges")

highchartzero() %>%
  hc_add_series(
    df,
    "networkgraph",
    hcaes(from = from, to = to, weight = weight),
    layoutAlgorithm = list(enableSimulation = TRUE)
  ) %>%
  hc_add_dependency("modules/networkgraph.js")

pareto

A pareto diagram is a type of chart that contains both bars and a linegraph, where individual values are represented in descending order by bars, and the cumulative total is represented by the line.

highchartzero() %>% 
  hc_add_series(type = "column",data = catch_all_data %>% select(x,y)) %>% hc_add_series(type = "pareto",data = catch_all_data %>% select(x,y),baseSeries = 1) %>% 

# catch_all_data %>%
#   select(x, y) %>%
#   hchart("pareto") %>%
  # hc_add_series(type = "pareto",baseSeries = 1L,
  #               tooltip = list(valueDecimals = 2)) %>%
  hc_tooltip(shared = TRUE) %>%
  hc_add_dependency("modules/pareto.js")

variablepie

A variable pie series is a two dimensional series type, where each point renders an Y and Z value. Each point is drawn as a pie slice where the size (arc) of the slice relates to the Y value and the radius of pie slice relates to the Z value.

highchartzero() %>%
  hc_add_series(type = "variablepie", data = catch_all_data) %>%
  hc_add_dependency("modules/variable-pie.js")

variwide

A variwide chart (related to marimekko chart) is a column chart with a variable width expressing a third dimension.

highchartzero() %>%
  hc_add_series(type = "variwide", data = catch_all_data) %>%
  hc_add_dependency("modules/variwide.js")

.Wrap { max-width: calc(max(1180px,85%)) !important; }

function resizedw(){
    $(".highchart, .highcharts-container, .highcharts-container > svg").each(function(){
    
      var chartHeight = $(this).height(), 
          chartWidth = $(this).find("rect").width(), 
          mainWidth = $(".Content").width(), 
          newHeight = Math.round(((chartHeight*.85) / chartWidth)*mainWidth);
         // "height": Math.round(((9 / 16) * mainWidth)) 
      //console.log(chartHeight,chartWidth,newHeight);
       
      $(this).css({"width":"100%","max-width": "100%"});
  })
}

var doit;
window.onresize = function(){
  clearTimeout(doit);
  doit = setTimeout(resizedw, 1000);
};

window.onload = function(){
  window.dispatchEvent(new Event('resize'));
}