* [PATCH] Addition to Library of Babel
@ 2010-11-11 20:50 Thomas S. Dye
2010-11-12 23:38 ` Eric Schulte
0 siblings, 1 reply; 2+ messages in thread
From: Thomas S. Dye @ 2010-11-11 20:50 UTC (permalink / raw)
To: Emacs Org mode mailing list
[-- Attachment #1.1: Type: text/plain, Size: 193 bytes --]
Add Eric Fraga's GANTT chart code to the Library of Babel.
Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com
[-- Attachment #1.2.1: Type: text/html, Size: 207 bytes --]
[-- Attachment #1.2.2: gantt.patch --]
[-- Type: application/octet-stream, Size: 3161 bytes --]
Changes from master to gantt
Modified contrib/babel/library-of-babel.org
diff --git a/contrib/babel/library-of-babel.org b/contrib/babel/library-of-babel.org
index 07c40aa..0f2173e 100644
--- a/contrib/babel/library-of-babel.org
+++ b/contrib/babel/library-of-babel.org
@@ -286,11 +286,98 @@ are optional.
#+begin_src python
a
#+end_src
-
#+srcname: python-add(a=1, b=2)
#+begin_src python
a + b
#+end_src
-
+* GANTT Charts
+
+The =elispgantt= source block was sent to the mailing list by Eric
+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)
+ )
+ (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
+ (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)
+#+end_src
[-- Attachment #1.2.3: Type: text/html, Size: 2490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-13 0:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-11 20:50 [PATCH] Addition to Library of Babel Thomas S. Dye
2010-11-12 23:38 ` Eric Schulte
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).