UNPKG

orgchart

Version:

Simple and direct organization chart(tree-like hierarchy) plugin based on pure DOM and jQuery.

103 lines (96 loc) 3.32 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Organization Chart Plugin</title> <link rel="icon" href="img/logo.png"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.css"> <link rel="stylesheet" href="css/jquery.orgchart.css"> <link rel="stylesheet" href="css/style.css"> <style type="text/css"> #chart-container { position: absolute; top: 10px; left:40px; height: auto; max-height: 330px; width: calc(100% - 80px); z-index: 1; border-color: rgba(217, 83, 79, 0.9); } .orgchart { background: rgba(255,255,255,0.75); } </style> </head> <body id="pageBody"> <div id="chart-container"></div> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.js"></script> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.orgchart.js"></script> <script type="text/javascript"> $(function() { var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'watercolor' }), preload: 4 }), new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'terrain-labels' }), preload: 1 }) ], target: 'pageBody', view: new ol.View({ center: ol.proj.transform([-87.6297980, 41.8781140], 'EPSG:4326', 'EPSG:3857'), zoom: 10 }) }); $('body').prepend(map.getViewport()); var datascource = { 'name': 'Lao Lao', 'title': 'President Office', 'position': [-87.6297980, 41.8781140], 'children': [ { 'name': 'Bo Miao', 'title': 'Administration Dept.', 'position': [-83.0457540, 42.3314270]}, { 'name': 'Su Miao', 'title': 'R & D Dept.', 'position': [-81.6943610, 41.4993200]}, { 'name': 'Yu Jie', 'title': 'Product Dept.', 'position': [-71.0588800, 42.3600820]}, { 'name': 'Yu Li', 'title': 'Legal Dept.', 'position': [-74.0059410, 40.7127840]}, { 'name': 'Hong Miao', 'title': 'Finance Dept.', 'position': [-80.8431270, 35.2270870]}, { 'name': 'Yu Wei', 'title': 'Security Dept.', 'position': [-81.6556510, 30.3321840]}, { 'name': 'Chun Miao', 'title': 'HR Dept. ', 'position': [-81.3792360, 28.5383350]}, { 'name': 'Yu Tie', 'title': 'Marketing Dept.', 'position': [-80.1917900, 25.7616800] } ] }; $('#chart-container').orgchart({ 'data' : datascource, 'nodeContent': 'title', 'createNode': function($node, data) { $node.on('click', function() { var view = map.getView(); var duration = 2000; var start = +new Date(); var pan = ol.animation.pan({ duration: duration, source: view.getCenter(), start: start }); var bounce = ol.animation.bounce({ duration: duration, resolution: 4 * view.getResolution(), start: start }); map.beforeRender(pan, bounce); view.setCenter(ol.proj.transform(data.position, 'EPSG:4326', 'EPSG:3857')); }); } }); }); </script> </body> </html>