@@ -25,7 +25,8 @@ var defaultConfig = {
2525 edgeHoverEffect : true ,
2626 passiveUIEvents : false ,
2727 readOnly : false ,
28- restrictTranslate : false
28+ restrictTranslate : false ,
29+ incrementNodeNames : false
2930} ;
3031
3132class SelectedItem {
@@ -140,12 +141,12 @@ class Graph extends Element {
140141 ...item ,
141142 id : Number ( `${ Date . now ( ) } ${ Math . floor ( Math . random ( ) * 10000 ) } ` )
142143 } ;
144+ if ( item . attributes ) {
145+ node . attributes = { ...item . attributes } ;
146+ }
143147 delete node . action ;
144148 delete node . text ;
145149 delete node . onClick ;
146- if ( node . name ) {
147- node . name = `${ node . name } ${ Object . keys ( this . _graphData . get ( 'data.nodes' ) ) . length } ` ;
148- }
149150 var nodeSchema = this . _graphSchema . nodes [ node . nodeType ] ;
150151 if ( nodeSchema . attributes && ! node . attributes ) {
151152 node . attributes = { } ;
@@ -157,6 +158,9 @@ class Graph extends Element {
157158 }
158159 } ) ;
159160 }
161+ if ( this . _config . incrementNodeNames && node . attributes . name ) {
162+ node . attributes . name = `${ node . attributes . name } ${ Object . keys ( this . _graphData . get ( 'data.nodes' ) ) . length } ` ;
163+ }
160164 let element = e . target ;
161165 while ( ! element . classList . contains ( 'pcui-contextmenu' ) ) {
162166 element = element . parentElement ;
@@ -355,6 +359,8 @@ class Graph extends Element {
355359 value . forEach ( ( v , i ) => {
356360 node . attributes [ attributeKey ] [ keyMap [ i ] ] = v ;
357361 } ) ;
362+ } else if ( Object . keys ( prevAttributeValue ) . includes ( 'x' ) && Number . isFinite ( value ) ) {
363+ node . attributes [ attributeKey ] . x = value ;
358364 } else {
359365 node . attributes [ attributeKey ] = value ;
360366 }
0 commit comments