|
|
@ -4,8 +4,8 @@ |
|
|
|
* |
|
|
|
* A dynamic, browser-based visualization library. |
|
|
|
* |
|
|
|
* @version 0.0.9 |
|
|
|
* @date 2013-06-07 |
|
|
|
* @version 0.1.0-SNAPSHOT |
|
|
|
* @date 2013-06-10 |
|
|
|
* |
|
|
|
* @license |
|
|
|
* Copyright (C) 2011-2013 Almende B.V, http://almende.com
|
|
|
@ -6917,10 +6917,21 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
* @param {Object} node |
|
|
|
*/ |
|
|
|
function addNode(node) { |
|
|
|
if (!graph.nodes) { |
|
|
|
graph.nodes = {}; |
|
|
|
var nodes = graph.nodes; |
|
|
|
if (!nodes) { |
|
|
|
nodes = []; |
|
|
|
graph.nodes = nodes; |
|
|
|
} |
|
|
|
var current = graph.nodes[node.id]; |
|
|
|
|
|
|
|
// find existing node
|
|
|
|
var current = null; |
|
|
|
for (var i = 0, len = nodes.length; i < len; i++) { |
|
|
|
if (node.id === nodes[i].id) { |
|
|
|
current = nodes[i]; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (current) { |
|
|
|
// merge attributes
|
|
|
|
if (node.attr) { |
|
|
@ -6929,7 +6940,7 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
} |
|
|
|
else { |
|
|
|
// add
|
|
|
|
graph.nodes[node.id] = node; |
|
|
|
graph.nodes.push(node); |
|
|
|
if (nodeAttr) { |
|
|
|
var attr = merge({}, nodeAttr); // clone global attributes
|
|
|
|
node.attr = merge(attr, node.attr); // merge attributes
|
|
|
@ -6938,7 +6949,7 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Add an edge to the current graph obect |
|
|
|
* Add an edge to the current graph object |
|
|
|
* @param {Object} edge |
|
|
|
*/ |
|
|
|
function addEdge(edge) { |
|
|
@ -7203,7 +7214,7 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
else { |
|
|
|
// node statement
|
|
|
|
var node = { |
|
|
|
id: String(id) |
|
|
|
id: id |
|
|
|
}; |
|
|
|
attr = parseAttributes(); |
|
|
|
if (attr) { |
|
|
@ -7219,15 +7230,15 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
|
|
|
|
var to = token; |
|
|
|
addNode({ |
|
|
|
id: String(to) |
|
|
|
id: to |
|
|
|
}); |
|
|
|
getToken(); |
|
|
|
attr = parseAttributes(); |
|
|
|
|
|
|
|
// create edge
|
|
|
|
var edge = { |
|
|
|
from: String(from), |
|
|
|
to: String(to), |
|
|
|
from: from, |
|
|
|
to: to, |
|
|
|
type: type |
|
|
|
}; |
|
|
|
if (attr) { |
|
|
@ -7318,19 +7329,17 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
|
|
|
|
// copy the nodes
|
|
|
|
if (dotData.nodes) { |
|
|
|
for (var id in dotData.nodes) { |
|
|
|
if (dotData.nodes.hasOwnProperty(id)) { |
|
|
|
var node = { |
|
|
|
id: id, |
|
|
|
label: id |
|
|
|
}; |
|
|
|
merge(node, dotData.nodes[id].attr); |
|
|
|
if (node.image) { |
|
|
|
node.shape = 'image'; |
|
|
|
} |
|
|
|
graphData.nodes.push(node); |
|
|
|
dotData.nodes.forEach(function (dotNode) { |
|
|
|
var graphNode = { |
|
|
|
id: dotNode.id, |
|
|
|
label: String(dotNode.label || dotNode.id) |
|
|
|
}; |
|
|
|
merge(graphNode, dotNode.attr); |
|
|
|
if (graphNode.image) { |
|
|
|
graphNode.shape = 'image'; |
|
|
|
} |
|
|
|
} |
|
|
|
graphData.nodes.push(graphNode); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// copy the edges
|
|
|
|