How to build an Organization Chart with highcharter [duplicate]
Asked Answered
D

2

3

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'))
  )
Diagonal answered 24/10, 2019 at 11:21 Comment(0)
D
1

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'))
  )
Diagonal answered 26/10, 2019 at 21:11 Comment(0)
E
2

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.

Edacity answered 24/10, 2019 at 11:52 Comment(5)
I checked the github version and to me it looks like they updated highcharter to use v7.2.0. After installing the dev version from github it could be used, couldnt it? However, I still have no clue about the syntax. Using the code above just yields the error "The quosure environment should be explicitly supplied as env" which seems rather unrelated to highcharterDiagonal
Unfortunately, no plot is rendered. I updated my question with the code I used.Diagonal
I created a ticket on Highcharter repo: github.com/jbkunst/highcharter/issues/567 I'll let you know if I get any feedback. You can follow the above ticket tooEdacity
Thank you! I was going to to the same :)Diagonal
The problem has been solved on a dev branch and I postet an answer myself. I appreciate your effort!Diagonal
D
1

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'))
  )
Diagonal answered 26/10, 2019 at 21:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.