orgchart
Version:
Simple and direct organization chart(tree-like hierarchy) library based on pure DOM.
58 lines (55 loc) • 1.83 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>OrgChart Different Width Nodes Demo</title>
<link rel="icon" href="img/logo.png">
<link rel="stylesheet" href="css/orgchart.css">
<link rel="stylesheet" href="css/style.css">
<style type="text/css">
.orgchart .node .title {
width: auto;
}
.orgchart .node .content {
width: auto;
padding: 0 3px;
}
</style>
</head>
<body>
<section class="demo-notes">
<h1>Different Width Nodes Demo</h1>
<p>This demo removes fixed title and content widths so node sizing follows the actual text length.</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': 'Lorem ipsum dolor sit amet',
'children': [
{ 'name': 'Bo Miao', 'title': 'consectetur adipiscing elit' },
{ 'name': 'Su Miao', 'title': 'Nulla accumsan, metus ultrices eleifend gravida',
'children': [
{ 'name': 'Tie Hua', 'title': 'nulla nunc varius lectus, nec rutrum justo nibh eu lectus' },
{ 'name': 'Hei Hei', 'title': 'Ut vulputate semper dui',
'children': [
{ 'name': 'Dan Dan', 'title': 'Fusce erat odio, sollicitudin vel erat vel' }
]
},
{ 'name': 'Pang Pang', 'title': 'interdum mattis neque' }
]
},
{ 'name': 'Hong Miao', 'title': 'Curabitur accumsan turpis pharetra augue tincidunt blandit' }
]
};
const oc = new OrgChart({
chartContainer: '#chart-container',
'data' : datasource,
'nodeContent': 'title'
});
});
</script>
</body>
</html>