πŸ“Š 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! πŸš€

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.

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 *