Code Monkey home page Code Monkey logo

orgchart's Introduction

OrgChart

Foreword

First of all, thanks a lot for wesnolte's great work:blush: -- jOrgChart. The thought that using nested tables to build out the tree-like orgonization chart is amazing. This idea is more simple and direct than its counterparts based on svg Unfortunately, it's long time not to see the update of jOrgChart. on the other hand, I got some interesting ideas to add, so I choose to create a new repo.

  • Since version 3.0, we use nested ul to construct tree-like chart instead of nested table.
  • Since version 4.0, users build up the ajax datasoure by themselves.

Features

  • Supports both local data and remote data (JSON).
  • Smooth expand/collapse effects based on CSS3 transitions.
  • Align the chart in 4 orientations.
  • Allows user to change orgchart structure by drag/drop nodes.
  • Allows user to edit orgchart dynamically and save the final hierarchy as a JSON object.
  • Supports exporting chart as a picture or pdf document.
  • Supports pan and zoom.
  • Allows user to customize the internal structure for every node.
  • Users can adopt multiple solutions to build up a huge organization chart(please refer hybrid layout sections).
  • touch-enabled plugin for mobile device.

CDN

Users could find the related CDN support for OrgChart's CSS and JavaScript.

cdnjs https://cdnjs.com/libraries/orgchart

Installation

Of course, you can directly use the standalone build by including dist/js/jquery.orgchart.js and dist/css/jquery.orgchart.css in your webapps.

Install with Bower

# From version 1.0.2 on, users can install orgchart and add it to bower.json dependencies
$ bower install orgchart

Install with npm

# From version 1.0.4 on, users can install orgchart with npm
$ npm install orgchart

require('orgchart') will load orgchart plugin onto the jQuery object. The orgchart module itself does not export anything.

online demos

ondemand-loading-data

Note: users use should set the relationship property of datasource by themselves. All of these staff are used to generate the correct expanding/collapsing arrows for nodes.

Here, we need the help from html2canvas.

Note:

(1) if you wanna export something in IE or Edge, please introduce es6-promise.auto.js firstly.

(2) if your OS is windows, please check your display scaling settings. For the perfact exported picture, you'd better adjust "Change the size of text, apps, and other items" to 100%.(thanks for sayamkrai's exploration)

(3) Besides, if you wanna export a pdf format or your orgchart includes picture, you have to introduce jspdf and set "exportFileextension" option to "pdf".

You need to set crossorigin to anonymous for your img tags.

export-chart-with-pictures

Here, we fall back on OpenLayers. It's the most aewsome open-source js library for Web GIS you sholdn't miss.

With the help of exposed core methods(addParent(), addSiblings(), addChildren(), removeNodes()) of orgchart plugin, we can finish this task easily.

