Update for Org Chart 4.
//If loading of a chart is initial
api.onInitialLoadingFinished(function () {
//Show loading panel before expanding
api.showLoadingPanel();
//Get account name of a current user
api.dataProvider.getCurrentUserAccountName(function (accountName) {
//Get an object with data of the current user
api.dataProvider.getBoxGroupItemDataById(accountName, function (dataItem) {
//If the current user has sombody above him (as a manager)
if (dataItem.parentId != "") {
//Drill down to the manager
api.drillDown(dataItem.parentId);
}
});
});
api.dataProvider.getCurrentUserAccountName(function (accountName) {
api.dataProvider.getBoxGroupItemDataById(accountName, function (dataItem) {
api.expandNodeLevelsConditionally(
//Expand 3 nodes: the one of the manager at the top, of the current user and of subordinates of the current user
3,
function (itemData) {
//Expand node if it is the current user or it has the current user as a manager or it is the manager of the current user
return itemData.AccountName == dataItem.id || itemData.Manager == dataItem.id || itemData.AccountName == dataItem.parentId;
},
function () {
//Hide loading panel after expanding
api.hideLoadingPanel();
}
);
});
});
});