Giter Site home page Giter Site logo

ritesh83 / jquery.orgchart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bigeyex/jquery.orgchart

1.0 3.0 1.0 174 KB

jquery plugin for org chart, use a javascript array as input.

License: MIT License

HTML 15.84% CSS 21.72% JavaScript 62.44%

jquery.orgchart's Introduction

jquery.orgChart

jquery plugin for org chart, use a javascript array as input. inspired by https://github.com/caprica/jquery-orgchart

see a demo here

Usage

  1. set up a
    as the container of org chart:
<div id="orgChart"></div>
  1. prepare your data in this format:
var testData = [
    {id: 1, name: 'Acme Organization', parent: 0},
    {id: 2, name: 'CEO Office', parent: 1},
    {id: 3, name: 'Division 1', parent: 1},
    {id: 4, name: 'Division 2', parent: 1},
    {id: 6, name: 'Division 3', parent: 1},
    {id: 7, name: 'Division 4', parent: 1},
    {id: 8, name: 'Division 5', parent: 1},
    {id: 5, name: 'Sub Division', parent: 3},        
];

Every node is an object with (in minimum) id, name, and parent.

  1. build orgnizational chart with:
var orgChart = $('#orgChart').orgChart({data: testData});

the object return by the jQuery function could be used to invoke methods.

Option List

All the options are optional.

data: (Array) the initial data of the org chart.

showControls: (Boolean/false) on/off for display add or remove node button.

allowEdit: (Boolean/false) on/off for allowing users to click on the node's title to edit its name.

onAddNode(node): (Function) callback function when "Add Child" button is clicked. Note that this will prevent the node from automatically created, so developers need to call newNode(parentId) to actually create the node.

onDeleteNode(node): (Function) callback function when "Delete Node" button is clicked. Note that this will prevent the node from automatically deleted, so developers need to call deleteNode(id) to actually delete the node.

onClickNode(node): (Function) callback when a node is clicked.

onEditNode(node): (Function) callback when a node is edited.

newNodeText: (String/"Add Child") text displayed on the "Add Child" button.

Note that in the callback options "onAddNode", "onDeleteNode", "onClickNode", a Node object will be passed as the parameter. You can access the data via node.data.

Methods

startEdit(id): let a node enter edit mode.

newNode(parentId): create a node as a subnode of node number parentId.

addNode(data): add a node carrying specific data.

deleteNode(id): delete the node with specific id.

getData(): get all the node data of the org chart in an array.

License

MIT

jquery.orgchart's People

Contributors

bigeyex avatar kesali avatar ritesh83 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

kesali

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.