Visualizing hierarchy is one of the most common requirements in enterprise applicationsβespecially for employee structures. In Oracle APEX, you can build an organisational chart in multiple ways depending on your UI needs.
In this blog, weβll explore two practical approaches:
- β Tree Region (Quick & Native)
- π Interactive Org Chart using JavaScript (Collapsible + Zoom + Modern UI)
πΉ Approach 1: Using Tree Region (Native APEX)
Oracle APEX provides a Tree Region to display hierarchical data using SQL.
SELECT
empno,
ename AS employee_name,
job AS title,
mgr AS manager_id
FROM emp;βοΈ Configuration
- Node Label Column β EMPLOYEE_NAME
- Node Value Column β EMPNO
- Hierarchy β Computed with SQL
- Node ID Column β EMPNO
- Parent Key Column β MANAGER_ID
- Start Tree With β Value is NULL
β Output
- Displays hierarchy in expandable tree format
- Simple and fast to implement
- Uses built-in APEX features
β Limitations
- Not visually appealing (no card layout)
- No zoom or drag
- Not suitable for modern dashboards
π Approach 2: Interactive Org Chart (Collapsible + Zoom)
To achieve a modern, visually rich organisational chart, we use JavaScript + AJAX + JSON.
πΉ Step 1: Add HTML Region
<div id="orgChart"></div>πΉ Step 2: Include JS Library
Add in Page β JavaScript β File URLs
https://balkan.app/js/OrgChart.jsπΉ Step 3: Create AJAX Callback
DECLARE
l_json CLOB;
BEGIN
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'id' VALUE empno,
'name' VALUE employee_name,
'title' VALUE title,
'pid' VALUE manager_id,
'tags' VALUE JSON_ARRAY(department)
)
)
INTO l_json
FROM (
SELECT
e.empno,
e.ename AS employee_name,
e.job AS title,
e.mgr AS manager_id,
d.dname AS department
FROM emp e
JOIN dept d ON e.deptno = d.deptno
);
HTP.P(l_json);
END;πΉ Step 4: JavaScript (Execute on Page Load)
apex.server.process("GET_ORG_DATA", {}, {
success: function(data) {
var chart = new OrgChart(document.getElementById("orgChart"), {
nodes: data,
nodeBinding: {
field_0: "name",
field_1: "title"
},
template: "ana",
collapse: {
level: 1
},
enableSearch: true,
mouseScrool: OrgChart.action.zoom,
zoom: {
speed: 120,
smooth: true
},
enableDragDrop: true
});
}
});π― Key Features Achieved
β Collapsible hierarchy
β Zoom in / Zoom out
β Drag to navigate
β Search employees
β Clean card-based UI
β Department-based customization (via tags)
π₯ Tree Region vs Org Chart
| Feature | Tree Region | JS Org Chart |
|---|---|---|
| Setup Time | β Fast | β οΈ Medium |
| UI | β Basic | β Modern |
| Collapsible | β Yes | β Yes |
| Zoom | β No | β Yes |
| Drag | β No | β Yes |
| Custom Styling | β Limited | β Full Control |
π‘ When to Use What?
π Use Tree Region when:
- You need quick implementation
- UI is not a priority
π Use Interactive Org Chart when:
- You want modern dashboards
- UX matters
- You need zoom, drag, styling
π Final Thoughts
While Oracle APEX provides powerful native components like Tree Region, integrating JavaScript libraries like OrgChart.js unlocks a whole new level of UI experience.
For enterprise-grade applications, the second approach is highly recommended as it delivers:
β¨ Better visualization
β¨ Improved user interaction
β¨ Scalable design
π Whatβs Next?
You can further enhance this solution by:
- Adding employee profile images π€
- Color-coding departments π¨
- Click β Navigate to employee detail page π
- Export org chart as PDF π
If you found this helpful, feel free to connect and share your thoughts! π
Love coding? Me too! Letβs keep in touch β subscribe to my website for regular chats on Oracle APEX, PL/SQL,SQL JavaScript, and CSS.



