emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Emacs Org mode mailing list <emacs-orgmode@gnu.org>
Subject: [PATCH] Addition to Library of Babel
Date: Thu, 11 Nov 2010 10:50:18 -1000	[thread overview]
Message-ID: <92DBEE47-51F6-40CE-8CC4-56AB069E963F@tsdye.com> (raw)


[-- 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

             reply	other threads:[~2010-11-11 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 20:50 Thomas S. Dye [this message]
2010-11-12 23:38 ` [PATCH] Addition to Library of Babel Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92DBEE47-51F6-40CE-8CC4-56AB069E963F@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).