Browse Source

fixed dynamic edges not correctly handling non-existent nodes.

flowchartTest
Alex de Mulder 9 years ago
parent
commit
547fb05176
7 changed files with 1543 additions and 1525 deletions
  1. +1516
    -1508
      dist/vis.js
  2. +5
    -3
      lib/network/modules/components/Edge.js
  3. +13
    -5
      lib/network/modules/components/edges/BezierEdgeDynamic.js
  4. +0
    -3
      lib/network/modules/components/edges/BezierEdgeStatic.js
  5. +0
    -3
      lib/network/modules/components/edges/StraightEdge.js
  6. +3
    -0
      lib/network/modules/components/edges/util/EdgeBase.js
  7. +6
    -3
      test/networkTest.html

+ 1516
- 1508
dist/vis.js
File diff suppressed because it is too large
View File


+ 5
- 3
lib/network/modules/components/Edge.js View File

@ -73,9 +73,6 @@ class Edge {
if (options.value !== undefined) {options.value = parseInt(options.value);} if (options.value !== undefined) {options.value = parseInt(options.value);}
// A node is connected when it has a from and to node that both exist in the network.body.nodes.
this.connect();
// update label Module // update label Module
this.updateLabelModule(); this.updateLabelModule();
@ -84,6 +81,9 @@ class Edge {
// if anything has been updates, reset the selection width and the hover width // if anything has been updates, reset the selection width and the hover width
this._setInteractionWidths(); this._setInteractionWidths();
// A node is connected when it has a from and to node that both exist in the network.body.nodes.
this.connect();
return dataChanged; return dataChanged;
} }
@ -267,6 +267,8 @@ class Edge {
this.to.detachEdge(this); this.to.detachEdge(this);
} }
} }
this.edgeType.connect();
} }

+ 13
- 5
lib/network/modules/components/edges/BezierEdgeDynamic.js View File

@ -8,17 +8,25 @@ class BezierEdgeDynamic extends BezierEdgeBase {
setOptions(options) { setOptions(options) {
this.options = options; this.options = options;
this.from = this.body.nodes[this.options.from];
this.to = this.body.nodes[this.options.to];
this.id = this.options.id; this.id = this.options.id;
this.setupSupportNode(); this.setupSupportNode();
this.connect();
}
// fix weird behaviour
if (this.from.id === this.to.id) {
connect() {
this.from = this.body.nodes[this.options.from];
this.to = this.body.nodes[this.options.to];
if (this.from === undefined || this.to === undefined) {
this.via.setOptions({physics:false}) this.via.setOptions({physics:false})
} }
else { else {
this.via.setOptions({physics:true})
// fix weird behaviour where a selfreferencing node has physics enabled
if (this.from.id === this.to.id) {
this.via.setOptions({physics: false})
}
else {
this.via.setOptions({physics: true})
}
} }
} }

+ 0
- 3
lib/network/modules/components/edges/BezierEdgeStatic.js View File

@ -5,9 +5,6 @@ class BezierEdgeStatic extends BezierEdgeBase {
super(options, body, labelModule); super(options, body, labelModule);
} }
cleanup() {
return false;
}
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx

+ 0
- 3
lib/network/modules/components/edges/StraightEdge.js View File

@ -5,9 +5,6 @@ class StraightEdge extends EdgeBase {
super(options, body, labelModule); super(options, body, labelModule);
} }
cleanup() {
return false;
}
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx

+ 3
- 0
lib/network/modules/components/edges/util/EdgeBase.js View File

@ -11,6 +11,9 @@ class EdgeBase {
this.hoverWidth = 1.5; this.hoverWidth = 1.5;
} }
connect() {}
cleanup() {return false}
setOptions(options) { setOptions(options) {
this.options = options; this.options = options;
this.from = this.body.nodes[this.options.from]; this.from = this.body.nodes[this.options.from];

+ 6
- 3
test/networkTest.html View File

@ -3,8 +3,8 @@
<head> <head>
<title>Network | Basic usage</title> <title>Network | Basic usage</title>
<script type="text/javascript" src="http://www.visjs.org/dist/vis.js"></script>
<link href="http://www.visjs.org/dist/vis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../dist/vis.js"></script>
<link href="../dist/vis.css" rel="stylesheet" type="text/css" />
<style type="text/css"> <style type="text/css">
#div_graph { #div_graph {
@ -13,7 +13,10 @@
border: 1px solid lightgray; border: 1px solid lightgray;
} }
</style> </style>
<script type="text/javascript">
</script>
</head> </head>
<body> <body>
<p> <p>
@ -67,7 +70,7 @@
edges: edges edges: edges
}; };
var network = new vis.Network(container, data, options);
network = new vis.Network(container, data, options);
// nodesView.refresh(); // nodesView.refresh();

Loading…
Cancel
Save