@ -49,10 +49,16 @@ Dag.prototype.setConfig = function (o) {
* create dag
* create dag
* /
* /
Dag . prototype . create = function ( ) {
Dag . prototype . create = function ( ) {
let self = this
jsPlumb . ready ( ( ) = > {
jsPlumb . ready ( ( ) = > {
JSP . init ( {
JSP . init ( {
dag : this . dag ,
dag : this . dag ,
instance : this . instance
instance : this . instance ,
options : {
onRemoveNodes ( $id ) {
self . dag . removeEventModelById ( $id )
}
}
} )
} )
// init event
// init event
@ -108,7 +114,7 @@ Dag.prototype.backfill = function (arg) {
tmp . push ( locationsValue2 [ i ] )
tmp . push ( locationsValue2 [ i ] )
}
}
}
}
function copy ( array ) {
function copy ( array ) {
let newArray = [ ]
let newArray = [ ]
for ( let item of array ) {
for ( let item of array ) {
@ -117,7 +123,7 @@ Dag.prototype.backfill = function (arg) {
return newArray ;
return newArray ;
}
}
let newArr = copy ( arr )
let newArr = copy ( arr )
function getNewArr ( ) {
function getNewArr ( ) {
for ( let i = 0 ; i < newArr . length ; i + + ) {
for ( let i = 0 ; i < newArr . length ; i + + ) {
@ -231,7 +237,7 @@ Dag.prototype.backfill = function (arg) {
for ( let i = 0 ; i < listarrs . length ; i + + ) {
for ( let i = 0 ; i < listarrs . length ; i + + ) {
delete ( listarrs [ i ] . id )
delete ( listarrs [ i ] . id )
}
}
for ( let a = 0 ; a < listarr . length ; a + + ) {
for ( let a = 0 ; a < listarr . length ; a + + ) {
dataObject [ listarr [ a ] . id ] = listarrs [ a ]
dataObject [ listarr [ a ] . id ] = listarrs [ a ]
}
}
@ -250,9 +256,9 @@ Dag.prototype.backfill = function (arg) {
}
}
} ;
} ;
}
}
lastchildren = lastchildren . sort ( createComparisonFunction ( 'x' ) )
lastchildren = lastchildren . sort ( createComparisonFunction ( 'x' ) )
// Coordinate value of each leaf node
// Coordinate value of each leaf node
for ( let a = 0 ; a < lastchildren . length ; a + + ) {
for ( let a = 0 ; a < lastchildren . length ; a + + ) {
dataObject [ lastchildren [ a ] . id ] . y = ( a + 1 ) * 120
dataObject [ lastchildren [ a ] . id ] . y = ( a + 1 ) * 120
@ -280,12 +286,18 @@ Dag.prototype.backfill = function (arg) {
if ( countTree > 1 ) {
if ( countTree > 1 ) {
dataObject [ Object . keys ( locationsValue1 ) [ 0 ] ] . y = ( countTree / 2 ) * 120 + 50
dataObject [ Object . keys ( locationsValue1 ) [ 0 ] ] . y = ( countTree / 2 ) * 120 + 50
}
}
locationsValue = dataObject
locationsValue = dataObject
let self = this
jsPlumb . ready ( ( ) = > {
jsPlumb . ready ( ( ) = > {
JSP . init ( {
JSP . init ( {
dag : this . dag ,
dag : this . dag ,
instance : this . instance
instance : this . instance ,
options : {
onRemoveNodes ( $id ) {
self . dag . removeEventModelById ( $id )
}
}
} )
} )
// Backfill
// Backfill
JSP . jspBackfill ( {
JSP . jspBackfill ( {
@ -298,10 +310,16 @@ Dag.prototype.backfill = function (arg) {
} )
} )
} )
} )
} else {
} else {
let self = this
jsPlumb . ready ( ( ) = > {
jsPlumb . ready ( ( ) = > {
JSP . init ( {
JSP . init ( {
dag : this . dag ,
dag : this . dag ,
instance : this . instance
instance : this . instance ,
options : {
onRemoveNodes ( $id ) {
self . dag . removeEventModelById ( $id )
}
}
} )
} )
// Backfill
// Backfill
JSP . jspBackfill ( {
JSP . jspBackfill ( {