GithubHelp home page GithubHelp logo

Interpreting edge label position about klayjs HOT 9 CLOSED

kieler avatar kieler commented on July 30, 2024
Interpreting edge label position

from klayjs.

Comments (9)

uruuru avatar uruuru commented on July 30, 2024 1

Looks like a bug in the position application code. I'll look into it. Thanks for mentioning the issue.

from klayjs.

uruuru avatar uruuru commented on July 30, 2024

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.

jbeard4 avatar jbeard4 commented on July 30, 2024

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:

screenshot from 2016-04-12 07 27 00

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.

uruuru avatar uruuru commented on July 30, 2024

I pushed a new version that hopefully fixes the issue. Let me know if it helps.

from klayjs.

jbeard4 avatar jbeard4 commented on July 30, 2024

I will review and let you know.

from klayjs.

jbeard4 avatar jbeard4 commented on July 30, 2024

Thank you for looking into this. The issue persists. Please see the attached screenshots:

screenshot from 2016-04-13 06 56 05

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.

uruuru avatar uruuru commented on July 30, 2024

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.

jbeard4 avatar jbeard4 commented on July 30, 2024

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}.

screen shot 2016-04-13 at 11 54 46 pm

Thank you for your assistance resolving this.

from klayjs.

jbeard4 avatar jbeard4 commented on July 30, 2024

I opened a related issue here: #9. Thank you.

from klayjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.