Browse Source

added edge arrow shorthand

flowchartTest
Alex de Mulder 9 years ago
parent
commit
5b7c3018d3
8 changed files with 71 additions and 26 deletions
  1. +38
    -10
      dist/vis.js
  2. +1
    -1
      examples/network/01_basic_usage.html
  3. +1
    -4
      examples/network/32_hierarchicaLayoutMethods.html
  4. +3
    -2
      lib/network/modules/CanvasRenderer.js
  5. +14
    -3
      lib/network/modules/EdgesHandler.js
  6. +14
    -3
      lib/network/modules/components/Edge.js
  7. +0
    -1
      lib/network/modules/components/edges/bezierEdgeDynamic.js
  8. +0
    -2
      lib/network/modules/components/edges/util/bezierBaseEdge.js

+ 38
- 10
dist/vis.js View File

@ -27978,9 +27978,24 @@ return /******/ (function(modules) { // webpackBootstrap
util.mergeOptions(this.options, options, "dashes");
if (options.arrows !== undefined) {
util.mergeOptions(this.options.arrows, options.arrows, "to");
util.mergeOptions(this.options.arrows, options.arrows, "middle");
util.mergeOptions(this.options.arrows, options.arrows, "from");
if (typeof options.arrows === "string") {
var arrows = options.arrows.toLowerCase();
if (arrows.indexOf("to") != -1) {
this.options.arrows.to.enabled = true;
}
if (arrows.indexOf("middle") != -1) {
this.options.arrows.middle.enabled = true;
}
if (arrows.indexOf("from") != -1) {
this.options.arrows.from.enabled = true;
}
} else if (typeof options.arrows === "object") {
util.mergeOptions(this.options.arrows, options.arrows, "to");
util.mergeOptions(this.options.arrows, options.arrows, "middle");
util.mergeOptions(this.options.arrows, options.arrows, "from");
} else {
throw new Error("The arrow options can only be an object or a string. Refer to the documentation. You used:" + JSON.stringify(options.arrows));
}
}
}
},
@ -28251,9 +28266,24 @@ return /******/ (function(modules) { // webpackBootstrap
util.mergeOptions(this.options, options, "dashes");
if (options.arrows !== undefined) {
util.mergeOptions(this.options.arrows, options.arrows, "to");
util.mergeOptions(this.options.arrows, options.arrows, "middle");
util.mergeOptions(this.options.arrows, options.arrows, "from");
if (typeof options.arrows === "string") {
var arrows = options.arrows.toLowerCase();
if (arrows.indexOf("to") != -1) {
this.options.arrows.to.enabled = true;
}
if (arrows.indexOf("middle") != -1) {
this.options.arrows.middle.enabled = true;
}
if (arrows.indexOf("from") != -1) {
this.options.arrows.from.enabled = true;
}
} else if (typeof options.arrows === "object") {
util.mergeOptions(this.options.arrows, options.arrows, "to");
util.mergeOptions(this.options.arrows, options.arrows, "middle");
util.mergeOptions(this.options.arrows, options.arrows, "from");
} else {
throw new Error("The arrow options can only be an object or a string. Refer to the documentation. You used:" + JSON.stringify(options.arrows));
}
}
if (options.id !== undefined) {
@ -29039,7 +29069,6 @@ return /******/ (function(modules) { // webpackBootstrap
},
_findBorderPosition: {
value: function _findBorderPosition(nearNode, ctx) {
console.log(this);
return this._findBorderPositionBezier(nearNode, ctx, this.via);
},
writable: true,
@ -29109,8 +29138,6 @@ return /******/ (function(modules) { // webpackBootstrap
*/
value: function _findBorderPositionBezier(nearNode, ctx) {
var viaNode = arguments[2] === undefined ? this._getViaCoordinates() : arguments[2];
console.log(nearNode, ctx, viaNode);
var maxIterations = 10;
var iteration = 0;
var low = 0;
@ -32370,6 +32397,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.renderRequests = 0;
this.pixelRatio = undefined;
// redefined in this._redraw
this.canvasTopLeft = { x: 0, y: 0 };
this.canvasBottomRight = { x: 0, y: 0 };
@ -32382,7 +32410,7 @@ return /******/ (function(modules) { // webpackBootstrap
return _this.dragging = false;
});
this.body.emitter.on("_redraw", function () {
console.log(_this.renderingActive);if (_this.renderingActive === false) {
if (_this.renderingActive === false) {
_this._redraw();
}
});

+ 1
- 1
examples/network/01_basic_usage.html View File

@ -43,7 +43,7 @@
nodes: nodes,
edges: edges
};
var options = {}//{physics:{stabilization:false}};
var options = {edges:{arrows:'to from'}}//{physics:{stabilization:false}};
var network = new vis.Network(container, data, options);
network.on("selected",function () {alert("1")})
</script>

+ 1
- 4
examples/network/32_hierarchicaLayoutMethods.html View File

@ -35,10 +35,7 @@
var edges = [];
// randomly create some nodes and edges
for (var i = 0; i < 15; i++) {
nodes.push({
id: i,
label: String(i)
});
nodes.push({id: i, label: String(i)});
}
edges.push({from: 0, to: 1});
edges.push({from: 0, to: 6});

+ 3
- 2
lib/network/modules/CanvasRenderer.js View File

@ -22,6 +22,7 @@ class CanvasRenderer {
this.renderRequests = 0;
this.pixelRatio = undefined;
// redefined in this._redraw
this.canvasTopLeft = {x: 0, y: 0};
this.canvasBottomRight = {x: 0, y: 0};
@ -29,7 +30,7 @@ class CanvasRenderer {
this.body.emitter.on("dragStart", () => {this.dragging = true;});
this.body.emitter.on("dragEnd", () => this.dragging = false);
this.body.emitter.on("_redraw", () => {console.log(this.renderingActive); if (this.renderingActive === false) {this._redraw();}});
this.body.emitter.on("_redraw", () => {if (this.renderingActive === false) {this._redraw();}});
this.body.emitter.on("_requestRedraw", this._requestRedraw.bind(this));
this.body.emitter.on("_startRendering", () => {this.renderRequests += 1; this.renderingActive = true; this.startRendering();});
this.body.emitter.on("_stopRendering", () => {this.renderRequests -= 1; this.renderingActive = this.renderRequests > 0;});
@ -138,7 +139,7 @@ class CanvasRenderer {
ctx.translate(this.body.view.translation.x, this.body.view.translation.y);
ctx.scale(this.body.view.scale, this.body.view.scale);
this.canvasTopLeft = this.canvas.DOMtoCanvas({x:0,y:0});
this.canvasTopLeft = this.canvas.DOMtoCanvas({x:0,y:0});
this.canvasBottomRight = this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth,y:this.canvas.frame.canvas.clientHeight});
if (hidden === false) {

+ 14
- 3
lib/network/modules/EdgesHandler.js View File

@ -137,9 +137,20 @@ class EdgesHandler {
util.mergeOptions(this.options, options, 'dashes');
if (options.arrows !== undefined) {
util.mergeOptions(this.options.arrows, options.arrows, 'to');
util.mergeOptions(this.options.arrows, options.arrows, 'middle');
util.mergeOptions(this.options.arrows, options.arrows, 'from');
if (typeof options.arrows === 'string') {
let arrows = options.arrows.toLowerCase();
if (arrows.indexOf("to") != -1) {this.options.arrows.to.enabled = true;}
if (arrows.indexOf("middle") != -1) {this.options.arrows.middle.enabled = true;}
if (arrows.indexOf("from") != -1) {this.options.arrows.from.enabled = true;}
}
else if (typeof options.arrows === 'object') {
util.mergeOptions(this.options.arrows, options.arrows, 'to');
util.mergeOptions(this.options.arrows, options.arrows, 'middle');
util.mergeOptions(this.options.arrows, options.arrows, 'from');
}
else {
throw new Error("The arrow options can only be an object or a string. Refer to the documentation. You used:" + JSON.stringify(options.arrows));
}
}
}

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

@ -93,9 +93,20 @@ class Edge {
util.mergeOptions(this.options, options, 'dashes');
if (options.arrows !== undefined) {
util.mergeOptions(this.options.arrows, options.arrows, 'to');
util.mergeOptions(this.options.arrows, options.arrows, 'middle');
util.mergeOptions(this.options.arrows, options.arrows, 'from');
if (typeof options.arrows === 'string') {
let arrows = options.arrows.toLowerCase();
if (arrows.indexOf("to") != -1) {this.options.arrows.to.enabled = true;}
if (arrows.indexOf("middle") != -1) {this.options.arrows.middle.enabled = true;}
if (arrows.indexOf("from") != -1) {this.options.arrows.from.enabled = true;}
}
else if (typeof options.arrows === 'object') {
util.mergeOptions(this.options.arrows, options.arrows, 'to');
util.mergeOptions(this.options.arrows, options.arrows, 'middle');
util.mergeOptions(this.options.arrows, options.arrows, 'from');
}
else {
throw new Error("The arrow options can only be an object or a string. Refer to the documentation. You used:" + JSON.stringify(options.arrows));
}
}
if (options.id !== undefined) {this.id = options.id;}

+ 0
- 1
lib/network/modules/components/edges/bezierEdgeDynamic.js View File

@ -94,7 +94,6 @@ class BezierEdgeDynamic extends BezierBaseEdge {
}
_findBorderPosition(nearNode, ctx) {
console.log(this)
return this._findBorderPositionBezier(nearNode, ctx, this.via);
}

+ 0
- 2
lib/network/modules/components/edges/util/bezierBaseEdge.js View File

@ -23,8 +23,6 @@ class BezierBaseEdge extends BaseEdge {
* @param viaNode
*/
_findBorderPositionBezier(nearNode, ctx, viaNode = this._getViaCoordinates()) {
console.log(nearNode, ctx, viaNode)
var maxIterations = 10;
var iteration = 0;
var low = 0;

Loading…
Cancel
Save