graphlib-dot icon indicating copy to clipboard operation
graphlib-dot copied to clipboard

Parse default graph attributes

Open cpettitt opened this issue 9 years ago • 3 comments

Currently rankdir doesn't get attached to the graph object in graphlib-dot, but it does with graphviz:

digraph {
    graph [rankdir=LR];

    X -> Y;
    Y -> X;
    Y -> Z;
    Z -> Y;
}

cpettitt avatar Sep 30 '14 12:09 cpettitt

This doesn't seem to work for any graph attributes.

HansvdLaan avatar Oct 06 '19 13:10 HansvdLaan

In https://github.com/dagrejs/graphlib-dot/blob/v0.6.4/lib/build-graph.js#L11, a missing graph: {} object causes the data to be lost in handleAttrStmt. However, I'm not sure how to merge the data from defaultStack into g.graph(), especially when it comes to subgraphs.


A workaround could be to use

digraph {
    rankdir=LR;

    X -> Y;
    Y -> X;
    Y -> Z;
    Z -> Y;
}

(demo), which is also used in some of the graphviz examples.

webmaster128 avatar Jan 31 '20 10:01 webmaster128

Another workaround is to put quotes around the names:

digraph {
    "graph" [rankdir=LR]
}

becomes

digraph {
    graph [rankdir=LR]
}

This works for node and edge defaults too.

metarmask avatar Aug 17 '20 19:08 metarmask