From mboxrd@z Thu Jan 1 00:00:00 1970 From: julia.jacobson@arcor.de Subject: Code for feature for showing progress in lisp code for creation of Gantt charts Date: Thu, 24 May 2012 17:00:54 +0200 (CEST) Message-ID: <646467803.782330.1337871654994.JavaMail.ngmail@webmail18.arcor-online.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_782328_1099003194.1337871654993" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZXD-0003KL-HG for emacs-orgmode@gnu.org; Thu, 24 May 2012 11:01:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXZX8-0003aN-3l for emacs-orgmode@gnu.org; Thu, 24 May 2012 11:01:03 -0400 Received: from mail-in-10.arcor-online.net ([151.189.21.50]:45146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZX7-0003Vx-Lh for emacs-orgmode@gnu.org; Thu, 24 May 2012 11:00:58 -0400 Received: from mail-in-09-z2.arcor-online.net (mail-in-09-z2.arcor-online.net [151.189.8.21]) by mx.arcor.de (Postfix) with ESMTP id 485522D6EC3 for ; Thu, 24 May 2012 17:00:55 +0200 (CEST) Received: from mail-in-06.arcor-online.net (mail-in-06.arcor-online.net [151.189.21.46]) by mail-in-09-z2.arcor-online.net (Postfix) with ESMTP id 30F2D20405 for ; Thu, 24 May 2012 17:00:55 +0200 (CEST) Received: from webmail18.arcor-online.net (webmail18.arcor-online.net [151.189.8.76]) by mail-in-06.arcor-online.net (Postfix) with ESMTP id 033F310BDE3 for ; Thu, 24 May 2012 17:00:55 +0200 (CEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org ------=_Part_782328_1099003194.1337871654993 Content-Type: multipart/alternative; boundary="----=_Part_782327_1390620785.1337871654993" ------=_Part_782327_1390620785.1337871654993 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello everybody out there using Org-mode, Some time ago, Eric Fraga had posted a script for generating Gantt charts directly out of Org-mode which is very helpful. Some project management software allows to follow the progress of tasks by staining a proportional part of the rectangle for a certain task in relation to its completion percentage in green and the rest in red. This allows easier evaluation of a project's current status. I added this feature to Eric Fraga's code and would like to post it here for discussion. It would be great if it could be somehow added to Org-mode. Thank you for making Org-mode such a good piece of software, Julia ------=_Part_782327_1390620785.1337871654993-- ------=_Part_782328_1099003194.1337871654993 Content-Type: application/octet-stream Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=pro_prog.org #+TITLE: Gantt charts with progress status #+AUTHOR: Julia Jacobson #+EMAIL: julia.jacobson@arcor.de #+DATE: \today #+LASTCHANGE: 2012.05.23 21:08:08 #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: #+latex_header: \usepackage{pgf, pgfarrows, pgfnodes} #+latex_header: \usepackage{tikz} #+latex_header: \newcommand\ganttline[4]{% line, tag, start end #+latex_header: \node at (0,#1) [anchor=base east] {#2}; #+latex_header: \fill[black!20!white] (#3/20,#1-.2) rectangle (#4/20,#1+.2);} * Table of tasks and milestones :noexport: One additional column where for the progress of a task in percent is added to the original table. #+tblname: gantttesttable | | type | label | activity | depends | start | duration | end | align | progress | |----+-----------+---------+-------------------------------+---------+-------+----------+-----+-------+----------| | 1 | date | Start | | | 0 | | 0 | | | | 2 | task | 1.1 | Lit survey | | 0 | 2 | 2 | right | 75 | | 3 | task | 1.2 | experiments | | 2 | 6 | 8 | | 40 | | 4 | milestone | M1 | data collected | 3 | 8 | | 8 | | | | 5 | task | 1.3 | Report | 3 | 8 | 6 | 14 | | 30 | | 6 | date | 6 weeks | | | 14 | | 14 | | | | 7 | milestone | M2 | Release | 5 | 14 | | 14 | | | |----+-----------+---------+-------------------------------+---------+-------+----------+-----+-------+----------| | 8 | task | 2.1 | Discuss | 5 | 14 | 1 | 15 | left | 90 | | 9 | task | 2.2 | Correct mistakes | 8 | 15 | 1 | 16 | left | 10 | | 10 | task | 2.3 | Add feedback | 5 | 14 | 2 | 16 | left | 50 | | 11 | date | End | | | 16 | | 16 | | | |----+-----------+---------+-------------------------------+---------+-------+----------+-----+-------+----------| #+TBLFM: address@hidden::$8=$6+$7::@address@hidden::@address@hidden::@address@hidden::@address@hidden::@address@hidden * lisp code for creating latex that uses above :noexport: #+source: elispgantt #+begin_src emacs-lisp :var table=gantttesttable :results raw :export results (defun esf/generate-gantt-chart (table) (let ((dates "") (entries (nthcdr 2 table)) (milestones "") (nmilestones 0) (ntasks 0) (projecttime 0) (tasks "") (xlength 1) (progress 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)) (progress (nth 9 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}{%d}\n" tasks label task start end textposition flush progress)) (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 "#+begin_latex \\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} ,#+end_latex\n" projecttime ntasks tasks milestones dates) ) ) (esf/generate-gantt-chart table) #+end_src * Time line #+latex_header: \usepackage{tikz} #+begin_latex \newcounter{gantttask} \newcommand{\gantttaskcol}{blue!50!white} \newcommand{\gantttaskcolour}{yellow!50!white} \newcommand{\ganttmilestonecolour}{red!50!white} \newcommand{\ganttdatelinecolour}{black!50!white} \newcommand{\ganttprojecttime}{1} \newcommand{\ganttntasks}{1} \newcommand\gantttask[7]{% label, activity, start, end, labelpos, align \begin{pgfonlayer}{foreground} % \node at (0,\thegantttask) [anchor=base east] {#2}; \stepcounter{gantttask} \node [left] at (0,\thegantttask) {#1}; \draw[fill=\gantttaskcol] (#3/\ganttprojecttime,\thegantttask-0.4) rectangle (#3/\ganttprojecttime + #7/100 * #4/\ganttprojecttime - #7/100 * #3/\ganttprojecttime,\thegantttask +0.4); \draw[fill=\gantttaskcolour] (#3/\ganttprojecttime + #7/100 * #4/\ganttprojecttime - #7/100 * #3/\ganttprojecttime,\thegantttask-0.4) rectangle (#4/\ganttprojecttime,\thegantttask +0.4); \node at (#5/\ganttprojecttime,\thegantttask) #6 {#2}; \end{pgfonlayer} } \newcommand\ganttpoint[3]{% line, tag, date \node at (0,#1) [anchor=base east] {#2}; \fill[black] (#3/\ganttprojecttime,#1) circle (0.1/\ganttprojecttime); } \newcommand\ganttdateline[2]{% tag, date \begin{pgfonlayer}{background} \draw[\ganttdatelinecolour] (#2/\ganttprojecttime,0) -- (#2/\ganttprojecttime,\thegantttask+1); \node at (#2/\ganttprojecttime,0) [above] {#1}; \end{pgfonlayer} } \newcommand\ganttmilestone[2]{% tag, date \begin{pgfonlayer}{foreground} \node at (#2/\ganttprojecttime,\thegantttask+1.0) [below] {#1}; \draw[black,fill=\ganttmilestonecolour] (#2/\ganttprojecttime-0.1\ganttntasks/\ganttprojecttime,\thegantttask+0.9) rectangle (#2/\ganttprojecttime+0.1\ganttntasks/\ganttprojecttime,\thegantttask+1.1); \end{pgfonlayer} } #+END_LaTeX #+ \\draw[help lines, very thin, red!20!white] (0,%s) grid (\\ganttprojecttime,0); # <> ------=_Part_782328_1099003194.1337871654993--