Comments (9)
Looks like a bug in the position application code. I'll look into it. Thanks for mentioning the issue.
from klayjs.
The expected behavior would be that both labels are relative to the parent node of their corresponding source node. In this case that is the invisible root node.
There's an example model which illustrates what coordinates are relative to.
Note that for us a label's coordinates denote the top-left corner, I'm not sure if that's the case for svg text as well.
from klayjs.
Thank you @uruuru, the documentation you linked to is what I was looking for. Unfortunately, the edge label coordinates do not appear to include the correct offset. Please see the attached screenshot, which illustrates label position in the root element coordinate space:
Here is the SVG as a reference:
<svg class="schviz2 ng-isolate-scope" display-model="displayModel" viewBox="0 -10 109.78124904632568 53">
<desc>Created with Snap</desc><defs></defs>
<g>
<g class="node compound">
<rect></rect>
<g id="off" transform="matrix(1,0,0,1,87.7812,20.6667)" class="node leaf highlighted">
<rect x="0" y="0" width="10" height="10"></rect><text x="2.5" y="6.5">off</text>
</g>
<path d="M87.78124904632568 24 L22 24" class="link"></path>
<text x="37.99999952316284" y="0">touch</text>
<g id="on" transform="matrix(1,0,0,1,12,20.6667)" class="node leaf">
<rect x="0" y="0" width="10" height="10"></rect><text x="2.5" y="6.5">on</text>
</g>
<path d="M22 27.333333333333332 L35.99999976158142 27.333333333333332 L35.99999976158142 40 L73.78124928474426 40 L73.78124928474426 27.333333333333336 L87.78124904632568 27.333333333333336" class="link"></path>
<text x="37.99999952316284" y="16">touch</text>
</g>
</g>
<defs>
<marker id="end" viewBox="0 -5 10 10" refX="10" refY="0" markerWidth="3" markerHeight="5" orient="auto">
<path d="M0,-5L10,0L0,5"></path>
</marker>
</defs>
</svg>
Is it possible this is a bug in the edge label positioning algorithm? Thank you.
from klayjs.
I pushed a new version that hopefully fixes the issue. Let me know if it helps.
from klayjs.
I will review and let you know.
from klayjs.
Thank you for looking into this. The issue persists. Please see the attached screenshots:
And SVG:
<svg class="schviz2 ng-isolate-scope" display-model="displayModel" viewBox="0 0 109.78124904632568 53">
<desc>Created with Snap</desc>
<defs/>
<g>
<g class="node compound">
<rect/>
<g id="off" transform="matrix(1,0,0,1,87.7812,20.6667)" class="node leaf highlighted">
<rect x="0" y="0" width="10" height="10"/>
<text x="2.5" y="6.5">off</text>
</g>
<path d="M87.78124904632568 24 L22 24" class="link"/>
<text x="49.99999952316284" y="12">touch</text>
<g id="on" transform="matrix(1,0,0,1,12,20.6667)" class="node leaf">
<rect x="0" y="0" width="10" height="10"/>
<text x="2.5" y="6.5">on</text>
</g>
<path d="M22 27.333333333333332 L35.99999976158142 27.333333333333332 L35.99999976158142 40 L73.78124928474426 40 L73.78124928474426 27.333333333333336 L87.78124904632568 27.333333333333336" class="link"/>
<text x="49.99999952316284" y="28">touch</text>
</g>
</g>
<defs>
<marker id="end" viewBox="0 -5 10 10" refX="10" refY="0" markerWidth="3" markerHeight="5" orient="auto">
<path d="M0,-5L10,0L0,5"/>
</marker>
</defs>
</svg>
from klayjs.
The positions look correct to me. The upper touch
label is at ~50, 12
, where 12
is the default distance to the border. Is it possible that the svg's text coordinates refer to the bottom-left corner and you have to add the height of the label?
from klayjs.
Hi @uruuru. You are correct. I had to set dominant-baseline="text-before-edge" on the SVG text element in order to make the x, y coordinates equivalent to the top left corner of the text. This returns a good result. Here is the output, with option { labelSpacing : 1}
.
Thank you for your assistance resolving this.
from klayjs.
I opened a related issue here: #9. Thank you.
from klayjs.
Related Issues (20)
- Calculate positions for self loops and orthogonal routing style. HOT 1
- Max graph width and node 'wrap' HOT 13
- Time Savings with Interactive Mode HOT 3
- Location of the Java source code HOT 5
- Force edge to leave and re-enter parent source node when targeting descendant node HOT 2
- Set the spacing of cross-hierachy edge virtual ports HOT 9
- Tips for improving efficiency HOT 2
- Allow node and edge id's as integers. HOT 2
- layouter's `error` callback function must be specified
- Global layout option not applied HOT 4
- bendPoints must be set for interactive layout HOT 6
- pretty development version HOT 6
- collapse parent HOT 1
- child edge positioning HOT 2
- Different direction within the graph HOT 5
- 'Short hierarchical edges' not imported if layoutHierarchy false
- When do you plan to provide a new version? HOT 14
- How to compile from original source? HOT 2
- intCoordinates results in misaligned edges originating from and targeting the same port HOT 5
- Help with debugging; exception after adding a node HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from klayjs.