dagrejs / dagre

Directed graph layout for JavaScript
MIT License
4.75k stars 607 forks source link

Importing dagre.js after traspiling with Babel #450

Open vakokako opened 3 months ago

vakokako commented 3 months ago

Hi, I want to preface this by saying that we are not knowledgeable with javascript importing, but would be grateful if you can help us with our problem :)

We want to use dagre in application that uses Qml for UI. Qml runtime allows to import javascript files to use in Qml, but only supports Ecmascript version 7. Our solution was to use Babel to transpile the dagre.js to ES7, then Qml engine seems to parse the dagre.js correctly without complaints. However, after importing dagre.js, we can't access the exported variables, like dagre.graphlib.

Are there any reasons that this should not work, if Qml engine implements ES7. Maybe dagre.js is only supposed to work in browsers? Or some other checks during import fail... Would be super helpful to hear some input on this.

I'm also attaching the transpiled dagre.js. dagre.es7.zip

emmenlau commented 3 months ago

I think it would be awesome if dagre could be used from Qt QML!

Qt does not provide any layouting of graphs. There is the nice Qt QML library QuickQanava that can be used to display and interact with complex graph layouts, but it also does not provide any layouting. dagre would be a perfect extension for this! And I think the QuickQanava developers would be interested to add dagre bindings.