|
@ -570,7 +570,6 @@ Network.prototype.setData = function(data, disableStart) { |
|
|
Network.prototype.setOptions = function (options) { |
|
|
Network.prototype.setOptions = function (options) { |
|
|
if (options) { |
|
|
if (options) { |
|
|
var prop; |
|
|
var prop; |
|
|
|
|
|
|
|
|
var fields = ['nodes','edges','smoothCurves','hierarchicalLayout','clustering','navigation', |
|
|
var fields = ['nodes','edges','smoothCurves','hierarchicalLayout','clustering','navigation', |
|
|
'keyboard','dataManipulation','onAdd','onEdit','onEditEdge','onConnect','onDelete','clickToUse' |
|
|
'keyboard','dataManipulation','onAdd','onEdit','onEditEdge','onConnect','onDelete','clickToUse' |
|
|
]; |
|
|
]; |
|
@ -688,24 +687,25 @@ Network.prototype.setOptions = function (options) { |
|
|
if (options.labels) { |
|
|
if (options.labels) { |
|
|
throw new Error('Option "labels" is deprecated. Use options "locale" and "locales" instead.'); |
|
|
throw new Error('Option "labels" is deprecated. Use options "locale" and "locales" instead.'); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// (Re)loading the mixins that can be enabled or disabled in the options.
|
|
|
|
|
|
// load the force calculation functions, grouped under the physics system.
|
|
|
|
|
|
this._loadPhysicsSystem(); |
|
|
|
|
|
// load the navigation system.
|
|
|
|
|
|
this._loadNavigationControls(); |
|
|
|
|
|
// load the data manipulation system
|
|
|
|
|
|
this._loadManipulationSystem(); |
|
|
|
|
|
// configure the smooth curves
|
|
|
|
|
|
this._configureSmoothCurves(); |
|
|
|
|
|
|
|
|
// (Re)loading the mixins that can be enabled or disabled in the options.
|
|
|
|
|
|
// load the force calculation functions, grouped under the physics system.
|
|
|
|
|
|
this._loadPhysicsSystem(); |
|
|
|
|
|
// load the navigation system.
|
|
|
|
|
|
this._loadNavigationControls(); |
|
|
|
|
|
// load the data manipulation system
|
|
|
|
|
|
this._loadManipulationSystem(); |
|
|
|
|
|
// configure the smooth curves
|
|
|
|
|
|
this._configureSmoothCurves(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind keys. If disabled, this will not do anything;
|
|
|
|
|
|
this._createKeyBinds(); |
|
|
|
|
|
this.setSize(this.constants.width, this.constants.height); |
|
|
|
|
|
this.moving = true; |
|
|
|
|
|
this.start(); |
|
|
|
|
|
|
|
|
// bind keys. If disabled, this will not do anything;
|
|
|
|
|
|
this._createKeyBinds(); |
|
|
|
|
|
|
|
|
|
|
|
this.setSize(this.constants.width, this.constants.height); |
|
|
|
|
|
this.moving = true; |
|
|
|
|
|
this.start(); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -732,11 +732,9 @@ Network.prototype._create = function () { |
|
|
//////////////////////////////////////////////////////////////////
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
this.frame.canvas = document.createElement("canvas"); |
|
|
this.frame.canvas = document.createElement("canvas"); |
|
|
|
|
|
|
|
|
this.frame.canvas.style.position = 'relative'; |
|
|
this.frame.canvas.style.position = 'relative'; |
|
|
this.frame.appendChild(this.frame.canvas); |
|
|
this.frame.appendChild(this.frame.canvas); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.frame.canvas.getContext) { |
|
|
if (!this.frame.canvas.getContext) { |
|
|
var noCanvas = document.createElement( 'DIV' ); |
|
|
var noCanvas = document.createElement( 'DIV' ); |
|
|
noCanvas.style.color = 'red'; |
|
|
noCanvas.style.color = 'red'; |
|
@ -746,17 +744,13 @@ Network.prototype._create = function () { |
|
|
this.frame.canvas.appendChild(noCanvas); |
|
|
this.frame.canvas.appendChild(noCanvas); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
|
|
|
|
|
|
var ctx = this.frame.canvas.getContext("2d"); |
|
|
var ctx = this.frame.canvas.getContext("2d"); |
|
|
|
|
|
|
|
|
this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || |
|
|
this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || |
|
|
ctx.mozBackingStorePixelRatio || |
|
|
ctx.mozBackingStorePixelRatio || |
|
|
ctx.msBackingStorePixelRatio || |
|
|
ctx.msBackingStorePixelRatio || |
|
|
ctx.oBackingStorePixelRatio || |
|
|
ctx.oBackingStorePixelRatio || |
|
|
ctx.backingStorePixelRatio || 1); |
|
|
ctx.backingStorePixelRatio || 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.frame.canvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); |
|
|
this.frame.canvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -784,7 +778,7 @@ Network.prototype._create = function () { |
|
|
this.hammerFrame = Hammer(this.frame, { |
|
|
this.hammerFrame = Hammer(this.frame, { |
|
|
prevent_default: true |
|
|
prevent_default: true |
|
|
}); |
|
|
}); |
|
|
this.hammerFrame.on('release', me._onRelease.bind(me) ); |
|
|
|
|
|
|
|
|
this.hammerFrame.on('release', me._onRelease.bind(me) ); |
|
|
|
|
|
|
|
|
// add the frame to the container element
|
|
|
// add the frame to the container element
|
|
|
this.containerElement.appendChild(this.frame); |
|
|
this.containerElement.appendChild(this.frame); |
|
|