highcharter (version 0.7.0)

hc_add_series_treemap: Shortcut for create treemaps

Description

This function helps to create highcharts treemaps from treemap objects from the package treemap.

Usage

hc_add_series_treemap(hc, tm, ...)

Arguments

hc

A highchart htmlwidget object.

tm

A treemap object from the treemap package.

...

Additional shared arguments for the data series (http://api.highcharts.com/highcharts#series).

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
library("treemap")
library("viridis")

data(GNI2014)
head(GNI2014)

tm <- treemap(GNI2014, index = c("continent", "iso3"),
              vSize = "population", vColor = "GNI",
              type = "comp", palette = rev(viridis(6)),
              draw = FALSE)

highchart(height = 800) %>% 
  hc_add_series_treemap(tm, allowDrillToNode = TRUE,
                       layoutAlgorithm = "squarified",
                       name = "tmdata") %>% 
   hc_title(text = "Gross National Income World Data") %>% 
   hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
                             Pop: {point.value:,.0f}<br>
                             GNI: {point.valuecolor:,.0f}")

# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace