Minimize and Maximize nodes in OrgChart JS

Minimize and Maximize nodes in OrgChart JS

Minimize and Maximize nodes in OrgChart JS: How to Use the Min Max Functionality in OrgChart JS to Show More or Less Chart Information

How to Use the Min Max Functionality in OrgChart JS to Show More or Less Chart Information

When working with large organizational or hierarchical charts, it’s often helpful to give users control over how much information they see. With OrgChart JS, you can easily implement expand/collapse functionality using the built-in min/max feature — allowing you to create clean, dynamic, and interactive visualizations.

In this post, we’ll walk through how to create a chart that lets users toggle between detailed and simplified node views with a single click.

Full Code Example

🧩 Step 1: Include OrgChart JS

First, include the OrgChart JS library and create a placeholder <div> for your chart:

<script src="https://cdn.balkan.app/orgchart.js"></script>
<div id="tree"></div>

🎨 Step 2: Define Node Templates

We’ll create a few custom templates to give each node a distinct look (yellow for root, orange for mid-level, blue for leaf nodes). Then, we define “minimized” versions of these templates — smaller, simpler shapes that show less detail when nodes are collapsed.

OrgChart.templates.orange.min = Object.assign({}, OrgChart.templates.dot);
OrgChart.templates.orange.min.size = [10, 100];
OrgChart.templates.orange.min.node = `
  <rect x="-3" y="20" fill="#1E1E1E" width="17" height="50"></rect>
  <circle fill="#F57C00" cx="5" cy="50" r="5"></circle>
`;

We do something similar for the blue nodes. The min property tells OrgChart JS which template to use when a node is minimized.


🌳 Step 3: Define the Node Data

Each node has an id, optional pid (parent ID), and tags that define how it should be rendered.

let nodes = [
  { id: 1, tags: ["yellow"], img: 'https://cdn.balkan.app/shared/1.jpg' },
  { id: 2, pid: 1, tags: ["orangeEdge"], img: 'https://cdn.balkan.app/shared/2.jpg' },
  { id: 3, pid: 1, tags: ["orange", "minimized"], img: 'https://cdn.balkan.app/shared/3.jpg' },
  // ...
];

The minimized tag determines which nodes start in a collapsed (minimal) state.


⚙️ Step 4: Initialize the Chart

Now we’ll initialize our chart and link the templates to their tags:

let chart = new OrgChart(document.getElementById("tree"), {
  mode: "dark",
  mouseScrool: OrgChart.action.none,
  enableSearch: false,
  siblingSeparation: 6,
  nodeBinding: { img: "img" },
  tags: {
    yellow: { template: "yellow" },
    orange: { template: "orange" },
    orangeEdge: { template: "orangeEdge" },
    blue: { template: "blue" },
    blueEdge: { template: "blueEdge" },
    minimized: { min: true }
  }
});

The important part is the last line:

minimized: { min: true }

It tells OrgChart JS that all nodes with the "minimized" tag should use their min template.


🖱️ Step 5: Toggle Min/Max on Click

Finally, we add a click handler that toggles nodes between minimized and maximized states.

chart.onNodeClick((args) => {
  if (args.node.min) {
    chart.maximize(args.node.id);
    chart.expand(args.node.id, args.node.childrenIds);
  } else {
    chart.minimize(args.node.id);
    chart.collapse(args.node.id, args.node.childrenIds);
  }
  return false;
});

When a node is minimized, clicking it will expand it — showing the full template and revealing its children. When it’s expanded, clicking it will collapse it again into a smaller form.


🧠 Why Use Min/Max?

The min/max functionality is incredibly useful when you have:

  • Large charts that would otherwise overflow the screen.
  • Complex hierarchies where you want to hide deeper branches initially.
  • Interactive dashboards where users can explore details on demand.

By minimizing less important branches, you improve performance and focus user attention on key relationships.


🏁 Final Thoughts

OrgChart JS makes it simple to create dynamic, visually appealing organizational charts that can scale gracefully. With the min/max feature, you can deliver both high-level overviews and deep structural insights — all in one intuitive interface.

Advanced template with Min/Max

Read more on Min/Max Doc Page

Copy an OrgChart to Clipboard

Copy OrgChart Data to Clipboard

Pan on Node Is Now the Default in OrgChart JS

Export 2 Charts in a Single PDF

Introducing Liquid Glass Buttons in OrgChart JS

OrgScribe: The Markdown-Style Way to Build Org Charts

Achieve Any OrgChart Design

Why Not Load on Demand in OrgChart JS

JSON Export Slinks with Nodes in OrgChart JS

OrgChart JS Privacy

GEDCOM in Family Tree JS 2

Update a JSON File with Family Tree Members

Hide Nodes in an OrgChart with CSS

Pin (set as root) a node in an OrgChart

WordPress OrgChart Plugin

