Tims
Tims

Reputation: 641

Graphviz nodes on a timeline

What do I do to ensure April and May fall between Jan and Aug? Is there a solution without the use of hidden nodes/edges?

   digraph G {
        
        rankdir=LR;
    
      "09/30/2021"->"12/03/2021"->"01/05/2022"->"08/19/2022";
      "12/03/2021"->"04/27/2022"->"05/25/2022";
    
    }

https://dreampuf.github.io/GraphvizOnline/

Upvotes: 0

Views: 564

Answers (1)

Here's how to get your timeline linear using a cluster. Then to get the other arcs not to be inside the cluster, give them nodes outside the cluster. You can always hide these (and fix the one out of Sep) - yes there may be a way to not use hidden nodes, not sure why you'd want to avoid this.

digraph G {
    rankdir=LR;
    subgraph cluster_0 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=white];
        Jan->Feb->Mar -> Apr->May->Jun->Jul->Aug->Sep->Oct->Nov->Dec;
        label = "timeline";
    }

    Sep->op1->Mar->op2->May->op3->Aug;
    Mar->op4->Apr->op5->May;
}

Produces this:

image produced using dot.exe -Tpng -O timeline.dot

Upvotes: 1

Related Questions