Users are allowed to drag & drop the nodes of orgchart when option "draggable" is assigned to true(Note: this feature doesn't work on IE due to its poor support for HTML5 drag & drop API).

Furthermore, users can make use of option dropCriteria to inject their custom limitations on drag & drop. As shown below, we don't want an manager employee to be under a engineer under no circumstance.

That's where getHierarchy() comes in.

It's a so easy task, we just need to append id or className property to node data.

This feature is inspired by the issues(Aligning Children Vertical, Hybrid(horizontal + vertical) OrgChart). Thank mfahadi and Destructrix for their constructive suggestions:blush: Special thanks to tedliang for his wonderful hybrid mode solution.

From now on, users never have to worry about how to align a huge of nodes in one screen of browser. The option "verticalLevel" allows users to align child nodes vertically from the given level.

Note: currently, this option is incompatible with many other options or methods, like direction, drag&drop, addChildren(), removeNodes(), getHierarchy() and so on. These conflicts will be solved one by one in the later versions.

No problem. You just need to adjust a little detail of datasource with the help of option "collapse" and className "slide-up".

It's not a big deal. You just turn to the method init().

No problem. With the help of ES6 Template literals, we can customize the any complex node structure rather than the common title and content sections.

level-offset

You need the solution based on new datasource structure with levelOffset data prop + callback createNode() + CSS custom properties(variables)

nodes-of-different-widths

data-prop-hybrid

hybrid data property is designed for your use case. Once node data includes a "hybrid" prop with truthy value, its descendant nodes will be arranged vertically.

data-prop-compact

compact data property is designed for your use case. Once node data includes a "compact" prop with truthy value, itself and its descendant nodes will be arranged with compact mode.

how to start up demos locally

  • you have to install node.js v6+ because our unit tests are based on jsdom v11
  • you have to install modern browsers because many behaviors of orgchart plugin are based on HTML5 and CSS3
  • run npm install to install necessary dependencies
  • run npm test to run all tests including unit tests, integration tests and e2e tests
  • run npm run build to generate production js&css files of plugin
  • run npm start to start up local web server to host all the demos

Usage

Instantiation Statement

var oc = $('#chartContainerId').orgchart(options);

Structure of Datasource

{
  'id': 'rootNode', // It's a optional property which will be used as id attribute of node
  // and data-parent attribute, which contains the id of the parent node
  'collapsed': true, // By default, the children nodes of current node is hidden.
  'className': 'top-level', // It's a optional property
  // which will be used as className attribute of node.
  'nodeTitle': 'name', // This property is used to retrieve “title” value in datasource
  'nodeContent': 'title',// This property is used to retrieve "content" value in datasource
  'relationship': relationshipValue, // Note: when you activate ondemand loading nodes feature,
  // you should use json datsource (local or remote) and set this property.
  // This property implies that whether this node has parent, siblings, children.
  // relationshipValue is a string composed of three "0/1" identifier.
  // First character stands for wether current node has parent node;
  // Scond character stands for wether current node has siblings nodes;
  // Third character stands for wether current node has children node.
  'children': [ // The property stands for nested nodes.
    { 'name': 'Bo Miao', 'title': 'department manager', 'relationship': '110' },
    { 'name': 'Su Miao', 'title': 'department manager', 'relationship': '111',
      'children': [
        { 'name': 'Tie Hua', 'title': 'senior engineer', 'relationship': '110' },
        { 'name': 'Hei Hei', 'title': 'senior engineer', 'relationship': '110' }
      ]
    },
    { 'name': 'Yu Jie', 'title': 'department manager', 'relationship': '110' }
  ],
  'otherPro': anyValue // feel free to append any useful properties
};

Data Props

Name Type Description
hybrid truthy value nodes will be arranged vertically if this property is set to true
compact truthy value node will be rendered with compact mode if this property is set to true

Options

Name Type Required Default Description
data json or jquery object yes datasource usded to build out structure of orgchart. It could be a json object or a jquery object(ul element)
pan boolean no false Users could pan the orgchart by mouse drag&drop if they enable this option.
zoom boolean no false Users could zoomin/zoomout the orgchart by mouse wheel if they enable this option.
zoominLimit number no 7 Users are allowed to set a zoom-in limit.
zoomoutLimit number no 0.5 Users are allowed to set a zoom-out limit.
direction string no "t2b" The available values are t2b(implies "top to bottom", it's default value), b2t(implies "bottom to top"), l2r(implies "left to right"), r2l(implies "right to left").
verticalLevel integer(>=2) no Users can make use of this option to align the nodes vertically from the specified level.
toggleSiblingsResp boolean no false Once enable this option, users can show/hide left/right sibling nodes respectively by clicking left/right arrow.
visibleLevel positive integer no 999 It indicates the level that at the very beginning orgchart is expanded to.
nodeTitle string no "name" It sets one property of datasource as text content of title section of orgchart node. In fact, users can create a simple orghcart with only nodeTitle option.
parentNodeSymbol string no "oci-menu" Using your own icon to imply that the node has child nodes.
nodeContent string no It sets one property of datasource as text content of content section of orgchart node.
nodeId string no "id" It sets one property of datasource as unique identifier of every orgchart node.
nodeTemplate function no It's a template generation function used to customize any complex internal structure of node. It receives only one parameter: "data" stands for json datasoure which will be used to render one node.
createNode function no It's a callback function used to customize every orgchart node. It receives two parameters: "$node" stands for jquery object of single node div; "data" stands for datasource of single node.
exportButton boolean no false It enable the export button for orgchart.
exportButtonName string no "Export" It's export button name.
exportFilename string no "Orgchart" It's filename when you export current orgchart as a picture.
exportFileextension string no "png" Available values are png and pdf.
chartClass string no "" when you wanna instantiate multiple orgcharts on one page, you should add diffent classname to them in order to distinguish them.
draggable boolean no false Users can drag & drop the nodes of orgchart if they enable this option. **Note**: this feature doesn't work on IE due to its poor support for HTML5 drag & drop API.
dropCriteria function no Users can construct their own criteria to limit the relationships between dragged node and drop zone. Furtherly, this function accept three arguments(draggedNode, dragZone, dropZone) and just only return boolen values.
initCompleted function no It can often be useful to know when your table has fully been initialised, data loaded and rendered. It receives one parament: "$chart" stands for jquery object of initialised chart.
icons json no Users can use this option to plug Font Awesome icons back in.
          
'icons': {
  'theme': 'fa-solid fa-sm',
  'parentNode': 'fa-user-tie',
  'expandToUp': 'fa-angles-up',
  'collapseToDown': 'fa-angles-down',
  'collapseToLeft': 'fa-angles-left',
  'expandToRight': 'fa-angles-right',
  'collapsed': 'fa-circle-plus',
  'expanded': 'fa-circle-minus'
}
          
        
compact function no This callback is used to determine current node is wether rendered with compact mode. The node's data is passed in as a parameter. Note:The option "compact" has a higher priority than data prop "compact".

Methods

I'm sure that you can grasp the key points of the methods below after you try out demo -- edit orgchart.

var oc = $container.orgchart(options)

Embeds an organization chart in designated container. Accepts an options object and you can go through the "options" section to find which options are required. Variable oc is the instance of class OrgChart.

init(newOptions)

It's the useful way when users want to re-initialize or refresh orgchart based on new options or reload new data.

addAncestors(data, parentId)

Adds the ancestors for current orgchart.

Name Type Required Default Description
data json yes datasource for building ancestors
parentId string yes append current orgchart to the parent node with parentId

addDescendants(data, $parent)

Adds the descendants for specified parent node.

Name Type Required Default Description
data array yes datasource for building descendants
$parent jquery object yes append descendants to the $parent node

addParent(data)

Adds parent node(actullay it's always root node) for current orgchart.

Name Type Required Default Description
data json object yes datasource for building root node

addSiblings($node, data)

Adds sibling nodes for designated node.

Name Type Required Default Description
$node jquery object yes we'll add sibling nodes based on this node
data array yes datasource for building sibling nodes

addChildren($node, data)

Adds child nodes for designed node.

Name Type Required Default Description
$node jquery object yes we'll add child nodes based on this node
data array yes datasource for building child nodes

removeNodes($node)

Removes the designated node and its descedant nodes.

Name Type Required Default Description
$node jquery object yes node to be removed

getHierarchy()

This method is designed to get the hierarchy relationships of orgchart for further processing. For example, after editing the orgchart, you could send the returned value of this method to server-side and save the new state of orghcart.

Name Type Required Default Description
includeNodeData Boolean No false This optional parameter determines whether include the nodeData items in the generated JSON object in addition to the id and children

hideParent($node)

This method allows you to hide programatically the parent node of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to hide its parent node. Of course, its sibling nodes will be hidden at the same time

showParent($node)

This method allows you to show programatically the parent node of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to show its parent node

hideChildren($node)

This method allows you to hide programatically the children of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to hide its children nodes

showChildren($node)

This method allows you to show programatically the children of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to show its children nodes

hideSiblings($node, direction)

This method allows you to hide programatically the siblings of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to hide its siblings nodes
direction string No Possible values:"left","rigth". Specifies if hide the siblings at left or rigth. If not defined hide both of them.

showSiblings($node, direction)

This method allows you to show programatically the siblings of any specific node(.node element), if it has.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to show its siblings nodes
direction string No Possible values:"left","rigth". Specifies if show the siblings at left or rigth. If not defined show both of them.

getNodeState($node, relation)

This method returns you the display state of related node of the specified node.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to know its related nodes' display state.
relation String Yes Possible values: "parent", "children" and "siblings". Specifies the desired relation to return.

The returning object will have the following structure:

{
  "exist": true|false, // Indicates if has parent|children|siblings
  "visible":true|false, // Indicates if the relationship nodes are visible
}

getRelatedNodes($node, relation)

This method returns you the nodes related to the specified node.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to know its related nodes
relation String Yes Possible values: "parent", "children" and "siblings". Specifies the desired relation to return.

getParent($node)

This method returns you the parent node of the specified node.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to know its parent node

getSiblings($node)

This method returns you the sibling nodes of the specified node.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to know its sibling nodes

getChildren($node)

This method returns you the child nodes of the specified node.

Name Type Required Default Description
$node JQuery Object Yes It's the desired JQuery Object to know its child nodes

setChartScale($chart, newScale)

This method helps you set the specified chart with new scale.

Name Type Required Default Description
$chart JQuery Object Yes It's a chart in your chart-container
newScale Float Yes Positive float value which is used to zoom in/out the chart

export(exportFilename, exportFileextension)

This method allow you to export current orgchart as png or pdf file.

Name Type Required Default Description
exportFilename String No 'OrgChart' It's the name of exported file
exportFileextension String No 'png' It's the extension name of exported file

Events

Event Type Additional Parameters Description
nodedrop.orgchart draggedNode, dragZone, dropZone The event's handler is where you can place your customized function after node drop over. For more details, please refer to example drag & drop.
init.orgchart chart Initialisation complete event - fired when Organization Chart has been fully initialised and data loaded.
show-[relation].orgchart This event is fired when related nodes of a node become visible.
hide-[relation].orgchart This event if fired when related nodes of a node are collapsed.

Tips

How can I deactivate expand/collapse feature of orgchart?

This use case is inspired by the issue. Thanks der-robert and ActiveScottShaw for their constructive discussions:blush:

Users can enable/disable exapand/collapse feature with className "noncollapsable" as shown below.

$('.orgchart').addClass('noncollapsable'); // deactivate

$('.orgchart').removeClass('noncollapsable'); // activate

Why is the root node gone?

When I have a huge orgchart with enabled "pan" option, if I hide all the children of one of the topmost parents then the chart disappear from screen. It seems that we need to add a reset button to keep the chart visible. For details, please refer to the issue opened by manuel-84 😊

Users can embed any clear up logics into the click handler of the reset buttton as shown below.

$('.orgchart').css('transform',''); // remove the tansform settings

Browser Compatibility

  • Chrome 19+
  • Firefox 4+
  • Safari 6+
  • Opera 15+
  • IE 10+

orgchart's People

Contributors

abhijitmamarde avatar ademonte avatar ben12 avatar bigfox avatar costonb avatar dabeng avatar dependabot[bot] avatar extend1994 avatar hlin avatar husayt avatar hvianna avatar jason-cooke avatar joakku avatar lybkf avatar mreyratnz avatar newghost avatar nielsnet avatar richardwalker-iamtech avatar ron0115 avatar sachinsahoo11 avatar shahimclt avatar tedliang avatar tenbaset avatar tfrizzell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orgchart's Issues

multiple parent node

Now a node can have only one parent, if supports multiple parent node would be great? Like the dependency graph

function that return the full data

Hello,
the getHierarchy($chart) return me somthing like this:
{ "id": "01", "children": [ { "id": "02" }, { "id": "03" }, { "id": "04" } ] }

but I want to get the full data with the name and relationship:

'name': 'Ball game', 'relationship': '001', 'id':'01', 'children': [ { 'name': 'Football', 'relationship': '110','id':'02' }, { 'name': 'Basketball', 'relationship': '110' ,'id':'03'}, { 'name': 'Volleyball', 'relationship': '110' ,'id':'04'} ]

is there a function that return JSON data like the above?

my main goal is to save that data into variable after I edit the chart so when I load it again all changes I made will be remained.

I'll appreciate any help on the matter

Add to Structure

Hello, its hard to add something like that?
strcc

name: Kobayashi

simple if its org chart and one employee is assistant to another.

ajaxURLS call back

hi @dabeng ,
i am trying your plugin, everything run good,
but i found a bug in ajaxURL function
when i call children function, server side return json data,
but the plugin cannot parse the json data on line 541
if (data.children.length),
if will return
jquery.orgchart.js:541 Uncaught TypeError: Cannot read property 'length' of undefined
and my solution is add dataType: "JSON" on line 538
like this : $.ajax({ 'url': opts.ajaxURL.children + nodeId + '/',dataType: "JSON" })

hope help :D

Edit chart does not work with the latest jQuery

Several issues when using the latest jQuery (3.1.4) and the edit chart functionalities.
For example when adding a sibling the chart gets messed up.

I changed to the latest 2.x jQuery (2.2.4) and now everything seems to be working fine,

Orientation

It's possible to set the orgchart orientation? I need to put it in the horizontal orientation, instead of the vertical default orientation. I don't found anything about that in the docs, then I'm asking here.

In the demo, siblings collapse into each other

In the demo located at http://dabeng.github.io/OrgChart/drag-drop/ clicking the infacing arrows on either side of an element will collapse all of that elements siblings into the clicked element.

It seems that this is intended behaviour as if meant to focus on the selected node and its children but it strikes me counter-intuitive. This behaviour makes it seem like the hidden elements are children of the clicked element not its siblings which is not the case.

I feel like this will cause confusion with my users. I would need to make one of the following changes in order to use this:

  1. Hide the left and right arrow using CSS to eliminate confusion
  2. Change the left and right icons from an arrow to something that more intuitively suggests a focusing action, like a magnifying glass perhaps

screenshot at may 09 12-43-57

Exporting

We have downloaded 'html2canvas', and turned on the 'Export' button.

It does generate and download a png image .... but the image is always cropped.

Our Org Chart, can be quite long, so ends up having scroll bars (often both x and y axis)... is this the reason the image gets cut? ... if so is there a way to 'Force it' to be the whole area?

when I delete child node Can't Add Child node Again

When I select Basketball node that add child node TEST1 .
But if I make a wrong add child node (TEST1),
I want to delete that, then do it.
after all , I want to select Basketball this node and add any child node Again ,
but NOW I can't add any child node

why my browser(IE 11) can not show some special effect?

Thanks for your great work about Jorgchart. But with using this plugin ,the result of mine is not so good.When I move the mouse into a node, some special effect can not come out.The following is a comparison chart . In my result, the sign "up"、“down”、“right”、“left” can not come out.
example of your demo the right one
the result of mine the wrong one

Create bower package

I would like to use this plugin convieniently using rails-assets. Therefore, I would really like the issuing of a bower package for this plugin.

Aligning Children Vertical

Hi, I have used OrgChart library for a complex chart and works great. Kudos for the great work :).

But when chart gets bigger it becomes useless pretty soon, because of horizontal display of children. I could not find an option in plugin to align children vertical, under the parent.

Please see the attached image, I don't want the connecting lines for children, just alignment will fulfill my requirements.

If there is no option currently in the library, can you please guide me on how can I modify the library to achieve the effect. Thanks.
chart

Broken layout when the page uses CSS resets

Hi @dabeng!

I've got a layout problem when the container page includes a CSS reset (e.g. yui).

broken layout example

The line layout got broken when the CSS reset adds this css property:
table{ border-collapse: collapse }

I solved this issue adding this style in jquery.orgchart.css:
.orgchart table { border-collapse: separate }

I don't know if this is the best approach to solve the issue.
What do you think?

Thanks in advance.

Broken lines css

screen shot 2016-05-26 at 7 55 37 pm

I did not thoroughly check yet but I think this has something to do with normalize.css

Saving datasource

Hi there,

I'm loading my Json string with my hierarchy but after modifying the hierarchy, I want to save it so I can reopen the changes. How can I get the modified datasource from the chart?

Regards,
Jordi

stracure data like this

very thanks for orgchart , do it work in bellow structure data ??

 { id: '1', parent: '' },
 { id: '2', parent: '1' },
 { id: '3', parent: '1' },
 { id: '4', parent: '2' },
 { id: '5', parent: '3' },

Export image problems when using l2r and zoom

I am getting problems when using Export Image with a chart in l2r direction.
I also get similar problems when exporting image after I have zoomed the chart (which also happens in t2b direction mode).

The edges (lines) between the nodes gets messed up.

I have modified the chart script quite a lot so I am not sure that the problems is because of this. Maybe someone else can try to see if they also get these problems.

IE 9/10/11 + Canvas + SVG + orgchart.js

Hi
Firstly ,Great work on your project.
Secondly , i have picked up an issue where when using the addnode function and providing
an SVG ( i have checked the formatting all correct and the function works perfectly in chrome) it will not display any thing in the bound canvas objects.

when using the Canvas and SVG without the orgchart.js it seems to work fine in both ie and chrome,
but it has come down to i really want to use your orgchart.js as it handles so nicely.

Here is a snippet that works in chrome ( i have a loop around this code to produce more levels)


var data = '<svg width="400px" height="200px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
'<title> designation</title>' +
'<g id="columnGroup">' +
'<rect x="65" y="10" width="75" height="110" fill="gainsboro"/>' +
' <text x="0" y="30" font-size="18px" font-weight="bold" fill="crimson">' +
'<tspan x="0" dy="1.5em"> test 0 </tspan>' +
'<tspan x="0" dy="1em"> test 1 </tspan>' +
'<tspan x="0" dy="1em"> test 2</tspan>' +
'</text>' +
'<text x="250" y="30" font-size="18px" text-anchor="middle">' +
'<tspan x="250" font-weight="bold" fill="crimson">Actual</tspan>' +
'<tspan x="250" dy="1.5em"> 7 </tspan>' +
'<tspan x="250" dy="1em"> 8 </tspan>' +
'<tspan x="250" dy="1em"> 3 </tspan>' +
'</text>' +
'<text x="350" y="30" font-size="18px" text-anchor="middle">' +
'<tspan x="350" font-weight="bold" fill="crimson">Plan</tspan>' +
'<tspan x="350" dy="1.5em"> 8 </tspan>' +
'<tspan x="350" dy="1em"> 8 </tspan>' +
 '<tspan x="350" dy="1em"> 2 </tspan>' +
'</text>' +
'</g>' +
'</svg>';


var img = new Image();
var DOMURL = window.URL || window.webkitURL || self;
var svg = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
var url = DOMURL.createObjectURL(svg);

o.addNode(Id, reportingid, 'u', '', '', '', '', '', '', url, 'C');
o.drawChart('canvas1', 'c', true);

Pan and Zoom

Is there a way to 'turn off' the Zoom but still be able to pan?

We want to be able to drag about, but not zoom in if possible?

Titles and Content in standard UL/LI

A couple of bits which don't seem straight forward and not really documented that I can see.

  1. We are using just the 'standard' UL/LI list .... In the LI's how do you define the TITLE and CONTENT? I know you can add 'nodeContent' into the jquery options ... but what value does it need and what is the structure of the LI's?

  2. Changing the WIDTHS ... we want to make the titles longer so you get to see more content .... do we then have to go through the CSS and change all the widths / margins?

collapse siblings to right and left respectively..on the basis of an arrow

First of all great work guys.

I just have a question about collapsing and expanding the siblings on the basis of arrow.
Currently clicking on any horizontal arrow results into collapsing all siblings.
Can we make this collapsing more appropriate by considering the arrow's direction.
For example., collapse/hide only right side nodes when right side arrow is clicked and and same for left and expanding/showing up the nodes.

Please share your thoughts on this.

Thanks....

Error loading external JSON file in Firefox

Trying to load a valid JSON external file. Works fine in IE11, but latest version of Firefox returns this error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

It shouldn't need to JSON.parse a file that already contains valid JSON, right? Seems like an extra step. Google search reveals that this is exactly the error returned when trying to parse already-valid JSON.

Thanks for an excellent library!

Cancel the drop event

Hi.

I was wondering if it is possible to cancel the drag & drop event if some criteria are not met. For example, I do not want an employee to be under a specific department under no circumstance.

I have already found a way to check if the dropZone should be valid or not but I have not found a way to return the dragged node to its previous position.

Is what I am asking even possible?

Thanks

Namespace css correctly

Please, do not use css which is not namespaced correctly. For example: I see that you define a .hidden class with a display: none; In my projects, I could also have used a hidden class and this will interfere with the hidden class you use for this plugin...

Also .node, .slide-up, .slide-down are also not namespaced. If you agree, I could make a PR.

<br> in nodeContent?

hi @dabeng,
after few week ago, i got another question,
can i know, nodeContent only support single line?

example:
nodeContent: 'title';
and
title:'a<br>b'

it only show
a ini chart...
if you need image support please let me know, thanks !

Extending the plugin

Hi dabeng,
I'd like to add new factory functions without doing a fork. (Will be more than happy to share them with the community).
Found this approach:
http://stackoverflow.com/questions/2050985/best-way-to-extend-a-jquery-plugin/4414356#4414356

(function($) {
/**
 *  Namespace: the namespace the plugin is located under
 *  pluginName: the name of the plugin
 */
    var extensionMethods = {
        /*
         * retrieve the id of the element
         * this is some context within the existing plugin
         */
        showId: function(){
            return this.element[0].id;
        }
    };

    $.extend(true, $[ Namespace ][ pluginName ].prototype, extensionMethods);


})(jQuery);

To make it work I would need to provide the 'namespace' and 'pluginName'. Looks to me that these concepts are used ambiguously in literature. Tried several combinations to get the extension pattern to work, without success.

Any thoughts on this?

kbg

Custom code

Hello @dabeng
I'm wondering whether it's possible to use custom html instead of default title and name? In jOrgChart there was a possibility to use any code except ul and li inside the node and the plugin was just connecting the blocks into a tree - I'm looking for such a solution, do you think that I can do that in your plugin without tons of extra coding?
Regards

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.