Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added square, triangle and star node shapes. #78

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 103 additions & 92 deletions src/core/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,37 @@ function Graph() {
'hidden': false,
'forceLabel': false,
// Strings :
'shape': 'circle',
'label': id.toString(),
'id': id.toString(),
// Custom attributes :
'attr': {}
};

for (var k in params) {
switch (k) {
case 'id':
break;
case 'x':
case 'y':
case 'size':
n[k] = +params[k];
break;
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
n[k] = !!params[k];
break;
case 'color':
case 'label':
n[k] = params[k];
break;
default:
n['attr'][k] = params[k];
if (params.hasOwnProperty(k)) {
switch (k) {
case 'id':
break;
case 'x':
case 'y':
case 'size':
n[k] = +params[k];
break;
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
n[k] = !!params[k];
break;
case 'color':
case 'label':
case 'shape':
n[k] = params[k];
break;
default:
n['attr'][k] = params[k];
}
}
}

Expand Down Expand Up @@ -143,33 +147,36 @@ function Graph() {
*/
function checkNode(node, copy) {
for (var k in copy) {
switch (k) {
case 'id':
case 'attr':
case 'degree':
case 'inDegree':
case 'outDegree':
case 'displayX':
case 'displayY':
case 'displaySize':
break;
case 'x':
case 'y':
case 'size':
node[k] = +copy[k];
break;
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
node[k] = !!copy[k];
break;
case 'color':
case 'label':
node[k] = (copy[k] || '').toString();
break;
default:
node['attr'][k] = copy[k];
if (copy.hasOwnProperty(k)) {
switch (k) {
case 'id':
case 'attr':
case 'degree':
case 'inDegree':
case 'outDegree':
case 'displayX':
case 'displayY':
case 'displaySize':
break;
case 'x':
case 'y':
case 'size':
node[k] = +copy[k];
break;
case 'fixed':
case 'active':
case 'hidden':
case 'forceLabel':
node[k] = !!copy[k];
break;
case 'color':
case 'label':
case 'shape':
node[k] = (copy[k] || '').toString();
break;
default:
node['attr'][k] = copy[k];
}
}
}

Expand Down Expand Up @@ -272,29 +279,31 @@ function Graph() {
e['target']['inDegree']++;

for (var k in params) {
switch (k) {
case 'id':
case 'source':
case 'target':
break;
case 'hidden':
e[k] = !!params[k];
break;
case 'size':
case 'weight':
e[k] = +params[k];
break;
case 'color':
e[k] = params[k].toString();
break;
case 'type':
e[k] = params[k].toString();
break;
case 'label':
e[k] = params[k];
break;
default:
e['attr'][k] = params[k];
if (params.hasOwnProperty(k)) {
switch (k) {
case 'id':
case 'source':
case 'target':
break;
case 'hidden':
e[k] = !!params[k];
break;
case 'size':
case 'weight':
e[k] = +params[k];
break;
case 'color':
e[k] = params[k].toString();
break;
case 'type':
e[k] = params[k].toString();
break;
case 'label':
e[k] = params[k];
break;
default:
e['attr'][k] = params[k];
}
}
}

Expand Down Expand Up @@ -337,28 +346,30 @@ function Graph() {
*/
function checkEdge(edge, copy) {
for (var k in copy) {
switch (k) {
case 'id':
case 'displaySize':
break;
case 'weight':
case 'size':
edge[k] = +copy[k];
break;
case 'source':
case 'target':
edge[k] = self.nodesIndex[k] || edge[k];
break;
case 'hidden':
edge[k] = !!copy[k];
break;
case 'color':
case 'label':
case 'type':
edge[k] = (copy[k] || '').toString();
break;
default:
edge['attr'][k] = copy[k];
if (copy.hasOwnProperty(k)) {
switch (k) {
case 'id':
case 'displaySize':
break;
case 'weight':
case 'size':
edge[k] = +copy[k];
break;
case 'source':
case 'target':
edge[k] = self.nodesIndex[k] || edge[k];
break;
case 'hidden':
edge[k] = !!copy[k];
break;
case 'color':
case 'label':
case 'type':
edge[k] = (copy[k] || '').toString();
break;
default:
edge['attr'][k] = copy[k];
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/core/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ function Monitor(instance, dom) {

s += '<p>GLOBAL :</p>';
for (var k in self.p.globalProbes) {
s += '<p>' + k + ' : ' + self.p.globalProbes[k]() + '</p>';
if (self.p.globalProbes.hasOwnProperty(k)) {
s += '<p>' + k + ' : ' + self.p.globalProbes[k]() + '</p>';
}
}

s += '<br><p>LOCAL :</p>';
for (var k in self.p.localProbes) {
s += '<p>' + k + ' : ' + self.p.localProbes[k]() + '</p>';
if (self.p.localProbes.hasOwnproperty(k)) {
s += '<p>' + k + ' : ' + self.p.localProbes[k]() + '</p>';
}
}

self.p.dom.innerHTML = s;
Expand Down
Loading