cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1169
Views
3
Helpful
3
Replies

View Position

m.rainer
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

aaikepae
Cisco Employee
Cisco Employee

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

View solution in original post

3 Replies 3

alzverev
Cisco Employee
Cisco Employee

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

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

aaikepae
Cisco Employee
Cisco Employee

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

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: