0 Votes

Organization Chart Macro

Version 3.1 par john le 2026/01/03 16:48

Description

This macro allows to display an organization chart either from data provided as a wiki list, either from data provided as json, either from the users of the wiki using a "manager" field in the user profile.

To configure the XWiki fields, visit the OrgChartSetup page.

Macro Parameters

 Parameter Name  Description  Possible values  Default value
 source   list, json, xwiki  list if there is a content parameter, xwiki if not 
 content field  wiki list or json to use as data source  see examples  empty
 user  user to start the organizational chart in xwiki source mode any user document (XWiki.ID) If none provided the macro will look for the first user having no manager and being a manager of at least on person
 managerfield  name of the field used to store the manager of a person any users field in the XWiki.XWiki Users class manager
 titlefield  name of the field used to store the title of a person any field in the XWiki.XWikiUsers class title

Simple Organization Chart using an unordered list

{{orgchart}}
* Jef
** John
** Joe
*** Patrick
*** Marie
{{/orgchart}}

Simple Organization Chart using json

{{orgchart source="json"}}
  {
      'name': 'Lao Lao',
      'title': 'general manager',
      'children': [
        { 'name': 'Bo Miao', 'title': 'department manager' },
        { 'name': 'Su Miao', 'title': 'department manager',
          'children': [
            { 'name': 'Tie Hua', 'title': 'senior engineer' },
            { 'name': 'Hei Hei', 'title': 'senior engineer',
              'children': [
                { 'name': 'Dan Dan', 'title': 'engineer' }
              ]
            },
            { 'name': 'Pang Pang', 'title': 'senior engineer' }
          ]
        },
        { 'name': 'Hong Miao', 'title': 'department manager' }
      ]
   }
{{/orgchart}}

Organization Chart based on XWiki users

For this organization chart to work you need to create a field in the XWiki.XWikiUsers class to hold the manager of a user.
Also you need to provide the top of the organization chart to start with.

{{orgchart source="xwiki" user="XWiki.Admin" managerfield="manager" titlefield="title" /}}

XWiki can also find automatically a user that had reporters and no manager to start the tree

{{orgchart /}}