Defining the graph structure

In addition to the nodesStore property, it is also necessary to specify the relations between the items in the data source. There are two types of relationship: hierarchical and explicit.
To define hierarchical and explicit relationships between nodes use metadata in the nodesStore. To define explicit relationships between nodes use metadata in the linksStore.
The key difference between hierarchical and explicit is the way they are represented. The representation of hierarchical relationships is based on the value of the createLinksForHierarchy attribute. If true, the hierarchical relationships are represented as links. If false, the hierarchical relationships are represented as a series of nested subgraphs. Explicit relationships are always represented as links.

Defining links using hierarchical relationships

To define links using hierarchical relationships:
For example, the following data file defines an employee hierarchy:
{ 
  "identifier":"Name", 
  "label":"Name", 
  "items":[ 
      { "children":[ 
          {"_reference":"Hermann Bacchus"}, 
          {"_reference":"Marion Daignan"}, 
          {"_reference":"Margaret Brinkmeier"}, 
          {"_reference":"Peter Courcelle"} 
        ], 
        "Name":"Friedrich Azaretto", 
        "EMail":"fazaretto@my.com" 
      } 
      ... 
] }
In this example, you define a dojo.data.api.ItemFileReadStore data store that loads the data file as in the following markup:
<div dojoType="dojo.data.ItemFileReadStore" url="./mycompany.json" jsId="graphModel" ></div>
   <div id="canvas" dojoType='ibm_ilog.diagram.widget.Diagram' style="width:900px;height:700px" nodesStore="graphModel" childBinding="children" nodesQuery="{Name:'*'}" ></div>
When you set the childBinding attribute of the Diagram widget to children, the node that corresponds to the name property is linked to all the nodes that represent the data item referenced in the children array.

Defining links using explicit relationships

To describe hierarchical relationships between nodes from information in the nodesStore:
To describe hierarchical relationships between nodes from information in the linksStore:

Defining more complex nodesStore relationships

It might not be possible to determine more complex relationships by a simple nodesStore attribute lookup, or you might not want to declaratively specify the attribute name.
To define complex nodesStore relationships:
  • Use the attributes childBinding, parentBinding, successorsBinding, and predecessorsBinding. These attributes can refer to a function.
    The following example shows how the children lookup can be achieved using the function findChildren.
    var findStartItem = function(linksStore, linkStoreItem, nodesStore) {
            return linksStore.getValue(linkStoreItem, "start");
    };