Skip to content
Merged
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
14 changes: 11 additions & 3 deletions js/module/tracer/directed_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class DirectedGraphTracer extends Tracer {
constructor(name) {
super(name);

this.nodePositions = [];

if (this.isNew) initView(this);
}

Expand Down Expand Up @@ -43,6 +45,13 @@ class DirectedGraphTracer extends Tracer {
return this;
}

_setNodePositions(obj){
for(var i = 0; i < obj.length; i++){
this.nodePositions.push(obj[i]);
}
super.dirtyData();
}

processStep(step, options) {
switch (step.type) {
case 'setTreeData':
Expand Down Expand Up @@ -116,7 +125,6 @@ class DirectedGraphTracer extends Tracer {

setData(G, undirected) {
if (super.setData.apply(this, arguments)) return true;

this.graph.clear();
const nodes = [];
const edges = [];
Expand All @@ -127,8 +135,8 @@ class DirectedGraphTracer extends Tracer {
nodes.push({
id: this.n(i),
label: '' + i,
x: .5 + Math.sin(currentAngle) / 2,
y: .5 + Math.cos(currentAngle) / 2,
x: (this.nodePositions[i]) ? this.nodePositions[i].x : .5 + Math.sin(currentAngle) / 2,
y: (this.nodePositions[i]) ? this.nodePositions[i].y : .5 + Math.cos(currentAngle) / 2,
size: 1,
color: this.color.default,
weight: 0
Expand Down
9 changes: 9 additions & 0 deletions js/module/tracer/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ class Tracer {
$name.text(name || this.defaultName);
}

dirtyData(){
this.isNew = true;
}

cleanData(){
this.isNew = false;
}

setData() {
const data = toJSON(arguments);
if (!this.isNew && this.lastData === data) {
return true;
}
this.lastData = this.capsule.lastData = data;
this.cleanData();
return false;
}

Expand Down