Onion Diagram (Nested Ellipses)

Hi, I’m trying to draw a simple onion diagram for stakeholder analysis. Please, see examples [1], or [2].
Am I taking the right approach here by using nested subgraphs in the code snippet below?
I haven’t quite grasped the dot syntax yet and would greatly appreciate your help!

digraph O {
    subgraph layer4 {
        shape = ellipse;
        label = "Wider Environment";
        subgraph layer3 {
            shape = ellipse;
            label = "Containing System";
            subgraph layer2 {
                shape = ellipse;
                label = "System";
                subgraph layer1 {
                    shape = ellipse;
                    label = "Product";
                }
            }
        }
    }
}

1:
2: https://d3n817fwly711g.cloudfront.net/uploads/2019/01/New-Stakeholder-Onion-Diagram-.png

In the ballpark. A subgraph is more of a subset or grouping, and does not produce a physical shape. What you probably want is a cluster subgraph (I suggest reading the Dot User Guide https://www.graphviz.org/pdf/dotguide.pdf)
Anyway, clusters can’t be oval-shaped, but they can be rounded rectangles. Maybe close enough for your needs.

digraph O {
    subgraph cluster_layer4 {
        style=rounded  // close enough to onion shape??
        //shape = ellipse; 
        label = "Wider Environment";
        subgraph cluster_layer3 {
            //shape = ellipse;
            label = "Containing System";
            subgraph cluster_layer2 {
                //shape = ellipse;
                label = "System";
                subgraph cluster_layer1 {
                    //shape = ellipse;
                    label = "Product";
		    inner [style=invis] // bogus node
                }
            }
        }
    }
}  

onion1

Except for the patchwork algorithm, the Graphviz algorithms are focused on producing node-link diagrams for combinatorial graphs. The raw data here consists of nested sets, with no explicit edges, and the desired layout is not a node-link diagram. None of the Graphviz algorithms will give you what you want, with Steve’s suggestion being about the best you can do. The underlying graphics model can draw what you want, but this would require someone to write the algorithm to convert your data into the output you want.

Hi @steveroush, thank you for your prompt response. Even though it’s not exactly the shape I was looking for, I’ve learnt a great deal from the doc that you’ve linked!

Hi @erg , thank you for your detailed explanation. I’ll look more into the patchwork engine and see what I can do.

  • First let’s note that Graphviz is not well suited to producing Onion diagrams. Graphviz can produce many cool graphs, but Onion diagrams weren’t on the requirements list.

  • If you are only intending to produce one or two of these diagrams, a gui-based drawing program might be best.

  • If you want to automate the process, you might also look at dpic (Dpic distribution). A bit lower-level, but more explicit positioning commands.

  • If you are still interested in using Graphviz, here is a way to get nested ellipses:

    graph nest {
    // built by hand/eyeball
    node [shape=ellipse fixedsize=true]
    a [width=3 height=2.2 pos=“400,100” label=“first\n\n\n\n\n\n\n” ]
    b [width=2 height=1.4 pos=“400,75” label=“second\n\n\n\n\n” ]
    c [width=1 height=.8 pos=“400,60” label=“third” ]

    notes[shape=plaintext  pos="700,60" label=<
      <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
      <TR><TD PORT="p1">note 1</TD></TR>
      <TR><TD PORT="p2">note 3</TD></TR>
      <TR><TD PORT="p3">note 2</TD></TR>
      </TABLE>>  ]
    
    edge[style=dotted]
    a--notes:p1
    b--notes:p2
    c--notes:p3    
    

    }

Producing this:
nestedEllipse

Instead of using dot, this uses neato -n (see the FAQ FAQ | Graphviz)
The downside is that you have to provide all the positioning and sizing - a pain the first time, but pretty easy to automate

hello, koblih
have you got an union diagram, could you share some ideas at here?