How to build an Organization Chart with highcharter

Viewed 950

I want to plot an organization chart with highcharter (or, optionally, with another R highchart plotting library). I know that there are already some questions about that topic but they seem outdated since highchart now offers the possibility of organization chart.

Edit: Due to the responses of raf18seb (thanks a lot for you insights), I tried to download the github version and run some code that mirrors the sankey logic. However, no plot is rendered:

devtools::install_github("jbkunst/highcharter")
library(highcharter)

highchart() %>%
  hc_chart(type = 'organization') %>%
  hc_add_series(
    data = list(
      list(from = 'Brazil', to = 'Portugal'),
      list(from = 'Brazil', to = 'Spain'),
      list(from = 'Poland', to = 'England'))
  )
2 Answers

Organization series was added to Highcharts from v7.1.0, but Highcharter uses v7.0.1.

After Highcharter is updated, you should be able to use Organization chart using below syntax:

Organization series inherits from Sankey.

And this R code works for Sankey:

library(highcharter)

highchart() %>%
  hc_chart(type = 'sankey') %>%
  hc_add_series(
    data = list(
      list(from = 'Brazil', to = 'Portugal', weight = 5),
      list(from = 'Brazil', to = 'Spain', weight = 2),
      list(from = 'Poland', to = 'England', weight = 2))
  )

So all you need to do is to change type: 'sankey' to type: 'organization'.

Tested here in JS: https://jsfiddle.net/BlackLabel/q8x06jga

Of course, you don't need weight value.

Thanks to the feature request by @raf18seb, currently we can build an organization chart as follows:

devtools::install_github("jbkunst/highcharter", ref = "720")
library(highcharter)

highchart() %>%
  hc_chart(type = 'organization') %>%
  hc_add_series(
    data = list(
      list(from = 'Brazil', to = 'Portugal'),
      list(from = 'Brazil', to = 'Spain'),
      list(from = 'Poland', to = 'England'))
  )
Related