Skip to content

Commit

Permalink
added forceLabel node attribute in graph.js + fixed undefined but exi…
Browse files Browse the repository at this point in the history
…sting string nodes/edges properties
  • Loading branch information
jacomyal committed Apr 3, 2012
1 parent 02cb7d0 commit 6b6dd1d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ function Graph() {

params = params || {};
var n = {
// Numbers :
'x': 0,
'y': 0,
'size': 1,
'degree': 0,
'inDegree': 0,
'outDegree': 0,
// Flags :
'fixed': false,
'active': false,
'hidden': false,
'forceLabel': false,
// Strings :
'label': id.toString(),
'id': id.toString(),
// Custom attributes :
'attr': {}
};

Expand All @@ -81,6 +86,7 @@ function Graph() {
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
n[k] = !!params[k];
break;
case 'color':
Expand Down Expand Up @@ -121,6 +127,7 @@ function Graph() {
'fixed': node['fixed'],
'active': node['active'],
'hidden': node['hidden'],
'forceLabel': node['forceLabel'],
'attr': node['attr']
};
};
Expand Down Expand Up @@ -154,11 +161,12 @@ function Graph() {
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
node[k] = !!copy[k];
break;
case 'color':
case 'label':
node[k] = copy[k].toString();
node[k] = (copy[k] || '').toString();
break;
default:
node['attr'][k] = copy[k];
Expand Down

0 comments on commit 6b6dd1d

Please sign in to comment.