A modern, high-performance, interactive visual hierarchy and organizational chart component for Angular and MemberJunction applications.
Built on top of D3 layout engines, --mj-* design tokens, and MemberJunction's metadata layer, this component visualizes any self-referencing entity hierarchy with smooth pan/zoom, collapsible sub-branches, live path search, subtree focus, drag-and-drop reparenting, and cancelable before/after lifecycle events.
ParentID, ParentCategoryID, ParentAccountID, etc.) and seamlessly handles single and composite primary keys.[+] / [-] badges displaying both direct child counts and total descendant subtree volume.BeforeNodeExpand, AfterNodeExpand, BeforeNodeCollapse, AfterNodeCollapse, BeforeReparent, and AfterReparent.--mj-* CSS design tokens for dark and light modes.RecordNavigationEvent for opening detail records in MemberJunction Explorer tabs.Import HierarchyTreeComponent (standalone) or HierarchyTreeModule into your Angular component:
import { Component } from '@angular/core';
import { HierarchyTreeComponent, HierarchyTreeConfig, HierarchyNodeEvent } from '@memberjunction/ng-hierarchy-tree';
import { FormNavigationEvent } from '@memberjunction/ng-base-forms';
@Component({
selector: 'app-org-chart',
standalone: true,
imports: [HierarchyTreeComponent],
template: `
<mj-hierarchy-tree
[Config]="treeConfig"
(NodeClick)="onNodeClick($event)"
(Navigate)="onNavigate($event)">
</mj-hierarchy-tree>
`
})
export class OrgChartComponent {
public treeConfig: HierarchyTreeConfig = {
EntityName: 'MJ_BizApps_Common: Organizations',
ParentField: 'ParentID',
SubtitleField: 'OrganizationType',
DefaultIcon: 'fa-solid fa-building',
DefaultColor: 'var(--mj-brand-primary)',
Height: '600px'
};
public onNodeClick(event: HierarchyNodeEvent): void {
console.log('Node selected:', event.Node.Name);
}
public onNavigate(event: FormNavigationEvent): void {
// Forward to NavigationService or Explorer FormComponent
}
}
HierarchyTreeConfig)| Property | Type | Default | Description |
|---|---|---|---|
EntityName |
string |
(Required) | The MemberJunction entity name to visualize (e.g. 'MJ_BizApps_Orders: Product Categories'). |
ParentField |
string |
'ParentID' |
Foreign key field pointing to the parent record. Auto-detected from metadata if omitted. |
NameField |
string |
Entity NameField |
Field to use for the main card title. |
SubtitleField |
string |
undefined |
Optional field for the secondary metadata tag or subtitle. |
IconField |
string |
undefined |
Optional field containing a dynamic Font Awesome icon class or image URL. |
DefaultIcon |
string |
'fa-solid fa-sitemap' |
Fallback icon when node does not specify one. |
ColorField |
string |
undefined |
Optional field for a dynamic accent color — a design token is preferred over a hex literal. |
DefaultColor |
string |
'var(--mj-brand-primary, #38bdf8)' |
Fallback accent color. Bound to an inline style, so a var() token resolves at paint time and follows the active theme. |
ExtraFilter |
string |
undefined |
SQL-like filter string applied to the RunView query (e.g. 'IsActive = 1'). |
OrderBy |
string |
'Name ASC' |
Sort order for sibling nodes. |
FocusRecordID |
string |
undefined |
Initial record ID to focus as subtree root. |
Orientation |
'top-to-bottom' | 'left-to-right' |
'top-to-bottom' |
Layout direction. |
ShowSearch |
boolean |
true |
Whether to display the live search input. |
ShowToolbar |
boolean |
true |
Whether to display the zoom and expansion controls toolbar. |
Height |
string |
'560px' |
Total container height. |
// Cancelable Event Example: Prevent collapsing root nodes
onBeforeNodeCollapse(event: CancelableHierarchyNodeEvent) {
if (event.Node.Depth === 0) {
event.Cancel('Root node must remain expanded');
}
}
NodeClick: EventEmitter<HierarchyNodeEvent>NodeDoubleClick: EventEmitter<HierarchyNodeEvent>NodeSelect: EventEmitter<HierarchyNodeEvent>BeforeNodeExpand: EventEmitter<CancelableHierarchyNodeEvent>AfterNodeExpand: EventEmitter<HierarchyNodeEvent>BeforeNodeCollapse: EventEmitter<CancelableHierarchyNodeEvent>AfterNodeCollapse: EventEmitter<HierarchyNodeEvent>BeforeReparent: EventEmitter<CancelableReparentEvent>AfterReparent: EventEmitter<ReparentEvent>NodeAction: EventEmitter<NodeActionEvent>Navigate: EventEmitter<FormNavigationEvent>Call public methods on HierarchyTreeComponent via @ViewChild:
@ViewChild(HierarchyTreeComponent) treeComponent!: HierarchyTreeComponent;
// Expansion
this.treeComponent.expandAll();
this.treeComponent.collapseAll();
// Navigation & Canvas
this.treeComponent.fitToScreen();
this.treeComponent.zoomIn();
this.treeComponent.zoomOut();
this.treeComponent.resetZoom();
// Focus & Subtrees
this.treeComponent.setFocusRoot('ORG-1234');
this.treeComponent.resetFocus();
// Export
const svgContent = this.treeComponent.exportAsSVG();
This component consumes standard --mj-* design tokens:
--mj-bg-surface-sunken: Canvas background--mj-bg-surface-card: Node card background--mj-border-default: Node borders & link curves--mj-text-primary: Node title text--mj-text-secondary: Subtitles & badges--mj-brand-primary: Focus indicators & search match highlights