rhighchartsorganization

Organisational Chart with independent nodes


I would like to visualize my company´s organizational chart in an HTML Widget to replace the currently used drawn PDF.

In principle this seems feasible using the highchart or googleVis package. Unfortunately, the current org chart has some independent nodes that are placed next to the top level, see „Other Unit on the right/left“ in my example pictures.

Furthermore, there are even more independent nodes on the left hand side, see „other independent units“ in the first example picture. Those could be vertically aligned to one of the other nodes and just flow down. Alternatively, they could be another department with no connection to the top as in my second example picture.

Is there a good way to do this? MWE for the picture was taken from this questions: How can we plot Highcarts organization chart in R language?

Example Picture with manually added nodes enter image description here

Example picture with additional independent department enter image description here

MWE from other question:

library(highcharter)
library(dplyr)

highchart() %>%
  hc_chart(type = 'organization', inverted = TRUE) %>%
  hc_title(text = 'Highcharts Org Chart') %>%
  hc_add_series(
    name = 'Highsoft',
    data = list(
      list(from = 'Shareholders', to = 'Board'),
      list(from = 'Board', to = 'CEO'),
      list(from = 'CEO', to = 'CTO'),
      list(from = 'CEO', to = 'CPO'),
      list(from = 'CEO', to = 'CSO'),
      list(from = 'CEO', to = 'CMO'),
      list(from = 'CEO', to = 'HR'),
      list(from = 'CTO', to = 'Product'),
      list(from = 'CTO', to = 'Web'),
      list(from = 'CSO', to = 'Sales'),
      list(from = 'CMO', to = 'Market')
    ),
    levels = list(
      list(level = 0, color = 'silver', dataLabels = list(color = 'black'), height = 55),
      list(level = 1, color = 'silver', dataLabels = list(color = 'black'), height = 55),
      list(level = 2, color = '#980104'),
      list(level = 4, color = '#359154')
    ),
    nodes = list(
      list(id = 'Shareholders'),
      list(id = 'Board'),
      list(id = 'CEO', title = 'CEO', name = 'Grethe Hjetland', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132317/Grethe.jpg'),
      list(id = 'HR', title = 'HR/CFO', name = 'Anne Jorunn Fjarestad', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132314/AnneJorunn.jpg', column = 3, offset = '75%'),
      list(id = 'CTO', title = 'CTO', name = 'Christer Vasseng', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12140620/Christer.jpg', column = 4, layout = 'hanging'),
      list(id = 'CPO', title = 'CPO', name = 'Torstein Honsi', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12131849/Torstein1.jpg', column = 4),
      list(id = 'CSO', title = 'CSO', name = 'Anita Nesse', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132313/Anita.jpg', column = 4, layout = 'hanging'),
      list(id = 'CMO', title = 'CMO', name = 'Vidar Brekke', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/13105551/Vidar.jpg', column = 4, layout = 'hanging'),
      list(id = 'Product', name = 'Product developers'),
      list(id = 'Web', name = 'Web devs, sys admin'),
      list(id = 'Sales', name = 'Sales team'),
      list(id = 'Market', name = 'Marketing team')
    ),
    colorByPoint = TRUE,
    color = '#007ad0',
    dataLabels = list(color = 'white'),
    borderColor = 'white',
    nodeWidth = 65
  ) %>%
  hc_tooltip(outside = TRUE)

Solution

  • Simple illustration

    The simplest way to illustrate how this can be done is by simply removing the line list(from = 'CEO', to = 'CTO') from your example.

    library(highcharter)
    library(dplyr)
    
    highchart() %>%
      hc_chart(type = 'organization', inverted = TRUE) %>%
      hc_title(text = 'Highcharts Org Chart') %>%
      hc_add_series(
        name = 'Highsoft',
        data = list(
          list(from = 'Shareholders', to = 'Board'),
          list(from = 'Board', to = 'CEO'),
          #list(from = 'CEO', to = 'CTO'),
          list(from = 'CEO', to = 'CPO'),
          list(from = 'CEO', to = 'CSO'),
          list(from = 'CEO', to = 'CMO'),
          list(from = 'CEO', to = 'HR'),
          list(from = 'CTO', to = 'Product'),
          list(from = 'CTO', to = 'Web'),
          list(from = 'CSO', to = 'Sales'),
          list(from = 'CMO', to = 'Market')
        ),
        levels = list(
          list(level = 0, color = 'silver', dataLabels = list(color = 'black'), height = 55),
          list(level = 1, color = 'silver', dataLabels = list(color = 'black'), height = 55),
          list(level = 2, color = '#980104'),
          list(level = 4, color = '#359154')
        ),
        nodes = list(
          list(id = 'Shareholders'),
          list(id = 'Board'),
          list(id = 'CEO', title = 'CEO', name = 'Grethe Hjetland', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132317/Grethe.jpg'),
          list(id = 'HR', title = 'HR/CFO', name = 'Anne Jorunn Fjarestad', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132314/AnneJorunn.jpg', column = 3, offset = '75%'),
          list(id = 'CTO', title = 'CTO', name = 'Christer Vasseng', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12140620/Christer.jpg', column = 4, layout = 'hanging'),
          list(id = 'CPO', title = 'CPO', name = 'Torstein Honsi', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12131849/Torstein1.jpg', column = 4),
          list(id = 'CSO', title = 'CSO', name = 'Anita Nesse', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132313/Anita.jpg', column = 4, layout = 'hanging'),
          list(id = 'CMO', title = 'CMO', name = 'Vidar Brekke', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/13105551/Vidar.jpg', column = 4, layout = 'hanging'),
          list(id = 'Product', name = 'Product developers'),
          list(id = 'Web', name = 'Web devs, sys admin'),
          list(id = 'Sales', name = 'Sales team'),
          list(id = 'Market', name = 'Marketing team')
        ),
        colorByPoint = TRUE,
        color = '#007ad0',
        dataLabels = list(color = 'white'),
        borderColor = 'white',
        nodeWidth = 65
      ) %>%
      hc_tooltip(outside = TRUE)
    

    enter image description here

    This breaks the link between CEO and CTO but nodes remain in position because their position is specified in the column argument (which in the end rather corresponds to rows as the chart is inverted).

    Application to your objective

    So for the left/right other units:

    And for the independent units:

    library(highcharter)
    library(dplyr)
    
    highchart() %>%
      hc_chart(type = 'organization', inverted = TRUE) %>%
      hc_title(text = 'Highcharts Org Chart') %>%
      hc_add_series(
        name = 'Highsoft',
        data = list(
          # Added ###########
          list(from = 'OU1', to = 'OU1'),
          list(from = 'OU2', to = 'OU2'),
          ###################
          list(from = 'Shareholders', to = 'Board'),
          list(from = 'Board', to = 'CEO'),
          list(from = 'CEO', to = 'CTO'),
          list(from = 'CEO', to = 'CPO'),
          list(from = 'CEO', to = 'CSO'),
          list(from = 'CEO', to = 'CMO'),
          list(from = 'CEO', to = 'HR'),
          # Added #######################
          list(from = 'IUs', to = 'IU1'),
          list(from = 'IUs', to = 'IU2'),
          ###############################
          list(from = 'CTO', to = 'Product'),
          list(from = 'CTO', to = 'Web'),
          list(from = 'CSO', to = 'Sales'),
          list(from = 'CMO', to = 'Market')
        ),
        levels = list(
          list(level = 0, color = 'silver', dataLabels = list(color = 'black'), height = 55),
          list(level = 1, color = 'silver', dataLabels = list(color = 'black'), height = 55),
          list(level = 2, color = '#980104'),
          list(level = 4, color = '#359154')
        ),
        nodes = list(
          # Added #####
          list(id = 'OU1', name = "Other Unit 1", column = 0),
          list(id = 'OU2', name = "Other Unit 2", column = 0),
          ##############
          list(id = 'Shareholders'),
          list(id = 'Board'),
          list(id = 'CEO', title = 'CEO', name = 'Grethe Hjetland', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132317/Grethe.jpg'),
          list(id = 'HR', title = 'HR/CFO', name = 'Anne Jorunn Fjarestad', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132314/AnneJorunn.jpg', column = 3, offset = '75%'),
          # Added #####
          list(id = 'IUs', name = 'Independent units', column = 4, layout = 'hanging'),
          list(id = 'IU1', name = 'Independent units #1'),
          list(id = 'IU2', name = 'Independent units #2'),
          #############################################
          list(id = 'CTO', title = 'CTO', name = 'Christer Vasseng', color = '#007ad0', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12140620/Christer.jpg', column = 4, layout = 'hanging'),
          list(id = 'CPO', title = 'CPO', name = 'Torstein Honsi', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12131849/Torstein1.jpg', column = 4),
          list(id = 'CSO', title = 'CSO', name = 'Anita Nesse', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/12132313/Anita.jpg', column = 4, layout = 'hanging'),
          list(id = 'CMO', title = 'CMO', name = 'Vidar Brekke', image = 'https://wp-assets.highcharts.com/www-highcharts-com/blog/wp-content/uploads/2018/11/13105551/Vidar.jpg', column = 4, layout = 'hanging'),
          list(id = 'Product', name = 'Product developers'),
          list(id = 'Web', name = 'Web devs, sys admin'),
          list(id = 'Sales', name = 'Sales team'),
          list(id = 'Market', name = 'Marketing team')
        ),
        colorByPoint = TRUE,
        color = '#007ad0',
        dataLabels = list(color = 'white'),
        borderColor = 'white',
        nodeWidth = 65
      ) %>%
      hc_tooltip(outside = TRUE)
    

    enter image description here