Provides methods for loading JSON data.
Provides the Loader.loadJSON method implemented by the main visualization classes to load JSON Trees and Graphs.
Provides static methods for loading JSON data.
This object is extended by the main Visualization classes (ST, Hypertree, TM and RGraph) in order to implement the Loader.loadJSON method.
The Loader.loadJSON method accepts JSON Trees and Graph objects. This will be explained in detail in the Loader.loadJSON method definition.
loadJSON: function( json, i )
Loads a JSON structure to the visualization. The JSON structure can be a JSON tree or graph structure.
A JSON tree or graph structure consists of nodes, each having as properties
Hash keys prefixed with a dollar sign (i.e $) have special meaning. I will detail those properties below.
For JSON tree structures, there’s an extra property children of type Array which contains the node’s children.
var json = {
"id": "aUniqueIdentifier",
"name": "usually a nodes name",
"data": {
"some key": "some value",
"some other key": "some other value"
},
"children": [ 'other nodes or empty' ]
};JSON Graph structures consist of an array of nodes, each specifying the nodes to which the current node is connected.
For JSON Graph structures, the children property is replaced by the adjacencies property.
There are two types of Graph structures, simple and extended graph structures.
For simple Graph structures, the adjacencies property contains an array of strings, each specifying the id of the node connected to the main node.
var json = [
{
"id": "aUniqueIdentifier",
"name": "usually a nodes name",
"data": {
"some key": "some value",
"some other key": "some other value"
},
"adjacencies": ["anotherUniqueIdentifier", "yetAnotherUniqueIdentifier", 'etc']
},
'other nodes go here...'
];For extended Graph structures, the adjacencies property contains an array of Adjacency objects that have as properties
var json = [
{
"id": "aUniqueIdentifier",
"name": "usually a nodes name",
"data": {
"some key": "some value",
"some other key": "some other value"
},
"adjacencies": [
{
nodeTo:"aNodeId",
data: {} //put whatever you want here
},
'other adjacencies go here...'
},
'other nodes go here...'
];Since all visualizations implement this method, this will be the entry point for JSON data for all visualizations. This method could be called like this
var ht = new Hypertree(canvas, config); ht.loadJSON(json); var tm = new TM.Squarified(config); tm.loadJSON(json); var st = new ST(canvas, config); st.loadJSON(json); var rg = new RGraph(canvas, config); rg.loadJSON(json);
| json | A JSON Tree or Graph structure. |
| i | For Graph structures only. Sets the indexed node as root for the visualization. |
Loads a JSON structure to the visualization.
loadJSON: function( json, i )