Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

Label nodes with coordinates

+1 vote
Hi everybody,

I have a .xls file to use as input with the X and Y coordinates of each node. With the properties mapper I can assign X to label 1 and Y as label 2, so they will be shown next to each node.

Since I need to move some nodes, their coordinates will change: is there a way to refresh the X and Y labels? (I would rather avoid to manually change the numbers reading the new coordinates from the properties view...)

Thanks a lot

Best regards
in Help by

1 Answer

0 votes
Unfortunately, yEd does not offer a way to automatically write node coordinates to labels (or custom properties).

The best you can do by way of "automation" is to save your diagram to GraphML and use an XSLT processor to update the appropriate label elements with the data from the corresponding nodes' coordinates.
by [yWorks] (134k points)
Thanks for your answer, I'll try but I've never used XML language, let me ask if I understand what needs to be done in the graphML file (pasted below): the processor has to copy x and y values from the last line (geometry) to overwrite values in data key d5 and d7?

<node id="n0">
      <data key="d3" xml:space="preserve">1</data>
      <data key="d4" xml:space="preserve">161.22</data>
      <data key="d5" xml:space="preserve">506812.504</data>
      <data key="d6" xml:space="preserve">5044095.345</data>
      <data key="d7" xml:space="preserve">-5044095.345</data>
      <data key="d8">
        <y:ShapeNode>
          <y:Geometry height="10.0" width="10.0" x="506839.792" y="-5044044.282"/>

Well, yes, if  d5 and d7 are the keys for the corresponding custom properties. Note, the names "d5" and "d7" are generated on the fly when your graph is saved to GraphML. When you save the next time, your custom properties for coordinates might use different keys. The keys are defined at the start of the GraphML file in a <key attr.name="..." attr.type="double" for="node" id="..."> element. You need to find the <key> element whose attr.name attribute value matches the name of the corresponding custom property to determine the correct id.

Aside from setting the values of the data elements, I suggest updating the corresponding label texts as well. The <y:ShapeNode> element in each node should have several <y:NodeLabel ...>text</y:NodeLabel> child elements. Suppose your x-coordinate is in the second label and your y-coordinate is in the third label, then update the value for the second and third <y:NodeLabel> elements as well.

If you update only your d5/d7 data elements but not the <y:NodeLabel> elements, you can use yEd's properties mapper to update the appropriate label texts from your updated property values once you open the modified GraphML file in yEd again.

Just found that Excel can import/export xml files, I tried to open the GraphML project but the tree structure produced by mappingXML doesn't read the custom properties nor the labels, only node id and geometry. Am I missing something?
Many thanks
You probably need to define custom XML mappings in Excel to extract the data you are interested in from GraphML files. Unfortunately, this is the wrong place to ask about how to use this specific feature of Excel (or even Excel in general).
Legal Disclosure | Privacy Policy
...