diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-11-12 16:37:17 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-11-12 16:37:17 -0700 |
commit | a9c5797fa1b7f221c22bc9ba5e9af3223dabdd63 (patch) | |
tree | b16d012b882365b7aab72a2e1b97883b3b43c893 | |
parent | 2ae5721731aab7f95e5516a63b2e832ae7b044b0 (diff) | |
download | org-mode-a9c5797fa1b7f221c22bc9ba5e9af3223dabdd63.tar.gz |
library of babel: aesthetic changes to elispgantt
-rw-r--r-- | contrib/babel/library-of-babel.org | 141 |
1 files changed, 64 insertions, 77 deletions
diff --git a/contrib/babel/library-of-babel.org b/contrib/babel/library-of-babel.org index 0f2173e..abc15a9 100644 --- a/contrib/babel/library-of-babel.org +++ b/contrib/babel/library-of-babel.org @@ -297,87 +297,74 @@ Fraga. It was modified slightly by Tom Dye. #+source: elispgantt #+begin_src emacs-lisp :var table=gantttest -(defun esf/generate-gantt-chart (table) (let ((dates "") - (entries (nthcdr 2 table)) - (milestones "") - (nmilestones 0) - (ntasks 0) - (projecttime 0) - (tasks "") - (xlength 1) - ) + (entries (nthcdr 2 table)) + (milestones "") + (nmilestones 0) + (ntasks 0) + (projecttime 0) + (tasks "") + (xlength 1)) (message "Initial: %s\n" table) (message "Entries: %s\n" entries) (while entries (let ((entry (first entries))) - (if (listp entry) - (let ((id (first entry)) - (type (nth 1 entry)) - (label (nth 2 entry)) - (task (nth 3 entry)) - (dependencies (nth 4 entry)) - (start (nth 5 entry)) - (duration (nth 6 entry)) - (end (nth 7 entry)) - (alignment (nth 8 entry)) - ) - (if (> start projecttime) (setq projecttime start)) - (if (string= type "task") - (let ((end (+ start duration)) - (textposition (+ start (/ duration 2))) - (flush "") - ) - (if (string= alignment "left") - (progn - (setq textposition start) - (setq flush "[left]")) - (if (string= alignment "right") - (progn - (setq textposition end) - (setq flush "[right]")) - ) - ) - (setq tasks (format "%s \\gantttask{%s}{%s}{%d}{%d}{%d}{%s}\n" tasks label task start end textposition flush)) - (setq ntasks (+ 1 ntasks)) - (if (> end projecttime) - (setq projecttime end)) - ) - (if (string= type "milestone") - (progn - (setq milestones (format "%s \\ganttmilestone{$\\begin{array}{c}\\mbox{%s}\\\\ \\mbox{%s}\\end{array}$}{%d}\n" milestones label task start)) - (setq nmilestones (+ 1 nmilestones))) - (if (string= type "date") - (setq dates (format "%s \\ganttdateline{%s}{%d}\n" dates label start)) - (message "Ignoring entry with type %s\n" type) - ) - ) - ) - ) - (message "Ignoring non-list entry %s\n" entry) - ) ; end if list entry - (setq entries (cdr entries)) - ) - ) ; end while entries left + (if (listp entry) + (let ((id (first entry)) + (type (nth 1 entry)) + (label (nth 2 entry)) + (task (nth 3 entry)) + (dependencies (nth 4 entry)) + (start (nth 5 entry)) + (duration (nth 6 entry)) + (end (nth 7 entry)) + (alignment (nth 8 entry))) + (if (> start projecttime) (setq projecttime start)) + (if (string= type "task") + (let ((end (+ start duration)) + (textposition (+ start (/ duration 2))) + (flush "")) + (if (string= alignment "left") + (progn + (setq textposition start) + (setq flush "[left]")) + (if (string= alignment "right") + (progn + (setq textposition end) + (setq flush "[right]")))) + (setq tasks + (format "%s \\gantttask{%s}{%s}{%d}{%d}{%d}{%s}\n" + tasks label task start end textposition flush)) + (setq ntasks (+ 1 ntasks)) + (if (> end projecttime) + (setq projecttime end))) + (if (string= type "milestone") + (progn + (setq milestones + (format + "%s \\ganttmilestone{$\\begin{array}{c}\\mbox{%s}\\\\ \\mbox{%s}\\end{array}$}{%d}\n" + milestones label task start)) + (setq nmilestones (+ 1 nmilestones))) + (if (string= type "date") + (setq dates (format "%s \\ganttdateline{%s}{%d}\n" + dates label start)) + (message "Ignoring entry with type %s\n" type))))) + (message "Ignoring non-list entry %s\n" entry)) ; end if list entry + (setq entries (cdr entries)))) ; end while entries left (format "\\pgfdeclarelayer{background} -\\pgfdeclarelayer{foreground} -\\pgfsetlayers{background,foreground} -\\renewcommand{\\ganttprojecttime}{%d} -\\renewcommand{\\ganttntasks}{%d} -\\noindent -\\begin{tikzpicture}[y=-0.75cm,x=0.75\\textwidth] - \\begin{pgfonlayer}{background} - \\draw[very thin, red!10!white] (0,1+\\ganttntasks) grid [ystep=0.75cm,xstep=1/\\ganttprojecttime] (1,0); - \\draw[\\ganttdatelinecolour] (0,0) -- (1,0); - \\draw[\\ganttdatelinecolour] (0,1+\\ganttntasks) -- (1,1+\\ganttntasks); - \\end{pgfonlayer} -%s -%s -%s -\\end{tikzpicture}" projecttime ntasks tasks milestones dates) - ) - ) -(esf/generate-gantt-chart table) + \\pgfdeclarelayer{foreground} + \\pgfsetlayers{background,foreground} + \\renewcommand{\\ganttprojecttime}{%d} + \\renewcommand{\\ganttntasks}{%d} + \\noindent + \\begin{tikzpicture}[y=-0.75cm,x=0.75\\textwidth] + \\begin{pgfonlayer}{background} + \\draw[very thin, red!10!white] (0,1+\\ganttntasks) grid [ystep=0.75cm,xstep=1/\\ganttprojecttime] (1,0); + \\draw[\\ganttdatelinecolour] (0,0) -- (1,0); + \\draw[\\ganttdatelinecolour] (0,1+\\ganttntasks) -- (1,1+\\ganttntasks); + \\end{pgfonlayer} + %s + %s + %s + \\end{tikzpicture}" projecttime ntasks tasks milestones dates)) #+end_src - - |