- Trying to save the position of our nodes and nodesets to database. Everything works fine so far. But when using "dataProcessor: force or nextforce"
- The nodes move automatically when being saved and reloaded.
- When using dataProcessor could recognize some new values in nodes. (px, py or dx, dy).
- Want to understand what these values are and how to use them when saving positions.
If you have properties x and y set for the nodes, 'force layout' skips those nodes.
last project had savable layout (but stored data in local data storage).
We had an object dumpData, which had a property 'nodes' (array). Each node had x and y properties.
$scope.readDumpData = function(){ if($scope.dumpData && $scope.dumpData.nodes ){ $scope.dumpData.nodes.forEach(function(node, index, nodes){ nodeInst = $scope.topo.getNode($scope.topologyData.nodesDict.getItem(node.nodeName)); if(nodeInst != undefined) nodeInst.position({'x': node.x, 'y': node.y}); }); } };
What is not typical in this code is $scope and something called nodesDict. $scope is an AngularJS object for interaction within directives/controllers/etc. nodesDict is a nx.data.Dictionary object that associates a node's name with its internal id. This is specific to the project, but you may try to modify and reuse the code.
- Understood correctly. If X and Y are set to a node, the dataProcessor "force" or "nextforce" should be ignored. But unfortunately it behaves in a different manner. Every time we save nodes with (X,Y) and reload them we have a delta. Most times it's small but sometimes its really big. This does not happen if we do not use "force" or "nextforce".
One tips for that, if node already has x,y attribute and you don't want that involve in force layout. you can add 'fixed:true' to you data to achieve that.
Comments
0 comments
Please sign in to leave a comment.