12-22-2015 05:37 AM
Hello,
We are 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 we recognize some new values in nodes. (px, py or dx, dy).
Can anybody help us to understand what these values are and how we have to use them when saving positions?
Thanks a lot
Markus
Solved! Go to Solution.
02-10-2016 04:06 PM
Hi Markus,
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.
Abu
12-22-2015 09:34 AM
Hey Markus,
If you have properties x and y set for the nodes, 'force layout' skips those nodes.
In my last project I also had savable layout (but I 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 our project, but you may try to modify and reuse the code.
Get back to me if it has not solved the problem
- Alex
12-23-2015 12:18 AM
Hi Alex,
Thanks a lot for your prompt answer.
Hope I do understand this correctly. If X and Y are set to a node, the dataProcessor "force" or "nextforce" should be ignored.
Is this correct?
That really would make sense to me, 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".
Best regards
Markus
02-10-2016 04:06 PM
Hi Markus,
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.
Abu
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide