We highly encourage you to consider connect-it instead.
Arg-Graph is a simple free library for creating dynamic Directed Graph using JQuery which enables you to draw SVG based connectors (lines, arrows) between DOM nodes via drag and drop.
The best way to become acquainted with the library is to see Demos
You can create a digraph (directed graph) easily by calling the "ArgGraph" function.
<div class="arg-Graph">
</div>
var argGraph=$('.arg-Graph').ArgGraph();
You can append new items to the container div, as html code. like this:
<div class="arg-Graph">
<div id="item1" class="arg-Graph_item" data-neighbors="item2,item3" style="left: 259px; top: 22px;">
Title
<span class="arg-Graph_connector-handler"></span>
<span class="arg-Graph_delete-item"></span>
</div>
<div id="item2" class="arg-Graph_item" style="left: 159px; top: 212px;">
Title
<span class="arg-Graph_connector-handler"></span>
<span class="arg-Graph_delete-item"></span>
</div>
</div>
Now you must refresh the graph by calling 'refresh' function.
argGraph.refresh()
Creating a JavaScript object and import that to the graph:
newItem = {
"id": "item1",
"text": "Start",
"position": {
"left": "259px",
"top": "22px"
},
"neighbors": [
"item2",
"item3"
]
}
argGraph.import(newItem)
Note: You can append multiple items as array object using "import" function.
You can import this object as JSON format by calling "importJson" function.
var json=JSON.stringify(newItem,null,4);
argGraph.importJson(json);
By calling "export"/"exportJson" function you can get a JavaScript/JSON object similar to the import object format:
var json = argGraph.exportJson();
result:
[
{
"id": "item7",
"text": "Test",
"position": {
"left": "531.328px",
"top": "406px"
},
"neighbors": [
"item8"
]
},
{
"id": "item8",
"text": "Deployment",
"position": {
"left": "373.328px",
"top": "463px"
},
"neighbors": [
"item9"
]
},
{
"id": "item9",
"text": "Test",
"position": {
"left": "239.328px",
"top": "515px"
},
"neighbors": ""
}
]
Naser Yousefi