@ -118,8 +118,6 @@ function Network (container, data, options) {
this . nodesHandler = new NodesHandler ( this . body , images , groups , this . layoutEngine ) ; // Handle adding, deleting and updating of nodes as well as global options
this . nodesHandler = new NodesHandler ( this . body , images , groups , this . layoutEngine ) ; // Handle adding, deleting and updating of nodes as well as global options
this . edgesHandler = new EdgesHandler ( this . body , images , groups ) ; // Handle adding, deleting and updating of edges as well as global options
this . edgesHandler = new EdgesHandler ( this . body , images , groups ) ; // Handle adding, deleting and updating of edges as well as global options
// this event will trigger a rebuilding of the cache everything. Used when nodes or edges have been added or removed.
// this event will trigger a rebuilding of the cache everything. Used when nodes or edges have been added or removed.
this . body . emitter . on ( "_dataChanged" , ( params ) => {
this . body . emitter . on ( "_dataChanged" , ( params ) => {
var t0 = new Date ( ) . valueOf ( ) ;
var t0 = new Date ( ) . valueOf ( ) ;
@ -238,10 +236,13 @@ Network.prototype.setData = function(data) {
}
}
}
}
else {
else {
this . nodesHandler . setData ( data && data . nodes ) ;
this . edgesHandler . setData ( data && data . edges ) ;
this . nodesHandler . setData ( data && data . nodes , true ) ;
this . edgesHandler . setData ( data && data . edges , true ) ;
}
}
// emit change in data
this . body . emitter . emit ( "_dataChanged" ) ;
// find a stable position or start animating to a stable position
// find a stable position or start animating to a stable position
this . body . emitter . emit ( "initPhysics" ) ;
this . body . emitter . emit ( "initPhysics" ) ;
} ;
} ;
@ -347,7 +348,7 @@ Network.prototype.destroy = function() {
this . body . emitter . off ( ) ;
this . body . emitter . off ( ) ;
// remove the container and everything inside it recursively
// remove the container and everything inside it recursively
this . util . recursiveDOMDelete ( this . body . container ) ;
util . recursiveDOMDelete ( this . body . container ) ;
} ;
} ;
@ -549,49 +550,13 @@ Network.prototype._updateValueRange = function(obj) {
} ;
} ;
/ * *
* Set the translation of the network
* @ param { Number } offsetX Horizontal offset
* @ param { Number } offsetY Vertical offset
* @ private
* /
Network . prototype . _setTranslation = function ( offsetX , offsetY ) {
if ( this . translation === undefined ) {
this . translation = {
x : 0 ,
y : 0
} ;
}
if ( offsetX !== undefined ) {
this . translation . x = offsetX ;
}
if ( offsetY !== undefined ) {
this . translation . y = offsetY ;
}
this . emit ( 'viewChanged' ) ;
} ;
/ * *
* Get the translation of the network
* @ return { Object } translation An object with parameters x and y , both a number
* @ private
* /
Network . prototype . _getTranslation = function ( ) {
return {
x : this . translation . x ,
y : this . translation . y
} ;
} ;
/ * *
/ * *
* Scale the network
* Scale the network
* @ param { Number } scale Scaling factor 1.0 is unscaled
* @ param { Number } scale Scaling factor 1.0 is unscaled
* @ private
* @ private
* /
* /
Network . prototype . _setScale = function ( scale ) {
Network . prototype . _setScale = function ( scale ) {
this . scale = scale ;
this . body . view . scale = scale ;
} ;
} ;
/ * *
/ * *
@ -600,21 +565,7 @@ Network.prototype._setScale = function(scale) {
* @ private
* @ private
* /
* /
Network . prototype . _getScale = function ( ) {
Network . prototype . _getScale = function ( ) {
return this . scale ;
} ;
/ * *
* load the functions that load the mixins into the prototype .
*
* @ private
* /
Network . prototype . _initializeMixinLoaders = function ( ) {
for ( var mixin in MixinLoader ) {
if ( MixinLoader . hasOwnProperty ( mixin ) ) {
Network . prototype [ mixin ] = MixinLoader [ mixin ] ;
}
}
return this . body . view . scale ;
} ;
} ;
@ -622,6 +573,7 @@ Network.prototype._initializeMixinLoaders = function () {
* Load the XY positions of the nodes into the dataset .
* Load the XY positions of the nodes into the dataset .
* /
* /
Network . prototype . storePositions = function ( ) {
Network . prototype . storePositions = function ( ) {
// todo: incorporate fixed instead of allowedtomove, add support for clusters and hierarchical.
var dataArray = [ ] ;
var dataArray = [ ] ;
for ( var nodeId in this . body . nodes ) {
for ( var nodeId in this . body . nodes ) {
if ( this . body . nodes . hasOwnProperty ( nodeId ) ) {
if ( this . body . nodes . hasOwnProperty ( nodeId ) ) {