orgchart
Version:
Simple and direct organization chart(tree-like hierarchy) library based on pure DOM.
49 lines (46 loc) • 1.46 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>OrgChart Local Datasource Demo</title>
<link rel="icon" href="img/logo.png">
<link rel="stylesheet" href="css/orgchart.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<section class="demo-notes">
<h1>Local Datasource Demo</h1>
<p>This demo builds the chart directly from a local JSON datasource embedded in the page.</p>
</section>
<div id="chart-container"></div>
<script type="text/javascript" src="js/orgchart.js"></script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
const datasource = {
'name': 'Lao Lao',
'title': 'general manager',
'children': [
{ 'name': 'Bo Miao', 'title': 'department manager' },
{ 'name': 'Su Miao', 'title': 'department manager',
'children': [
{ 'name': 'Tie Hua', 'title': 'senior engineer' },
{ 'name': 'Hei Hei', 'title': 'senior engineer',
'children': [
{ 'name': 'Dan Dan', 'title': 'engineer' }
]
},
{ 'name': 'Pang Pang', 'title': 'senior engineer' }
]
},
{ 'name': 'Hong Miao', 'title': 'department manager' }
]
};
const oc = new OrgChart({
chartContainer: '#chart-container',
'data' : datasource,
'nodeContent': 'title'
});
});
</script>
</body>
</html>