Create Organizational Chart with Pure JavaScript – js-orgChart-2

Category: Chart & Graph , Javascript | May 26, 2015
Author:rchockxm
Views Total:19,830 views
Official Page:Go to website
Last Update:May 26, 2015
License:MIT

Preview:

Create Organizational Chart with Pure JavaScript – js-orgChart-2

Description:

A multi-purpose JavaScript library that lets you generate a highly customizable organizational chart on your web page. You can find more interactive examples in the zip.

How to use it:

Load the js-orgchart-2.js JavaScript library in the html page.

<script src="path/to/js-orgchart-2.js"></script>

Create an empty element that will serve as the container for your organizational chart.

<div id="orgchart"></div>

Create params for the organizational chart.

var chartParams = {
    options: {
        top: 12,
        left: 12,
        line: {
          size: 2,
          color: "#3388dd"
        },
        node: {
          width: 128,
          height: 128,
          maxWidth: 128,
          maxHeight: 128,
          template: "<div id=\"{id}\"><img class=\"node-image\" src=\"images/avatar/{imgAvatar}\" /></div>"
        }
    },
    event: {
        node: {
          onProcess: function(node, nodes) {
              console.log("node.onProcess");
          },
          onClick: function() {
              console.log("node.onClick");
          },
          onMouseMove: function() {
              console.log("node.onMouseMove");
          },
          onMouseOver: function() {
              console.log("node.onMouseOver");
          },
          onMouseOut: function() {
              console.log("node.onMouseOut");
          }
        },
        onCreate: function() {
          console.log("onCreate");
        },
        onError: null,
        onFinish: function() {
          console.log("onFinish");
        }
    },
    nodes: pOrgNodes
};

Create OrgChartV2.

var pChart = new OrgChartV2(chartParams);

Initialization.

pChart.render();

You Might Be Interested In:


One thought on “Create Organizational Chart with Pure JavaScript – js-orgChart-2

  1. Janakiramulu Gandham

    how to achieve the chart with predefined hierarchy of nodes from JSON file

    Reply

Leave a Reply