Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loses positions of nodes #15

Open
PermanAtayev opened this issue Jul 12, 2019 · 9 comments
Open

Loses positions of nodes #15

PermanAtayev opened this issue Jul 12, 2019 · 9 comments

Comments

@PermanAtayev
Copy link

For the graph below with the layout option "preset" initial positions of the nodes are lost

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
     http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G" edgedefault="undirected">
    <node id="n0"/>
	    <data key="x">122.50374073928583</data>
		<data key="y">367.98329788349827</data>
    <node id="n1"/>
	    <data key="x">100</data>
		<data key="y">300</data>
    <node id="n2"/>
	    <data key="x">150</data>
		<data key="y">300</data>
    <node id="n3"/>
    <node id="n4"/>
    <node id="n5"/>
    <node id="n6"/>
    <node id="n7"/>
    <node id="n8"/>
    <node id="n9"/>
    <node id="n10"/>
    <edge source="n0" target="n2"/>
    <edge source="n1" target="n2"/>
    <edge source="n2" target="n3"/>
    <edge source="n3" target="n5"/>
    <edge source="n3" target="n4"/>
    <edge source="n4" target="n6"/>
    <edge source="n6" target="n5"/>
    <edge source="n5" target="n7"/>
    <edge source="n6" target="n8"/>
    <edge source="n8" target="n7"/>
    <edge source="n8" target="n9"/>
    <edge source="n8" target="n10"/>
  </graph>
</graphml>
@hasanbalci
Copy link
Contributor

AFAIK, graphml format doesn't include a separate structure or keyword for the position information. It is also given as a data element, so extension stores that information in node's data field. Position information can be reached from node's data field after import.

In my opinion, estimating position information from a data element and assigning it directly to the node's position field is not so convenient. Because, user may define position information with different names. (In the above file, it is x and y, but in another file it can be xPos and yPos.)

@ugurdogrusoz
Copy link
Contributor

@hasanbalci Does this extension recognize any of these ways to specify location? Can we perhaps make it recognize some commonly accepted location and dimension specification keywords?

@hasanbalci
Copy link
Contributor

hasanbalci commented Jul 25, 2019

No, it doesn't recognize. But maybe we can specify 'x' and 'y' for the position and 'width' and 'height' for the dimension.

@ugurdogrusoz
Copy link
Contributor

@JustDoIt1999 Could you please work on this and modify this extension to recognize 'x', 'y', 'width', and 'height'?

@PermanAtayev
Copy link
Author

PermanAtayev commented Jul 25, 2019

@ugurdogrusoz of course

@zeeshanullah
Copy link

A node in my graphml looks like this

<node id="n0">
      <data key="d0">
        <y:ImageNode>
          <y:Geometry height="48.0" width="48.0" x="-24.0" y="694.0"/>
          <y:Fill color="#CCCCFF" transparent="false"/>
          <y:BorderStyle color="#000000" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content" backgroundColor="#FFFFFF" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasLineColor="false" height="18.701171875" modelName="sides" modelPosition="e" textColor="#000000" visible="true" width="39.34375" x="52.0" y="14.6494140625">Server</y:NodeLabel>
          <y:Image refid="1"/>
        </y:ImageNode>
      </data>
      <data key="d1"/>
</node>

I am interested in the nodes position x and y. Since position cannot be recognized by the library, Can you guide me how can I access that manually? @PermanAtayev

@PermanAtayev
Copy link
Author

PermanAtayev commented Oct 28, 2019

You can access it as follows:
let obj = {}; obj["position"] = { x: parseInt(ele.data('x')), y: parseInt(ele.data('y')) };
where ele is a node in cytoscape.js

@zeeshanullah

@zeeshanullah
Copy link

I already tried this but it returns NaN for both values.

$graph.children("node").each(function () {
      var $node = $(this);

      var settings = {
        data: {id: $node.attr("id")},
        css: {},
        position: { x: parseInt($node.data('x')), y: parseInt($node.data('y')) }
      };

@PermanAtayev

@PermanAtayev
Copy link
Author

PermanAtayev commented Oct 31, 2019

This type of graphml is not supported by the extension, please use the format I provided for this issue.
@zeeshanullah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants