Difference between revisions of "Gantt-tikz"

From ConTeXt wiki
(See also: - add pgfgantt)
(update to match new verison (2.1))
Line 3: Line 3:
 
Gantt-tikz is a module for drawing Gantt diagrams via pgf/tikz.
 
Gantt-tikz is a module for drawing Gantt diagrams via pgf/tikz.
  
It is an essential port of the [http://www.martin-kumm.de/tex/gantt.sty gantt.sty] (version 1.1) LaTeX macro package from Martin Kumm.
+
It is an essential port of the [http://www.martin-kumm.de/tex/gantt.sty gantt.sty] (version 1.3) LaTeX macro package from Martin Kumm.
  
[http://tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=300 Gantt-tikz] is included as a (third party) [http://tlcontrib.metatex.org module] for ConTeXt.
+
[http://tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=564 Gantt-tikz] is included as a (third party) [http://tlcontrib.metatex.org module] for ConTeXt.
  
 
== Description ==
 
== Description ==
Line 34: Line 34:
 
=== Ganttbar ===
 
=== Ganttbar ===
 
draws a single, unconnected bar for representing a task
 
draws a single, unconnected bar for representing a task
<texcode>\ganttbar[pattern=<pattern>,color=<color>]{label}{start}{length}</texcode>
+
<texcode>\ganttbar[pattern=value,color=value]{label}{start}{length}</texcode>
 
where the optional comma separated arguments are:
 
where the optional comma separated arguments are:
  
Line 48: Line 48:
 
=== Ganttbarcon ===
 
=== Ganttbarcon ===
 
draws a single bar '''and''' connects the bar with the previous bar for consecutive tasks
 
draws a single bar '''and''' connects the bar with the previous bar for consecutive tasks
<texcode>\ganttbarcon[pattern=<pattern>,color=<color>]{label}{start}{length}</texcode>
+
<texcode>\ganttbarcon[pattern=value,color=value]{label}{start}{length}</texcode>
 
where the optional pattern argument are the same as for \ganttbar
 
where the optional pattern argument are the same as for \ganttbar
  
Line 54: Line 54:
 
draws a bar to group tasks
 
draws a bar to group tasks
 
<texcode>\ganttgroup{label}{start}{length}</texcode>
 
<texcode>\ganttgroup{label}{start}{length}</texcode>
 +
 +
=== Ganttmilestone ===
 +
draws a milestone using a diamond
 +
<texcode>\ganttmilestone[color=value]{label}{start}</texcode>
 +
where the optional color argument argument is:
 +
 +
* ''<color>'' - a tikz color of the pattern (e.g. black (default), red, green blue gray, dark gray)
 +
 +
=== Ganttmilestonecon ===
 +
draws a milestone using a diamond '''and''' connects the milestone with the previous bar or milestone
 +
<texcode>\ganttmilestonecon[color=value]{label}{start}</texcode>
 +
where the optional color argument argument is:
 +
 +
* ''<color>'' - a tikz color of the pattern (e.g. black (default), red, green blue gray, dark gray)
  
 
== Examples ==
 
== Examples ==
Line 141: Line 155:
  
 
[[Image:Gantt-tikz_example3.png|608px]]
 
[[Image:Gantt-tikz_example3.png|608px]]
 +
 +
 +
=== Example using Milestones: ===
 +
<texcode>
 +
\usemodule[gantt-tikz]
 +
\setuppagenumbering[location=]
 +
 +
\starttext
 +
  \startgantt{10}{12}
 +
    \startganttitle
 +
      \numtitle{1}{1}{12}{1}
 +
    \stopganttitle
 +
    \ganttbar{a task}{0}{2}
 +
    \ganttbarcon{a consecutive task}{2}{4}
 +
    \ganttbarcon{another consecutive task}{8}{2}
 +
    \ganttmilestone[color=cyan]{Milestone with color!}{4}
 +
    \ganttbar{another task}{2}{2}
 +
    \ganttbar[color=cyan]{another coloured task}{4}{4}
 +
    \ganttbar{another task}{4}{2}
 +
    \ganttcon{4}{5}{4}{7}
 +
    \ganttmilestonecon{A connected Milestone}{7}
 +
    \ganttbarcon{another consecutive task}{8}{2}
 +
  \stopgantt
 +
\stoptext
 +
</texcode>
 +
 +
[[Image:Gantt-tikz_example5.png|650px]]
  
  

Revision as of 22:49, 27 August 2011

< Modules | Graphics | Gantt charts | TikZ >

Gantt-tikz is a module for drawing Gantt diagrams via pgf/tikz.

It is an essential port of the gantt.sty (version 1.3) LaTeX macro package from Martin Kumm.

Gantt-tikz is included as a (third party) module for ConTeXt.

Description

In the following you will find a short description of environments and commands:

Gantt

The gantt environment draws the canvas of a gantt figure (realized as tikzpicture)

\startgantt[...]{no of Tasks to plot}{no of time slots}

The optional argument [...] can be filled in a key=value syntax, using one or more of the following keys:

  • xunitlength - length of one time slot (default: 1cm)
  • fontsize - fontsize of labels (default: \tf)
  • titlefontsize - fontsize of title section (default: \tfx)
  • drawledgerline - Switch to enable/disable the drawing of horizontal ledger lines (default value: false)

Ganttitle

is the environment for drawing the title section

Titleelement

draws one element of the title

\titleelement{label}{length}

Numtitle

draws a numbered sequence of title elements

\numtitle{start number}{increment}{end number}{length of each title element}

Ganttbar

draws a single, unconnected bar for representing a task

\ganttbar[pattern=value,color=value]{label}{start}{length}

where the optional comma separated arguments are:

  • <pattern> - is a tikz pattern (e.g. north east lines (default), north west lines, crosshatch, crosshatch dots, grid, …)
  • <color> - a tikz color of the pattern (e.g. black (default), red, green blue gray, dark gray)

for more information see the tikz documentation

Ganttcon

draws an arrow between to bars with specified coordinates

\ganttcon{startx}{starty}{endx}{endy}

Ganttbarcon

draws a single bar and connects the bar with the previous bar for consecutive tasks

\ganttbarcon[pattern=value,color=value]{label}{start}{length}

where the optional pattern argument are the same as for \ganttbar

Ganttgroup

draws a bar to group tasks

\ganttgroup{label}{start}{length}

Ganttmilestone

draws a milestone using a diamond

\ganttmilestone[color=value]{label}{start}

where the optional color argument argument is:

  • <color> - a tikz color of the pattern (e.g. black (default), red, green blue gray, dark gray)

Ganttmilestonecon

draws a milestone using a diamond and connects the milestone with the previous bar or milestone

\ganttmilestonecon[color=value]{label}{start}

where the optional color argument argument is:

  • <color> - a tikz color of the pattern (e.g. black (default), red, green blue gray, dark gray)

Examples

From the original LaTeX package.

Here is a minimal example:

\usemodule[gantt-tikz]
\setuppagenumbering[location=]

\starttext
  \startgantt{7}{12}
    \startganttitle
      \numtitle{1}{1}{12}{1}
    \stopganttitle
    \ganttbar{a task}{0}{2}
    \ganttbarcon{a consecutive task}{2}{4}
    \ganttbarcon{another consecutive task}{8}{2}
    \ganttbar{another task}{2}{2}
    \ganttbar{another task}{4}{2}
    \ganttbar{another task}{4}{2}
    \ganttcon{4}{4}{4}{6}
  \stopgantt
\stoptext

Download: example1.tex

Gantt-tikz example1.png


Here is a similar example using the names of the month's:

\usemodule[gantt-tikz]
\setuppagenumbering[location=]

\starttext
  \startgantt{3}{12}
    \startganttitle
      \titleelement{Jan}{1}
      \titleelement{Feb}{1}
      \titleelement{Mar}{1}
      \titleelement{Apr}{1}
      \titleelement{May}{1}
      \titleelement{Jun}{1}
      \titleelement{Jul}{1}
      \titleelement{Aug}{1}
      \titleelement{Sep}{1}
      \titleelement{Oct}{1}
      \titleelement{Nov}{1}
      \titleelement{Dec}{1}
    \stopganttitle
    \ganttbar{Task 1}{0}{2}
    \ganttbarcon{a consecutive task}{2}{4}
  \stopgantt
\stoptext

Download: example2.tex

Gantt-tikz example2.png


You can use more titles with different length' to divide the time axis:

\usemodule[gantt-tikz]
\setuppagenumbering[location=]

\starttext
  \startgantt{4}{12}
    \startganttitle
      \numtitle{2010}{1}{2012}{4}
    \stopganttitle
    \startganttitle
      \numtitle{1}{1}{4}{1}
      \numtitle{1}{1}{4}{1}
      \numtitle{1}{1}{4}{1}
    \stopganttitle
    \ganttbar{Task 1}{0}{2}
    \ganttbarcon{a consecutive task}{2}{4}
  \stopgantt
\stoptext

Download: example3.tex

Gantt-tikz example3.png


Example using Milestones:

\usemodule[gantt-tikz]
\setuppagenumbering[location=]

\starttext
  \startgantt{10}{12}
    \startganttitle
      \numtitle{1}{1}{12}{1}
    \stopganttitle
    \ganttbar{a task}{0}{2}
    \ganttbarcon{a consecutive task}{2}{4}
    \ganttbarcon{another consecutive task}{8}{2}
    \ganttmilestone[color=cyan]{Milestone with color!}{4}
    \ganttbar{another task}{2}{2}
    \ganttbar[color=cyan]{another coloured task}{4}{4}
    \ganttbar{another task}{4}{2}
    \ganttcon{4}{5}{4}{7}
    \ganttmilestonecon{A connected Milestone}{7}
    \ganttbarcon{another consecutive task}{8}{2}
  \stopgantt
\stoptext
Error creating thumbnail: File missing


Here is a more complex example using groups, different patterns and the optional arguments:

\usemodule[gantt-tikz]
\setuppapersize[landscape][landscape]
\setuplayout[scale=0.8]
\setuppagenumbering[location=]

\starttext
  \startgantt[xunitlength=0.5cm,fontsize=\tfx,titlefontsize=\tfx,drawledgerline=true]{10}{48}
    \startganttitle
      \titleelement{2009}{7}
      \numtitle{2010}{1}{2012}{12} 
      \titleelement{2013}{5}
    \stopganttitle
    \startganttitle
      \numtitle{6}{1}{12}{1} 
      \numtitle{1}{1}{12}{1} 
      \numtitle{1}{1}{12}{1} 
      \numtitle{1}{1}{12}{1} 
      \numtitle{1}{1}{5}{1} 
    \stopganttitle
    \ganttbar{task 1}{2}{17} 
    \ganttgroup{a group of tasks}{6}{18}
    \ganttbar{task 2}{5}{10} 
    \ganttbar[pattern=crosshatch,color=blue]{task 3}{15}{3}  
    \ganttbar{task 4}{20}{3}  
    \ganttcon{15}{4}{20}{6}
    \ganttbar{task 5}{15}{5} 
    \ganttbarcon[color=red]{task 6}{20}{5}
    \ganttbarcon{task 7}{30}{5}
  \stopgantt
\stoptext

Download: example4.tex

Gantt-tikz example4.png

See also


The package maintainer is Adam Reviczky and it is released under the GNU General Public License (version 2) license.