Git Product home page Git Product logo

Comments (4)

dmulyalin avatar dmulyalin commented on July 22, 2024

Hi, thank you for reporting the issue.

That was a restriction in drawio module in release 0.1.2 but latest code on master brunch includes capability to add labels to links/edges for drawio diagrams - docs - added it as result of working on #1. If you want to test, feel free to install from master:

python3 -m pip install git+https://github.com/dmulyalin/N2G

Yet to release N2G 0.2.0, as planning to add new features and refactor the code a bit. But 0.2.0 will include capability to add src/trgt labels to edges for drawio.

from n2g.

stigmergist avatar stigmergist commented on July 22, 2024

Thanks for the reply. I am using the latest from master branch. These two links do not have labels (nor need them), but one is A->B and the other is B->A. They are getting collapsed into a single link (which is semantically incorrect for what I need).

I did a clean venv with the pip install approach and the same result.

from n2g.

dmulyalin avatar dmulyalin commented on July 22, 2024

Ok, I see.

Each link need to have unique ID attribute assigned, the most natural way is to use link labels and source/target nodes ID to derive link id. If several links with no labels added between same nodes, links will end up with same ID value calculated, by default second link will be skipped as a duplicate.

Added support for optional link_id attribute to add_link method starting with commit 78c7395. link_id must be unique across all links on this particular diagram.

from N2G import drawio_diagram as create_drawio_diagram

data = {
    "nodes": [
        {"id": "node-1"},
        {"id": "node-2"}
    ],
    "links": [
        {
            "source": "node-1", 
            "target": "node-2", 
            "link_id": 1,
            'style': 'endArrow=classic;endFill=0;sourcePortConstraint=east;targetPortConstraint=west;edgeStyle=orthogonalEdgeStyle;'
        },
        {
            "source": "node-2", 
            "target": "node-1", 
            "link_id": 2,
            'style': 'endArrow=classic;endFill=0;sourcePortConstraint=east;targetPortConstraint=west;edgeStyle=orthogonalEdgeStyle;'
        }
    ]
}    

drawio_drawing = create_drawio_diagram()
drawio_drawing.from_dict(data)
drawio_drawing.dump_file("diagram.drawio", ".")

from n2g.

stigmergist avatar stigmergist commented on July 22, 2024

Great - that works. Can work with that. Thanks.

BTW you need to add ttp and openpyxl to your package dependencies in the instructions

from n2g.

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.