|
@ -4,8 +4,8 @@ |
|
|
* |
|
|
* |
|
|
* A dynamic, browser-based visualization library. |
|
|
* A dynamic, browser-based visualization library. |
|
|
* |
|
|
* |
|
|
* @version 0.0.9 |
|
|
|
|
|
* @date 2013-06-07 |
|
|
|
|
|
|
|
|
* @version 0.1.0-SNAPSHOT |
|
|
|
|
|
* @date 2013-06-10 |
|
|
* |
|
|
* |
|
|
* @license |
|
|
* @license |
|
|
* Copyright (C) 2011-2013 Almende B.V, http://almende.com
|
|
|
* Copyright (C) 2011-2013 Almende B.V, http://almende.com
|
|
@ -6917,10 +6917,21 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
* @param {Object} node |
|
|
* @param {Object} node |
|
|
*/ |
|
|
*/ |
|
|
function addNode(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) { |
|
|
if (current) { |
|
|
// merge attributes
|
|
|
// merge attributes
|
|
|
if (node.attr) { |
|
|
if (node.attr) { |
|
@ -6929,7 +6940,7 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
// add
|
|
|
// add
|
|
|
graph.nodes[node.id] = node; |
|
|
|
|
|
|
|
|
graph.nodes.push(node); |
|
|
if (nodeAttr) { |
|
|
if (nodeAttr) { |
|
|
var attr = merge({}, nodeAttr); // clone global attributes
|
|
|
var attr = merge({}, nodeAttr); // clone global attributes
|
|
|
node.attr = merge(attr, node.attr); // merge 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 |
|
|
* @param {Object} edge |
|
|
*/ |
|
|
*/ |
|
|
function addEdge(edge) { |
|
|
function addEdge(edge) { |
|
@ -7203,7 +7214,7 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
else { |
|
|
else { |
|
|
// node statement
|
|
|
// node statement
|
|
|
var node = { |
|
|
var node = { |
|
|
id: String(id) |
|
|
|
|
|
|
|
|
id: id |
|
|
}; |
|
|
}; |
|
|
attr = parseAttributes(); |
|
|
attr = parseAttributes(); |
|
|
if (attr) { |
|
|
if (attr) { |
|
@ -7219,15 +7230,15 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
|
|
|
|
|
var to = token; |
|
|
var to = token; |
|
|
addNode({ |
|
|
addNode({ |
|
|
id: String(to) |
|
|
|
|
|
|
|
|
id: to |
|
|
}); |
|
|
}); |
|
|
getToken(); |
|
|
getToken(); |
|
|
attr = parseAttributes(); |
|
|
attr = parseAttributes(); |
|
|
|
|
|
|
|
|
// create edge
|
|
|
// create edge
|
|
|
var edge = { |
|
|
var edge = { |
|
|
from: String(from), |
|
|
|
|
|
to: String(to), |
|
|
|
|
|
|
|
|
from: from, |
|
|
|
|
|
to: to, |
|
|
type: type |
|
|
type: type |
|
|
}; |
|
|
}; |
|
|
if (attr) { |
|
|
if (attr) { |
|
@ -7318,19 +7329,17 @@ Timeline.prototype.getItemRange = function getItemRange() { |
|
|
|
|
|
|
|
|
// copy the nodes
|
|
|
// copy the nodes
|
|
|
if (dotData.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
|
|
|
// copy the edges
|
|
|