I'm trying to use this organization chart library at http://www.getorgchart.com
With few nodes works flawless, however, when I try to load the entire organization (around 1100 subjects with several nested levels) I get this console error:
Uncaught TypeError: Cannot read property '_aZ' of null
And fails to display the chart.
Any help will be apreciated. Thanks!
After some research, I've solved this.
The problem is that you need your dataSource ordered by parents first (this is not stated in the documentation); let's look at this example in the initialize on the client online demo:
$('#people').getOrgChart({
theme: "vivian",
primaryColumns: ["name", "title", "phone", "mail", "postcode"],
imageColumn: "image",
gridView: true,
dataSource:[
{ id: 1, parentId: null, name: "Elizabeth Horton", title: "Founder", phone: "(03) 9252 4642" , image: "images/f-46.jpg", mail:"elizabeth.horton@live.com", postcode: "PH2 2SR" },
{ id: 2, parentId: 1, name: "Emily Horton", title: "Fork lift operator", phone: "(08) 9015 4407", image: "images/f-45.jpg", mail:"emily.horton@live.com", postcode: "BA5 0AP" },
{ id: 3, parentId: 1, name: "Robert Nolan", title: "Blockmason", phone: "(02) 6747 7998", image: "images/f-41.jpg", mail:"robert.nolan@live.com", postcode: "BH9 4NG" },
{ id: 4, parentId: 1, name: "Callum Anderson", title: "System operator", phone: "(03) 5314 0473", image: "images/f-43.jpg", mail:"callum.anderson@live.com", postcode: "HR6 8ZF" },
{ id: 5, parentId: 4, name: "Courtney John", title: "System operator", phone: "(03) 5314 0473", image: "images/f-42.jpg", mail:"courtney.john@live.com", postcode: "OL4 6WF" }
]
});
If I change the order of Elizabeth Horton who is the head of the organization to the bottom of the dataSource like:
$('#people').getOrgChart({
theme: "vivian",
primaryColumns: ["name", "title", "phone", "mail", "postcode"],
imageColumn: "image",
gridView: true,
dataSource:[
{ id: 2, parentId: 1, name: "Emily Horton", title: "Fork lift operator", phone: "(08) 9015 4407", image: "images/f-45.jpg", mail:"emily.horton@live.com", postcode: "BA5 0AP" },
{ id: 3, parentId: 1, name: "Robert Nolan", title: "Blockmason", phone: "(02) 6747 7998", image: "images/f-41.jpg", mail:"robert.nolan@live.com", postcode: "BH9 4NG" },
{ id: 4, parentId: 1, name: "Callum Anderson", title: "System operator", phone: "(03) 5314 0473", image: "images/f-43.jpg", mail:"callum.anderson@live.com", postcode: "HR6 8ZF" },
{ id: 5, parentId: 4, name: "Courtney John", title: "System operator", phone: "(03) 5314 0473", image: "images/f-42.jpg", mail:"courtney.john@live.com", postcode: "OL4 6WF" },
{ id: 1, parentId: null, name: "Elizabeth Horton", title: "Founder", phone: "(03) 9252 4642" , image: "images/f-46.jpg", mail:"elizabeth.horton@live.com", postcode: "PH2 2SR" }
]
});
I got this error:
Uncaught TypeError: Cannot read property '_aZ' of null
So I hope that answering my own question helps other people with the same problem.
Cheers!