Helps if I attached the file...  <blush>

-- 
: Eric S Fraga via Emacs 26.0.50, Org release_9.0.9-551-g92e8c8
A small example in which the ~call~ statement below fails with error message:
Successfully reloaded Org
#+begin_example
Org mode version 9.0.9 (release_9.0.9-551-g92e8c8 @ /home/ucecesf/git/org-mode/lisp/)
Evaluate this emacs-lisp code block on your system? (y or n) y
executing Emacs-Lisp code block...

(options (quote "rankdir=LR;"))

(nodes (quote (("start" "start" "ellipse" "" "") ("one" "first" "" "" "the first task") ("two" "second" "" "" "second task") ("end" "End" "ellipse" "" "project complete"))))

(graph (quote (("start" "one" "") ("start" "two" "") ("one" "end" "test") ("two" "end" ""))))

Evaluate this dot code block (plot-graph) on your system? (y or n) y
executing Dot code block (plot-graph)...
Wrote /tmp/babel-7617mN6/ob-input-7617ncr
"[[file:dependency-graph.pdf]]"
org-indent-add-properties: Wrong type argument: arrayp, nil
#+end_example

* Overview                                               :ignoreheading:
#+call: graph-from-tables(options="rankdir=LR;",nodes=subtasks-table[2:-1],graph=dependency-table[2:-1]) :exports results :results file :post plot-graph[:results file :exports results :file dependency-graph.pdf](graph=*this*)



#+name: subtasks-table
| node     | label    | shape   | colour | description                      |
|----------+----------+---------+--------+----------------------------------|
| start    | start    | ellipse |        |                                  |
| one      | first    |         |        | the first task                   |
| two      | second   |         |        | second task                      |
| end      | End      | ellipse |        | project complete                 |

#+name: dependency-table
| from     | to       | label |
|----------+----------+-------|
| start    | one      |       |
| start    | two      |       |
| one      | end      | test  |
| two      | end      |       |

* graph from table
#+name: graph-from-tables
#+header: :var options="" :var nodes='() graph='()
#+BEGIN_SRC emacs-lisp :wrap src dot
  (concat
   "digraph {\n"
   options "\n"   ;; "//rankdir=LR;\n" ;; remove comment characters '//' for horizontal layout; add for vertical layout
   (mapconcat
    (lambda (x)
      (format "%s [label=\"%s\" shape=%s style=\"filled\" fillcolor=\"%s\"]"
              (car x)
              (nth 1 x)
              (if (string= "" (nth 2 x)) "box" (nth 2 x))
              (if (string= "" (nth 3 x)) "none" (nth 3 x))
              )) nodes "\n")
   "\n"
   (mapconcat
    (lambda (x)
      (format "%s -> %s [taillabel=\"%s\"]"
              (car x) (nth 1 x) (nth 2 x))) graph "\n")
   "}\n")
#+END_SRC

#+name: plot-graph
#+begin_src dot :var graph="digraph { anode;}" :file graph.pdf
$graph
#+end_src

Attachment: signature.asc
Description: PGP signature

Reply via email to