Electric Coffee
Electric Coffee

Reputation: 12114

Horizontally placing clusters with node outside

I'm fiddling around in Graphviz trying to make a graph of an architecture, but no matter what I try, dot always seems to want to connect some of the nodes with the longest possible path.

Here's a sketch of how I want it to more or less look:

Masterly sketch

Here's how it actually looks:

Not so masterly graph

And here's the code in question:

digraph ngsys {
    graph [dpi = 300];
    rankdir="LR";
    subgraph cluster_client {
        style=filled;
        color=lightgrey;
        node [style=filled, color=white];
        ngcontroller -> ngmodel;
        ngmodel -> ngview;
        label="Client";
    }

    ngview -> user [style=dashed];
    user -> ngcontroller [style=dashed];

    subgraph cluster_server {
        style=filled;
        color=lightgrey;
        node [style=filled, color=white];
        apicontroller -> apimodel;
        label="Server";
    }
    ngcontroller -> apicontroller [label="REST", dir=both, style=dashed];

    ngmodel [label="NG-Model" shape=box];
    user [label="User"];
    ngview [label="NG-View", shape=box];
    ngcontroller [label="NG-Controler", shape=box];
    apicontroller [label="API-Controller", shape=box];
    apimodel [label="API-Model", shape=box];

}

Is there anything I can do to make the output look a little more akin to the sketch?

Upvotes: 0

Views: 160

Answers (1)

stefan
stefan

Reputation: 3759

a little change fixes the order:

    ngview -> ngmodel [dir=back];
    ngmodel -> ngcontroller [dir=back];

another little change improves the look:

    nodesep=1;
    ...
    ngview:s -> user [style=dashed];
    user -> ngcontroller:s [style=dashed];

Upvotes: 1

Related Questions