Family Tree in WordPress

Organizational Charts with Multiple Parents

Introducing new PDF and PNG Previews in OrgChart JS

Building an Org Chart MVP

Introducing PowerPoint Preview in OrgChart JS

Change The Order in the OrgChart by Drag and Drop (Simple Example)

Highlight to the root on search in OrgChart JS

OrgChart JS Now Supports Export to PowerPoint

OrgChart JS Now Supports Export to PowerPoint

Dynamically changing an orgchart field

Project Timeline Chart

OrgChart Conditional Node Size

Add CSS on Export in OrgChart JS

OrgChart JS Angular Templates

Org Chart Web App with Node.js and Express

Loading on Demand with Family Tree JS 2

Dynamic Colors Organizational Chart

Charlie Chaplin Family Tree

Introducing Family Tree JS 2: The Next Generation is Here!

React OrgChart

Create and run an OrgChart Single Page Application with Node.js – beginner's guide.

Export and Import Org Chart to Excel

Adding Custom HTML Elements into OrgChart JS container

Еasily Create a Template in an OrgChart

Node Swapping in an Organizational Chart

Vladimir Putin Family Tree

Add Field Data in Expand button with OrgChart JS

Bill Gates Family Tree

Create a Tooltip for a ForeignObject Element Hover in OrgChart JS

Custom Aligning Nodes in a JavaScript Organizational Chart

Center and Zoom on Search Click in OrgChart JS

Create Multiline Group Titles in OrgChart JS

Adding Arrows in OrgChart JS Links

Show a Custom Edit Form for a node in OrgChart JS

Jeff Bezos Family Tree

How to Add Material Icons in OrgChart JS

Leonardo DiCaprio Family Tree

Visualizing Dual Reporting Structures with OrgChart JS

Exporting OrgChart JS to A4 PDF: A Step-by-Step Guide

Genghis Khan Family Tree: The Lineage of the Great Khan

OrgChart JS now support Export to Visio

New Export Option: childLevels in OrgChart JS

Elon Musk Family Tree

AI for OrgChart JS: Revolutionizing Organization Charts

Family Tree JS 2 (Preview)

d3 org chart

Our Family Tree App is Now on Android!

Why BALKAN OrgChart JS is the Best Organizational Chart Library

How to Create a JavaScript Flow Chart

How to Add an Organizational Chart to a Mobile Application

How to Create a JavaScript Organizational Chart

OrgChart JS Now Supports PDF Export Per Team

Introducing Family Tree App

Donald Trump Family Tree

Discover Your Roots: Build Your Family Tree with BALKAN App

JavaScript Organization Chart

Instantly create interactive, intuitive flowcharts in seconds

JavaScript Hierarchy Chart

Mermaid js alternative

Create Flowcharts in Seconds with Flow Chart JS: Your New Favorite JavaScript Library

Customizing Filter UI - Code of The Week

Zoom Slider - Code of The Week

Bookmarks - Code of The Week

Customizing Search Results - Code of The Week

Introducing Undo Redo - Code Of The Week

Price adjustment announcement

The price will increase for new customers

Buttons for adding family members to a family tree - Code of The Week

Levels - Code of The Week

Change node color from a button in the Edit Form - Code of The Week

Filter and Highlight Nodes - Code of The Week

Up Expanding - Code Of The Week

Programmatically move the chart - Code of The Week

Siblings in Family Tree JS - Code of The Week

Purple template - Code of The Week

Assistant With Children - Code of The Week

Conditional Layout - Code of The Week

Conditional Color - Code of the Week

Sriniz Family Tree Template - Code of The Week

Color Picker - Code of The Week

Add company logo as watermark in exported PDF documents - Code of The Week

Mind map - Code of The Week

Create relationship with circle menu - Code of The Week

Animated Photos - Code of the Week

Grouped Dotted Lines - Code Of The Week

Dotted Lines - Code Of The Week

Department Dynamic Title - Code Of The Week

Add expand button for partners - Code of the Week

Change the sub levels with Drag and Drop - Code of The Week

Custom Edit From using Popover - Code of the Week

Sub levels tag option - Code of the Week

Highlights search results directly on Org Chart nodes - Code of the Week

Code of the Week/Relationship maps and Business process diagrams

Search using field name abbreviations - Code of the Week

Dynamic Template - Code of the Week

Read and Write local CSV file using File API and Org Chart JS - Code of The Week

Organizational Chart Path Highlighting and Selection

Modern Template - Org Chart JS

Performance - Org Chart JS

Single parent is supported in Family Tree JS

How To Develop a Flowchart Maker with Org Chart JS

How to upload a photo to Family Tree JS in .NET core

How to change the color of selected node - Family Tree JS

Family Tree with live tiles

Error

BALKAN Blog

The Latest BALKAN App News and Releases. Latest information on Org Chart JS and Family Tree JS.