๐Ÿ“Š Building an Interactive Organisational Chart in Oracle APEX (2 Powerful Approaches)

๐Ÿ“Š Building an Interactive Organisational Chart in Oracle APEX (2 Powerful Approaches)

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:

  1. โœ… Tree Region (Quick & Native)
  2. ๐Ÿš€ 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

FeatureTree RegionJS 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! ๐Ÿš€

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *