0

I'm trying to create a flow chart using the DiagrammeR package in R and wish to have the arrows start from and point to the center of each node. I tried to use the headclip and tailclip options and they seem to help get the arrows start from and end at the same point. However, for some reason, it starts from the center of the node and oddly overlaps with the nodes. This is the code I've been using and the (incorrect) output diagram:

data <- list(a=1000, b=800, c=600, d=400)

grViz("
      digraph flowchart {
      graph [layout = dot, rankdir = LR]
      # node definitions with substituted label text
      node [fontname = Helvetica, shape = rectangle, fixedsize = true, width = 3, height = 0.8]        
      tab1 [label = '@@1'];
      tab2 [label = '@@2'];
      tab3 [label = '@@3'];
      tab4 [label = '@@4'];
      tab5 [label = '@@5'];

      node [fontname = Helvetica, shape = rectangle, fixedsize = true, width = 3, height = 0.5] 
      rank = same; tab6; tab7; tab8; tab9;
      tab6 [label = '@@6']
      tab7 [label = '@@7']
      tab8 [label = '@@8']
      tab9 [label = '@@9']
      tab10 [label = '@@10']
      tab11 [label = '@@11']

      # edge definitions with the node IDs
      edge[tailclip = false, headclip = false];
      tab1 -> tab3 -> {tab6 tab7 tab8 tab9};
      tab1 -> tab4;
      tab2 -> tab4;
      tab2 -> tab5 -> {tab10 tab11};
      }

      [1]: paste0('Status known at 30 days \\n (n = ', data$a, ')')
      [2]: paste0('Status known at 1 year \\n (n = ', data$a, ')')
      [3]: paste0('Status known at 30 days \\n but not 1 year \\n (n = ', data$a, ')')
      [4]: paste0('Status known for both \\n 30 days and 1 year \\n (n = ', data$a, ')')
      [5]: paste0('Status known at 1 year \\n but not 30 days \\n (n = ', data$a, ')')
      [6]: paste0('Withdrawal (n = ', data$a, ')')
      [7]: paste0('Loss to follow-up (n = ', data$a, ')')
      [8]: paste0('Missed visit (n = ', data$a, ')')
      [9]: paste0('Visit not yet due (n = ', data$a, ')')
      [10]: paste0('Missed 30D visit (n = ', data$b, ')')
      [11]: paste0('Lost to follow-up (n = ', data$b, ')')
      ")

enter image description here

I'm really looking for something like this:

enter image description here

Any help would be very much appreciated!

Edit: by removing the headclip and tailclip attributes, I get something like this, which is better, but each arrow has a different "vertex." I'm hoping so that they have the same vertex.

enter image description here

user122514
  • 397
  • 5
  • 13

1 Answers1

0

remove the headclip and tailclip attributes (or change them to true)

sroush
  • 5,375
  • 2
  • 5
  • 11
  • Hi, I've done that, but I get separate "vertices" for each edge. I'd really like for each arrow to have the same vertex, if that makes sense. Please let me know if I can clarify. – user122514 Apr 10 '20 at 17:11
  • I added what I get when I remove those two attributes. – user122514 Apr 10 '20 at 17:17
  • Add ports to your edges: tab1:e -> tab3; tab3:e -> {tab6 tab7 tab8 tab9}; – sroush Apr 10 '20 at 18:28
  • This is really close to my desired output, but the arrows are not the same length and do not point to the center of the next node :( – user122514 Apr 10 '20 at 18:44