diff options
author | Karl Berry <karl@freefriends.org> | 2013-06-29 15:38:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-06-29 15:38:02 +0000 |
commit | fd0e0fada68b585f51bcd1422e59ed7c2271660d (patch) | |
tree | 07016996c74768947c89b4353ba8c3158bd5fb7f | |
parent | 0e45eaa243e0008ecc5a2e48d746d793a7cda314 (diff) |
pgfgantt (4jun13)
git-svn-id: svn://tug.org/texlive/trunk@31037 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/pgfgantt/README | 14 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pgfgantt/pgfgantt.pdf | bin | 785864 -> 910543 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/pgfgantt/pgfgantt.dtx | 5116 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/pgfgantt/pgfgantt.ins | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty | 1772 |
5 files changed, 4448 insertions, 2460 deletions
diff --git a/Master/texmf-dist/doc/latex/pgfgantt/README b/Master/texmf-dist/doc/latex/pgfgantt/README index c93e2cb0814..39c93dd3fff 100644 --- a/Master/texmf-dist/doc/latex/pgfgantt/README +++ b/Master/texmf-dist/doc/latex/pgfgantt/README @@ -1,14 +1,14 @@ -The pgfgantt package v3.0 +The pgfgantt package v4.0 ------------------------------------------------------------------------------ This package is released under the LaTeX Project Public License v1.3c or later (see http://www.latex-project.org/lppl.txt). -The pgfgantt package provides the ganttchart environment, which draws -a Gantt chart within a TikZ picture. The user may add various elements -to the chart, namely titles, bars, milestones, groups and different links -between these elements. Furthermore, the appearance of the chart elements -is highly customizable, owing to a number of keys. +The pgfgantt package provides the ganttchart environment, which +draws a Gantt chart within a TikZ picture. The user may add various +elements to the chart, for example, titles, bars, groups, milestones and different +links between these elements. The appearance of the chart elements +is highly customizable, and even new chart elements may be defined. The package makes use of pgf/TikZ (http://tug.ctan.org/pkg/pgf). @@ -16,4 +16,4 @@ Installation: Run pgfgantt.ins through LaTeX and follow the instructions. -- Wolfgang Skala -January 25th, 2012
\ No newline at end of file +1st June 2013
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/pgfgantt/pgfgantt.pdf b/Master/texmf-dist/doc/latex/pgfgantt/pgfgantt.pdf Binary files differindex 3e27f4ed86c..7e75e25d068 100644 --- a/Master/texmf-dist/doc/latex/pgfgantt/pgfgantt.pdf +++ b/Master/texmf-dist/doc/latex/pgfgantt/pgfgantt.pdf diff --git a/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.dtx b/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.dtx index ef0c22fb527..2023be04d64 100644 --- a/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.dtx +++ b/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.dtx @@ -13,19 +13,20 @@ % \fi % % \iffalse -%<pgfgantt>\ProvidesPackage{pgfgantt}[2012/01/25 v3.0 Draw Gantt diagrams with TikZ] +%<pgfgantt>\ProvidesPackage{pgfgantt}[2013/06/01 v4.0 Draw Gantt diagrams with TikZ] %<pgfgantt>\NeedsTeXFormat{LaTeX2e}[1999/12/01] % %<*driver> \documentclass[captions=tableheading,cleardoublepage=empty]{scrartcl} -\usepackage[english]{babel} - \frenchspacing +\usepackage[ngerman,english]{babel} + \addto\extrasenglish{\extrasngerman} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[hdivide={2cm,*,5cm}]{geometry} \usepackage{url} \usepackage[dvipsnames]{xcolor} \usepackage{listings} +\usepackage{array,booktabs} \lstset{ language=[AlLaTeX]TeX, basicstyle=\ttfamily, @@ -33,6 +34,7 @@ keywordstyle=\color{Maroon}, commentstyle=\itshape\color{black!50}, columns=fullflexible, + keepspaces=true, backgroundcolor=\color{black!5}, tabsize=2, gobble=2, @@ -41,27 +43,27 @@ xleftmargin=.25em, xrightmargin=.25em, rulecolor=\color{white}, + alsoletter={*}, morekeywords={ganttchart,tikzpicture,tabular}, moretexcs={ - gantttitle,gantttitlelist,ganttbar,ganttlink, + ganttalignnewline,gantttitle,gantttitlelist,gantttitlecalendar, + gantttitlecalendar*,ganttbar,ganttlink,ganttlinkedgroup, ganttlinkedbar,ganttmilestone,ganttlinkedmilestone,ganttgroup, ganttset,ganttnewline,textcolor,foreach,draw, pgfcalendarweekdayshortname,usetikzlibrary, color,rotatebox,definecolor,sfdefault,mddefault,bfdefault,fcolorbox, newganttlinktype,newganttlinktypealias,setganttlinklabel, ganttsetstartanchor,ganttsetendanchor,xLeft,xRight,yUpper,yLower, - ganttlinklabel,ganttvalueof + ganttlinklabel,ganttvalueof,pgfcalendarweekdayname,pgfcalendarweekdayletter, + pgfcalendarmonthshortname,currentweek,startyear,startmonth,startday,x,y, + pgfcalendarweekday,pgfcalendarmonth,newgantttimeslotformat,pgfcalendardatetojulian, + newganttchartelement,newganttchartelement*,gantt,ganttlinked,ganttfoobar,ganttlinkedfoobar }, escapeinside=`', escapebegin=\begin{rmfamily}, escapeend=\end{rmfamily}, - emph={ - anchor,bar,bulge,canvas,chart,font,group,height,hgrid, - in,include,incomplete,inline,label,left,link,list,mid,milestone, - modifier,name,options,peak,peaks,progress,right,rule,shape,shift,slot,style, - text,time,title,today,tolerance,top,type,unit,vgrid,width,x,xshift,y,yshift - }, - emphstyle=\color{OliveGreen}, + emph={list}, + emphstyle=\color{black}, } \lstnewenvironment{texcode}[1][]{\lstset{basicstyle=\small\ttfamily,#1}}{} \usepackage{doc} @@ -71,9 +73,10 @@ \def\MacroFont{\small\ttfamily} \def\theCodelineNo{\sffamily\scriptsize\color{black!50}\arabic{CodelineNo}} \setcounter{IndexColumns}{2} - \def\pack#1{\texttt{#1}} + \def\pack#1{\textsf{#1}} \def\main#1{\textit{#1}} \def\usage#1{\textbf{#1}} + \def\opt#1{\textcolor{OliveGreen}{\texttt{#1}}} \providecommand\marg[1]{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}} \providecommand\oarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} \def\PrintDescribeMacro#1{\strut\MacroFont\color{RoyalBlue}\string#1} @@ -213,10 +216,20 @@ pdfhighlight=/N% ]{hyperref}% +\makeatletter +\newsavebox\keybox \newcommand\keyline[4][=]{% - \noindent\DescribeOpt{#2}\texttt{\textcolor{OliveGreen!50}{/pgfgantt/}\textcolor{OliveGreen}{#2}\space#1}#3% - \hfill\texttt{#4}\par\noindent\ignorespaces% + \savebox\keybox{\texttt{\textcolor{OliveGreen!50}{/pgfgantt/}\textcolor{OliveGreen}{#2}\space#1}#3}% + \noindent\DescribeOpt{#2}\usebox\keybox% + \settowidth\@tempdimb{\texttt{#4}}% + \@tempdima=\textwidth\relax% + \advance\@tempdima by-\wd\keybox\relax% + \advance\@tempdima by-5mm\relax% + \ifdim\@tempdima<\@tempdimb\relax\\\fi% + \hspace*{\fill}\texttt{#4}% + \par\noindent\ignorespaces% } +\makeatother \newenvironment{key}[4][=]{% \bigskip% \keyline[#1]{#2}{#3}{#4}% @@ -224,9 +237,20 @@ \def\TikZ{Ti\textit{k}Z} \DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}} +\def\GlossaryParms{% + \def\pfill##1{} + \parindent 0pt + \parskip 0pt plus 1pt + \small\raggedright + \def\@idxitem{\par\hangindent 30pt}% + \def\subitem{\@idxitem\hspace*{15pt}}% + \def\subsubitem{\@idxitem\hspace*{25pt}}% + \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}% +} + \usepackage{pgfgantt} -\usepackage{pgfcalendar} -\usetikzlibrary{positioning,shadows,shadings,decorations.pathmorphing} + +\usetikzlibrary{shadows,shadings,decorations.pathmorphing,shapes.misc} \EnableCrossrefs \CodelineIndex @@ -246,7 +270,7 @@ %</driver> % \fi % -% \CheckSum{1390} +% \CheckSum{2003} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -267,34 +291,84 @@ % % \GetFileInfo{pgfgantt.sty} % -% \DoNotIndex{\@empty,\@ifstar,\@ifundefined,\@nameuse,\@tempa,\@tempb,\addtocounter,\advance,\anchor,\begin,\begingroup,\bfseries,\breakforeach,\clip,\csname,\def,\draw,\edef,\else,\end,\endcsname,\endgroup,\expandafter,\fi,\foreach,\global,\i,\ifcase,\ifnum,\ifx,\itshape,\let,\newcommand,\newcounter,\newenvironment,\newif,\node,\normalcolor,\normalsize,\PackageWarning,\path,\pgf@x,\pgf@y,\pgf@xa,\pgf@xb,\pgf@ya,\pgf@yb,\pgfdeclareshape,\pgfkeys,\pgfkeyssetvalue,\pgfkeysvalueof,\pgfmathparse,\pgfmathresult,\pgfmathsetcounter,\pgfmathsetmacro,\pgfpoint,\pgfpointanchor,\pgfqkeys,\relax,\RequirePackage,\savedanchor,\scriptsize,\setcounter,\small,\stepcounter,\strut,\t,\the,\usetikzlibrary,\value,\x,\xdef} +% \DoNotIndex{\@empty,\@ifstar,\@ifundefined,\@tempa,\@tempb,\@tempc,\@tempcnta,\@tempcntb,\advance,\begin,\begingroup,\bfseries,\breakforeach,\clip,\csname,\def,\divide,\draw,\edef,\else,\end,\endcsname,\endgroup,\expandafter,\fi,\foreach,\global,\i,\ifcase,\ifdate,\ifdim,\ifnum,\ifx,\itshape,\let,\multiply,\newcommand,\newcount,\newenvironment,\newif,\node,\normalcolor,\normalfont,\normalsize,\PackageError,\PackageWarning,\path,\pgf@process,\pgf@x,\pgf@y,\pgf@xa,\pgf@xb,\pgf@xc,\pgf@ya,\pgf@yb,\pgf@yc,\pgfcalendar,\pgfcalendarcurrentday,\pgfcalendarcurrentjulian,\pgfcalendarcurrentmonth,\pgfcalendarcurrentweekday,\pgfcalendarcurrentyear,\pgfcalendardatetojulian,\pgfcalendarendiso,\pgfcalendarjuliantodate,\pgfdeclareshape,\pgfkeys,\pgfkeyscurrentname,\pgfkeyssetvalue,\pgfkeysvalueof,\pgfmathparse,\pgfmathprintnumber,\pgfmathresult,\pgfmathsetlength,\pgfmathsetmacro,\pgfpathclose,\pgfpathlineto,\pgfpathmoveto,\pgfpoint,\pgfpointadd,\pgfpointanchor,\pgfpointscale,\pgfqkeys,\relax,\RequirePackage,\savedanchor,\scriptsize,\setcounter,\small,\stepcounter,\strut,\t,\the,\usetikzlibrary,\value,\x,\xdef} % % % \title{Drawing Gantt Charts in \LaTeX\\with \TikZ} % \subtitle{The \texttt{pgfgantt} Package} -% \author{Wolfgang Skala\thanks{Division of Structural Biology, Department of Molecular Biology, University of Salzburg, Austria; \texttt{Wolfgang.Skala@stud.sbg.ac.at}}} +% \author{Wolfgang Skala\thanks{Division of Structural Biology, Department of Molecular Biology, University of Salzburg, Austria; \texttt{Wolfgang.Skala@sbg.ac.at}}} % \date{\fileversion\\\filedate} % \maketitle -% \changes{v1.0}{2011/03/01}{Initial release} % % \begin{abstract} -% The \pack{pgfgantt} package provides the |ganttchart| environment, which draws a Gantt chart within a \TikZ\ picture. The user may add various elements to the chart, namely titles (|\gantttitle|, |\gantttitlelist|), bars (|\ganttbar|), milestones (|\ganttmilestone|), groups (|\ganttgroup|) and different links between these elements (|\ganttlink|). Furthermore, the appearance of the chart elements is highly customizable, owing to a number of keys. +% The \pack{pgfgantt} package provides the |ganttchart| environment, which draws a Gantt chart within a \TikZ\ picture. The user may add various elements to the chart, for example, titles, bars, groups, milestones and different links between these elements. The appearance of the chart elements is highly customizable, and even new chart elements may be defined. % \end{abstract} % % \tableofcontents +% \changes{v4.0}{2013/06/01}{The key \texttt{link label anchor} was renamed to \texttt{link label node}.} +% \changes{v4.0}{2013/06/01}{\cs{newganttchartelement} defines completely new chart elements.} +% \changes{v4.0}{2013/06/01}{The key \texttt{progress label anchor} was replaced by \texttt{bar}/\texttt{group}/\texttt{milestone progress label node}.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{bar}/\texttt{group}/\texttt{milestone progress label anchor} were added.} +% \changes{v4.0}{2013/06/01}{The key \texttt{progress label font} was replaced by the keys \texttt{bar}/\texttt{group}/\texttt{milestone progress label font}.} +% \changes{v4.0}{2013/06/01}{The key \texttt{incomplete} was removed.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{group right}/\texttt{left peak} and \texttt{group peaks} were replaced by \texttt{group right}/\texttt{left peak tip position}, \texttt{group peaks tip position}, \texttt{group right}/\texttt{left peak width}, \texttt{group peaks width}, \texttt{group right}/\texttt{left peak height} and \texttt{group peaks height}.} +% \changes{v4.0}{2013/06/01}{Chart elements are now nodes, so the corresponding styles must specify a node shape.} +% \changes{v4.0}{2013/06/01}{The key \texttt{time slot modifier} was renamed to \texttt{chart element start border}.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{bar}/\texttt{group}/\texttt{milestone label inline anchor} were renamed to \texttt{bar}/\texttt{group}/\texttt{milestone inline label node}.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{bar}/\texttt{group}/\texttt{milestone label shape anchor} were renamed to \texttt{bar}/\texttt{group}/\texttt{milestone inline label anchor}.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{bar}/\texttt{group}/\texttt{milestone label anchor} were renamed to \texttt{bar}/\texttt{group}/\texttt{milestone label node}.} +% \changes{v4.0}{2013/06/01}{The key \texttt{title label anchor} was renamed to \texttt{title label node}.} +% \changes{v4.0}{2013/06/01}{\cs{gantttitlecalendar} prints a title calendar.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{calendar week text} and \texttt{compress calendar} were added.} +% \changes{v4.0}{2013/06/01}{The key \texttt{newline shortcut} determines whether the shortcut for line breaks is defined in the chart. In this case, \cs{ganttalignnewline} allows line breaks in the node text.} +% \changes{v4.0}{2013/06/01}{The keys \texttt{today offset}, \texttt{today label font} and \texttt{today label node} were added.} +% \changes{v4.0}{2013/06/01}{The key \texttt{today} accepts a time slot specifier.} +% \changes{v4.0}{2013/06/01}{The canvas is now a node with shape \texttt{rectangle} by default.} +% \changes{v4.0}{2013/06/01}{\cs{newgantttimeslotformat} allows the user to define custom time slot formats.} +% \changes{v4.0}{2013/06/01}{The key \texttt{time slot format/start date} specifies the internal date representation of digit 1 in the \texttt{simple} time slot format.} +% \changes{v4.0}{2013/06/01}{The key \texttt{time slot format/base century} provides the century for autocompletion of two-digit years.} +% \changes{v4.0}{2013/06/01}{The key \texttt{time slot format} changes the format of time slot specifiers.} +% \changes{v4.0}{2013/06/01}{The \texttt{ganttchart} environment now requires two mandatory arguments.} +% +% \changes{v3.0}{2012/01/25}{\cs{setganttlinklabel} specifies the label for all links of a certain type. The \texttt{link label} key locally overrides any label set by this command.} +% \changes{v3.0}{2012/01/25}{The \texttt{chart element} shape supports four additional anchors (\texttt{on left}, \texttt{on top}, \texttt{on right} and \texttt{on bottom}).} +% \changes{v3.0}{2012/01/25}{\cs{@gtt@get} has been renamed to \cs{ganttvalueof} to provide a convenient access for link type authors.} +% \changes{v3.0}{2012/01/25}{\cs{@gtt@keydef} and \cs{@gtt@stylekeydef} have been rewritten to support \texttt{pgfkey}'s abilities to store key values.} +% \changes{v3.0}{2012/01/25}{New auxiliary macros for \cs{newganttlinkstyle}: \cs{xLeft}, \cs{xRight}, \cs{yUpper}, \cs{yLower}, \cs{ganttsetstartanchor}, \cs{ganttsetendanchor} and \cs{ganttlinklabel}.} +% \changes{v3.0}{2012/01/25}{Completely rewrote the code for links (again). Definition of new link types is now possible (via \cs{newganttlinktype} and \cs{newganttlinktypealias}).} +% \changes{v3.0}{2012/01/25}{The \texttt{bar/group/milestone label shape anchor} keys allow for a fine-tuned placement of chart element labels.} +% \changes{v3.0}{2012/01/25}{All style keys (\texttt{canvas}, \texttt{bar} etc.) only support the common \TikZ\ style key syntax.} +% \changes{v2.1}{2011/11/10}{The \texttt{inline} key moves labels close to their respective chart elements.} +% \changes{v2.1}{2011/11/10}{Added three keys (\texttt{bar/group/milestone label inline anchor}) for placing inline labels.} +% \changes{v2.1}{2011/11/10}{The \texttt{ganttchart} environment may be used outside a \texttt{tikzpicture}.} +% \changes{v2.0}{2011/10/10}{The syntax of \cs{ganttlink} was completely changed. The command now takes one optional and \textit{two} mandatory arguments. The latter specify the name of the chart elements to be linked. Consequently, the keys \texttt{b-b}, \texttt{b-m}, \texttt{m-b} and \texttt{m-m} were removed. The keys \texttt{s-s}, \texttt{s-f}, \texttt{f-s} and \texttt{f-f} are now values for the \texttt{link type} key.} +% \changes{v2.0}{2011/10/10}{The optional argument of \cs{ganttnewline} now also accepts a style.} +% \changes{v2.0}{2011/10/10}{Removed the \texttt{hgrid shift} and \texttt{last line height} keys.} +% \changes{v2.0}{2011/10/10}{Removed the \texttt{vgrid lines list} key, as its behaviour can be simulated by an appropriate \meta{style list} for \texttt{vgrid}.} +% \changes{v2.0}{2011/10/10}{Added style lists for the horizontal and vertical grid.} +% \changes{v2.0}{2011/10/10}{Removed the \texttt{vgrid style} key.} +% \changes{v2.0}{2011/10/10}{Completely rewrote the calculation of coordinates.} +% \changes{v2.0}{2011/10/10}{The \texttt{x unit}, \texttt{y unit title} and \texttt{y unit chart} keys specify the width of time slots and the height of title or chart lines, respectively. Thus, one can draw titles whose height differs from the rest of the chart. Furthermore, the $x$- and $y$-dimensions of the chart are independent of the dimensions of the surrounding \texttt{tikzpicture}.} +% \changes{v1.1}{2011/04/18}{\texttt{link tolerance} decides whether a five- or a three-part link is drawn.} +% \changes{v1.1}{2011/04/18}{\texttt{milestone label text} configures the text of a milestone label.} +% \changes{v1.1}{2011/04/18}{\texttt{bar label text} configures the text of a bar label.} +% \changes{v1.1}{2011/04/18}{The \texttt{time slot modifier} key has been added. If set to zero, all $x$-coordinates are interpreted as given, without regarding them as time slots.} +% \changes{v1.1}{2011/04/18}{The \texttt{vgrid lines list} key determines the number of vertical grid lines drawn.} +% \changes{v1.1}{2011/04/18}{The introduction clarifies what I mean by ``a current \textsc{pgf} installation''.} +% \changes{v1.1}{2011/04/18}{\texttt{group label text} configures the text of a group label.} +% \changes{v1.0}{2011/03/01}{Initial release} % % % \section{Introduction} % -% The \pack{pgfgantt} package allows you to draw Gantt charts in \LaTeX. Thus, you can describe simple project schedules without having to include images produced by external programs. Similar to Martin Kumm's \pack{gantt} package\footnote{\url{http://www.martin-kumm.de/tex_gantt_package.php}} (which inspired \pack{pgfgantt}'s fundamental aspects), \pack{pgfgantt} bases upon the \TikZ\ frontend of \textsc{pgf}\footnote{\url{http://ctan.org/tex-archive/graphics/pgf/}}. Besides, it provides a comprehensive (and portable) alternative to \pack{pst-gantt}\footnote{\url{http://ctan.org/tex-archive/graphics/pstricks/contrib/pst-gantt/}}. +% The \pack{pgfgantt} package allows you to draw Gantt charts in \LaTeX. Thus, you can describe simple project schedules without having to include images produced by external programs. Similar to Martin Kumm's \pack{gantt} package\footnote{\url{http://www.martin-kumm.de/tex_gantt_package.php}} (which inspired \pack{pgfgantt}'s fundamental aspects), \pack{pgfgantt} bases upon \textsc{pgf} and its \TikZ\ frontend\footnote{\url{http://ctan.org/tex-archive/graphics/pgf/}}. Besides, it provides a comprehensive (and portable) alternative to \pack{pst-gantt}\footnote{\url{http://ctan.org/tex-archive/graphics/pstricks/contrib/pst-gantt/}}. % -% \changes{v1.1}{2011/04/18}{The introduction clarifies what I mean by ``a current \textsc{pgf} installation''.} -% \pack{pgfgantt} requires a \textit{current} \textsc{pgf} installation. \textbf{\color{red}Note that the version number must at least be 2.10, dated October 25th, 2010.} Furthermore, \textbf{\color{red}\pack{pgfgantt} 3.0 and above is not fully downwards compatible. In particular, the syntax of \texttt{\string\ganttlink} has changed.} +% \pack{pgfgantt} requires a \textit{current} \textsc{pgf} installation. \textbf{\color{red}Note that the version number must at least be 2.10, dated October 25th, 2010.} Furthermore, \textbf{\color{red}\pack{pgfgantt}~\fileversion\ and above is not fully downwards compatible.} % -% \paragraph{Acknowledgements} I would like to thank Petr Po\v s\'ik (Czech Technical University in Prague), Rapha\"el Clifford (University of Bristol) and Holger Karl (Universität Paderborn) for their ideas concerning new features. +% \paragraph{Acknowledgements} I would like to thank Petr Po\v s\'ik (Czech Technical University in Prague), Rapha\"el Clifford (University of Bristol), Holger Karl (Universität Paderborn), Jakob D\o llner M\o nster (Technical University of Denmark), Sascha Yousefi (Universität Freiburg) and Callum Webb for their ideas concerning new features. % % -% \section{User Guide} +% \clearpage\section{User Guide} % % \subsection{Overview} % @@ -307,7 +381,7 @@ % Compare the following code, which demonstrates some commands provided by \pack{pgfgantt}, to the output it produces: % % \begin{texcode} -% \begin{ganttchart}{12} +% \begin{ganttchart}{1}{12} % \gantttitle{2011}{12} \\ % \gantttitlelist{1,...,12}{1} \\ % \ganttgroup{Group 1}{1}{7} \\ @@ -320,7 +394,7 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}{12} +% \begin{ganttchart}{1}{12} % \gantttitle{2011}{12} \\ % \gantttitlelist{1,...,12}{1} \\ % \ganttgroup{Group 1}{1}{7} \\ @@ -338,35 +412,113 @@ % % \textit{Keys} (sometimes called \textit{options}) modify the output from \pack{pgfgantt}'s commands. You may specify a key in two ways: (1) Pass it to the optional argument present in each command, e.\,g. % \begin{texcode} -% \ganttbar[bar label font=\bfseries]{Task 1}{1}{2} +% \ganttbar[bar height=.6]{Task 1}{1}{2} % \end{texcode} -% This locally changes a key for the element(s) drawn by that command. (2) Alternatively, specify a key by the \DescribeMacro{\ganttset}|\ganttset|\marg{key=value list} macro, which sets its keys globally (or rather within the current \TeX\ group): +% This locally changes a key for the element(s) drawn by that command. (2) Alternatively, specify a key by the \DescribeMacro{\ganttset}|\ganttset|\marg{key=value list} macro, which sets its keys within the current \TeX\ group: % \begin{texcode} -% \ganttset{bar label font=\bfseries} +% \ganttset{bar height=.6} % \end{texcode} % Since \pack{pgfgantt} uses the \pack{pgfkeys} package for key management, all its keys reside in the |/pgfgantt/| path. However, if you set your keys by one of the methods explained above, this path is automatically prepended to each key. % % \subsection{The Canvas} % -% Let us have a look at the basic anatomy of a Gantt chart and define some common terms. Each \textit{chart} consists of several \textit{elements}, such as titles, bars and connections between bars. Commands that start with |\gantt|\dots\ draw these elements. When specifying start and end \textit{coordinates} for these commands, we use the dimensionless \textit{chart coordinate system}, whose origin lies in the top left corner. Along the $x$-axis, one unit corresponds to one \textit{time slot}; along the $y$-axis, one unit equals one \textit{line}. +% Let us have a look at the basic anatomy of a Gantt chart and define some common terms. Each \textit{chart} consists of several \textit{lines}, which may contain one or more \textit{title elements} (at the top) or \textit{chart elements} (such as bars, groups and milestones). From left to right, the chart is divided into an integer number of \textit{time slots} that represent the basic $x$-unit. % -% The \DescribeEnv{ganttchart}|ganttchart| environment groups several of the element-drawing macros into a single chart: +% The \DescribeEnv{ganttchart}|ganttchart| environment draws a single Gantt chart: % \begin{texcode} -% \begin{ganttchart}`\oarg{options}\marg{number of time slots}' +% \begin{ganttchart}`\oarg{options}\marg{start tss}\marg{end tss}' % `$\cdots$' % \end{ganttchart} % \end{texcode} -% The environment has one optional and one mandatory argument. The former specifies the \meta{options} for the chart, the latter indicates the \meta{number of time slots}.\par -% \changes{v2.1}{2011/11/10}{The \texttt{ganttchart} environment may be used outside a \texttt{tikzpicture}.} -% Although you will often put a |ganttchart| into a |tikzpicture| environment, you may actually use the environment on its own. \pack{pgfgantt} checks whether the chart is surrounded by a |tikzpicture| and adds this environment if necessary. +% The environment has one optional argument, which specifies the \meta{options} for the chart, and two mandatory arguments, which indicate the start and end time slot specifier. Although you will often put a |ganttchart| into a |tikzpicture| environment, you may actually use this environment on its own. \pack{pgfgantt} checks whether a chart is surrounded by a |tikzpicture| and adds this environment if necessary. +% +% \begin{key}{time slot format}{\meta{format}}{simple} +% Sets the \meta{format} of time slot specifiers. A \textbf{time slot specifier} (abbreviated ``tss'') denotes a certain time slot along the horizontal axis. \pack{pgfgantt} defines a range of formats: +% \begin{itemize} +% \item \texttt{simple} -- positive integers (the single format used by \pack{pgfgantt} prior to v4.0). See also the \opt{time slot format/start date} key below.\\ +% \textit{Examples:} \texttt{1}, \texttt{3}, \texttt{24} +% \item \texttt{isodate} -- dates in ISO-standard format (\texttt{yyyy-mm-dd}). In this format and any other, you may omit the leading zero if month or day are less than 10.\\ +% \textit{Examples:} \texttt{2013-03-14}, \texttt{2013-5-1} +% \item \texttt{isodate-yearmonth} -- ISO-standard dates without days (\texttt{yyyy-mm}). Such dates are automatically converted to the first day of the respective month.\\ +% \textit{Examples:} \texttt{2013-03}, \texttt{2013-5} +% \item \texttt{little-endian} -- Gregorian little-endian, i.\,e. day--month--year (the common German date format). Valid day/month and month/year separators are the hyphen (\texttt{-}), slash (\texttt{/}) and period (\texttt{.}). If you enter a two-digit year (for example, \texttt{13} instead of \texttt{2013}), it will be completed according to the value of \opt{time slot format/base century} (see below).\\ +% \textit{Examples:} \texttt{14-03-2013}, \texttt{14/03/13}, \texttt{14.3.2013} +% \item \texttt{middle-endian} -- middle-endian, i.\,e. month--day--year (the common US date format). For valid separators and automatic year completion, see \textit{little-endian}.\\ +% \textit{Examples:} \texttt{03-14-2013}, \texttt{03/14/13}, \texttt{3.14.2013} +% \item \texttt{big-endian} -- Gregorian big-endian, i.\,e. year--month--day (the ISO"=standard order). For valid separators and automatic year completion, see \textit{little-endian}.\\ +% \textit{Examples:} \texttt{2013-03-14}, \texttt{13/03/14}, \texttt{2013.3.14} +% \end{itemize} +% \end{key} +% +% \noindent Two subkeys of \opt{time slot format} let you configure \pack{pgfgantt}'s behavior regarding automatic completion of abbreviated dates: +% +% \begin{key}{time slot format/base century}{\meta{year}}{2000} +% Sets the century for auto-completion of two-digit years (used by the time slot formats \texttt{little-endian}, \texttt{middle-endian} and \texttt{big-endian}). Consequently, default settings convert a year like \texttt{13} to \texttt{2013}. +% \end{key} +% +% \begin{key}{time slot format/start date}{\meta{ISO-standard date}}{2000-01-01} +% Numbers denoting time slots in the \texttt{simple} format are internally converted to a date, where \texttt{1} is converted to \meta{ISO-standard date}, \texttt{2} to $\meta{ISO-standard date} + 1$ etc. +% \end{key} +% +% \bigskip\noindent Advanced users may add their own time slot \DescribeMacro{\newgantttimeslotformat}formats: +% \begin{texcode} +% \newgantttimeslotformat`\marg{name}\marg{converter code}' +% \end{texcode} +% Defines a new time slot format called \meta{name}. The \meta{converter code} must convert the time slot specifier stored in |#1| to its corresponding Julian day number (see section~57 of the \TikZ\ manual) and assign this number to the count register |#2|. The \meta{converter code} is executed within a \TeX\ group, so you may use temporary macros like |\@tempa|, counts like |\@tempcnta| etc. +% +% For example, we would like to create a format called \texttt{stardate}, where dates are given as ``\meta{year}\texttt{.}\meta{day of year}''. Thus, we will enter 24th February 2259 as ``\texttt{2259.55}''. To this end, we write the following code: +% \par\bigskip\noindent +% \begin{texcode}[numbers=left] +% \newgantttimeslotformat{stardate}{% +% \def\decomposestardate##1.##2\relax{% +% \def\stardateyear{##1}\def\stardateday{##2}% +% }% +% \decomposestardate#1\relax% +% \pgfcalendardatetojulian{\stardateyear-01-01}{#2}% +% \advance#2 by-1\relax% +% \advance#2 by\stardateday\relax% +% } +% +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% time slot format=stardate +% ]{2259.55}{2259.67} +% \gantttitlecalendar{year, month=name, day} \\ +% \end{ganttchart} +% \end{texcode} +% \begin{center} +% \newgantttimeslotformat{stardate}{% +% \def\decomposestardate##1.##2\relax{% +% \def\stardateyear{##1}\def\stardateday{##2}% +% }% +% \decomposestardate#1\relax% +% \pgfcalendardatetojulian{\stardateyear-01-01}{#2}% +% \advance#2 by-1\relax% +% \advance#2 by\stardateday\relax% +% } +% +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% time slot format=stardate +% ]{2259.55}{2259.67} +% \gantttitlecalendar{year, month=name, day} \\ +% \end{ganttchart} +% \end{center} % -% \begin{key}[./style=]{canvas}{\meta{style}}{fill=white} -% The |canvas| key changes the appearance of the canvas. \meta{style} is a list of \TikZ\ keys such as |fill|, |draw| or |dashed|. By default, the canvas is a white rectangle with a black frame.\changes{v3.0}{2012/01/25}{All style keys (\texttt{canvas}, \texttt{bar} etc.) only support the common \TikZ\ style key syntax.} +% \noindent The macro |\decomposestardate| (lines 2--4) has two delimited arguments: The first one is delimited by a period and the second one by |\relax|. The call in line 5 decomposes the tss stored in |#1| and saves the day in |\stardateday| and the year in |\stardateyear|. |\pgfcalendardatetojulian| (section~57.1.1 of the \TikZ\ manual) calculates the Julian date of the first day of |\stardateyear| and stores it in |#2| (line 6). We then subtract 1 from |#2| (line 7) and add the |\stardateday| (line 8). +% +% \begin{key}[./style=]{canvas}{\meta{style}}{shape=rectangle, draw, fill=white} +% The \opt{canvas} key changes the appearance of the canvas. \meta{style} is a list of \TikZ\ keys suitable for the \meta{options} of a \TikZ\ node (such as |shape=rectangle|, |fill| or |draw|; see chapter~16 of the \TikZ\ manual). By default, the canvas is a white rectangle with a black frame. % \par\bigskip\noindent % \begin{texcode} % \begin{tikzpicture} % optional -% \begin{ganttchart}% -% [canvas/.style={fill=yellow!25, draw=blue, dashed, very thick}]{6} +% \begin{ganttchart}[ +% canvas/.style=% +% {shape=chamfered rectangle, fill=yellow!25, +% draw=blue, dashed, very thick} +% ]{1}{6} % \gantttitle{Title}{6} \\ % \ganttbar{}{1}{2} \\ % \ganttbar{}{3}{6} @@ -374,14 +526,15 @@ % \end{tikzpicture} % optional % \end{texcode} % \begin{center} -% \begin{tikzpicture} -% \begin{ganttchart}% -% [canvas/.style={fill=yellow!25, draw=blue, dashed, very thick}]{6} +% \begin{ganttchart}[ +% canvas/.style=% +% {shape=chamfered rectangle, fill=yellow!25, +% draw=blue, dashed, very thick} +% ]{1}{6} % \gantttitle{Title}{6} \\ % \ganttbar{}{1}{2} \\ % \ganttbar{}{3}{6} % \end{ganttchart} -% \end{tikzpicture} % \end{center} % \end{key} % @@ -389,12 +542,13 @@ % \keyline{y unit title}{\meta{dimension}}{1cm} % \keyline{y unit chart}{\meta{dimension}}{1cm} % These keys specify the width of a time slot and the height of title or chart lines, respectively. Typically, the $x/y$-dimension ratio approximates $1:2$, and the line height is equal over the whole chart. Other dimensions are well possible, but you might have to change several spacing-related keys in order to obtain a pleasing chart. -% \changes{v2.0}{2011/10/10}{Completely rewrote the calculation of coordinates.} -% \changes{v2.0}{2011/10/10}{The \texttt{x unit}, \texttt{y unit title} and \texttt{y unit chart} keys specify the width of time slots and the height of title or chart lines, respectively. Thus, one can draw titles whose height differs from the rest of the chart. Furthermore, the $x$- and $y$-dimensions of the chart are independent of the dimensions of the surrounding \texttt{tikzpicture}.} -% % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[x unit=1cm, y unit title=.6cm, y unit chart=1.5cm]{6} +% \begin{ganttchart}[ +% x unit=1cm, +% y unit title=.6cm, +% y unit chart=1.5cm +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \gantttitle{Title 2}{6} \\ % \ganttbar{}{1}{3} \\ @@ -402,7 +556,11 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[x unit=1cm, y unit title=.6cm, y unit chart=1.5cm]{6} +% \begin{ganttchart}[ +% x unit=1cm, +% y unit title=.6cm, +% y unit chart=1.5cm +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \gantttitle{Title 2}{6} \\ % \ganttbar{}{1}{3} \\ @@ -411,31 +569,32 @@ % \end{center} % \end{key} % -% \begin{key}[]{hgrid}{\texttt{[=false/true/}\meta{style list}\texttt{]}}{false} +% \begin{key}[]{hgrid}{\texttt{[=false}\space\textbar\space\texttt{true}\space\textbar\space\meta{style list}\texttt{]}}{false} % \keyline[/.style=]{hgrid style}{\meta{style}}{dotted} -% \keyline[]{vgrid}{\texttt{[=false/true/}\meta{style list}\texttt{]}}{false} -% |hgrid| draws a horizontal grid which starts immediately below the last title element. The key can be specified in four different ways: Firstly, |hgrid=false| eliminates the horizontal grid. You may omit this declaration, since it is the default. Secondly, both |hgrid| and |hgrid=true| activate the horizontal grid, which is then drawn in the default style |dotted|. Finally, |hgrid=|\meta{style list} draws the horizontal grid in the given \meta{style list} (see below). +% \keyline[]{vgrid}{\texttt{[=false}\space\textbar\space\texttt{true}\space\textbar\space\meta{style list}\texttt{]}}{false} +% \opt{hgrid} draws a horizontal grid which starts immediately below the last title element. The key can be specified in four different ways: Firstly, \opt{hgrid}|=false| eliminates the horizontal grid. You may omit this declaration, since it is the default. Secondly, both \opt{hgrid} and \opt{hgrid}|=true| activate the horizontal grid, which is then drawn in the default style |dotted|. Finally, \opt{hgrid}|=|\meta{style list} draws the horizontal grid in the given \meta{style list} (see below). % -% |hgrid style| changes the style of single horizontal grid lines that are drawn with |\ganttnewline[grid]| (see section~\ref{ssc:newline}). The |vgrid| key governs the vertical grid; otherwise, use it exactly like |hgrid|. -% \changes{v2.0}{2011/10/10}{Added style lists for the horizontal and vertical grid.} -% \changes{v2.0}{2011/10/10}{Removed the \texttt{vgrid style} key.} +% \opt{hgrid style} changes the style of single horizontal grid lines that are drawn with |\ganttnewline[grid]| (see section~\ref{ssc:LineBreaks}). % -% \textit{Style lists} allow you to draw the grid lines in different styles. Each style list consists of several \textit{style list items} separated by a comma. A style list item has the general syntax |*{|\meta{n}|}{|\meta{style}|}| and orders the package to repeat the \meta{style} \meta{n}-times. (This syntax is reminiscent of column specifications in a |tabular| environment.) Thus, the list |*2{red}, *1{green}, *{10}{blue, dashed}| instructs \pack{pgfgantt} to draw first two red vertical grid lines, then a green one and finally ten dashed blue lines. If any grid lines remain to be drawn at the end of the list, the package starts again at the beginning of the list. +% The \opt{vgrid} key governs the vertical grid; otherwise, use it exactly like \opt{hgrid}. % +% \textit{Style lists} allow you to draw the grid lines in different styles. Each style list consists of several \textit{style list items} separated by a comma. A style list item has the general syntax |*{|\meta{n}|}{|\meta{style}|}| and orders the package to repeat the \meta{style} \meta{n}-times. (This syntax is reminiscent of column specifications in a |tabular| environment.) Thus, the list |*2{red}, *1{green}, *{10}{blue, dashed}| instructs \pack{pgfgantt} to draw first two red vertical grid lines, then a green one and finally ten dashed blue lines. If any grid lines remain to be drawn at the end of the list, the package starts again at the beginning of the list. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={*2{red}, *1{green}, *{10}{blue, dashed}}]{20} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={*2{red}, *1{green}, *{10}{blue, dashed}} +% ]{1}{20} % \gantttitle{Title 1}{20} \\ % \ganttbar{}{1}{8} \\ % \ganttbar{}{9}{20} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={*2{red}, *1{green}, *{10}{blue, dashed}}]{20} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={*2{red}, *1{green}, *{10}{blue, dashed}} +% ]{1}{20} % \gantttitle{Title 1}{20} \\ % \ganttbar{}{1}{8} \\ % \ganttbar{}{9}{20} @@ -453,9 +612,10 @@ % \begin{texcode} % % wrong code % -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={{red, dotted}}]{6} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={{red, dotted}} +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} @@ -466,9 +626,10 @@ % \begin{texcode} % % correct code % -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={*1{red, dotted}}]{6} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={*1{red, dotted}} +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} @@ -477,17 +638,19 @@ % \end{minipage} % % \begin{center} -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={{red, dotted}}]{6} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={{red, dotted}} +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} % \end{ganttchart} % \hspace{1cm} -% \begin{ganttchart}% -% [hgrid=true, -% vgrid={*1{red, dotted}}]{6} +% \begin{ganttchart}[ +% hgrid=true, +% vgrid={*1{red, dotted}} +% ]{1}{6} % \gantttitle{Title 1}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} @@ -496,88 +659,104 @@ % % % In a chart with many time slots, drawing vertical grid lines between all of them will lead to a confusing appearance. In such a case, you can pass an appropriate \meta{style list} to |vgrid| in order to draw every second grid line, for example. -% \changes{v1.1}{2011/04/18}{The \texttt{vgrid lines list} key determines the number of vertical grid lines drawn.} -% \changes{v2.0}{2011/10/10}{Removed the \texttt{vgrid lines list} key, as its behaviour can be simulated by an appropriate \meta{style list} for \texttt{vgrid}.} % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid={draw=none, dotted}]{12} +% \begin{ganttchart}[vgrid={draw=none, dotted}]{1}{12} % \gantttitlelist{1,...,12}{1} \\ % \ganttbar{}{1}{4} \\ % \ganttbar{}{5}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid={draw=none, dotted}]{12} +% \begin{ganttchart}[vgrid={draw=none, dotted}]{1}{12} % \gantttitlelist{1,...,12}{1} \\ % \ganttbar{}{1}{4} \\ % \ganttbar{}{5}{11} % \end{ganttchart} % \end{center} % \end{key} -% -% \changes{v2.0}{2011/10/10}{Removed the \texttt{hgrid shift} and \texttt{last line height} keys.} % -% \begin{key}{today}{\meta{time slot}}{none} +% \begin{key}{today}{\meta{tss}}{none} +% \keyline{today offset}{\meta{number}}{1} % \keyline[/.style=]{today rule}{\meta{style}}{dashed, line width=1pt} % \keyline{today label}{\meta{text}}{TODAY} -% Sometimes, you may wish to indicate the current day, month or the like on a Gantt chart. In order to do so, pass an integer value to the |today| key, which draws a vertical rule at the corresponding \meta{time slot}. This rule appears in the \meta{style} denoted by |today rule|, while |today label| contains the \meta{text} below the rule. +% \keyline{today label font}{\meta{font commands}}{\string\normalfont} +% \keyline[/.style=]{today label node}{\meta{style}}{anchor=north, font=\string\ganttvalueof\{today label font\}} +% Sometimes, you may wish to indicate the current day, month or the like on a Gantt chart. In order to do so, pass an integer value to the \opt{today} key, which draws a vertical rule at the corresponding \meta{tss}. \opt{today offset} determines the exact $y$-coordinate in the time slot and should lie between 0.0 (left border) and 1.0 (right border). The today rule appears in the \meta{style} denoted by \opt{today rule}. The node that contains the \meta{text} given by \opt{today label} appears below the rule. It is formatted by \opt{today label font} and \opt{today label node}. % \par\bigskip\noindent -% \begin{minipage}[t]{.44\textwidth} +% \begin{minipage}[t]{.42\textwidth} % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, today=2]{6} +% \begin{ganttchart}[ +% vgrid, +% today=2 +% ]{1}{6} % \gantttitle{Title}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} % \end{ganttchart} % \end{texcode} % \end{minipage}\hfill -% \begin{minipage}[t]{.54\textwidth} +% \begin{minipage}[t]{.56\textwidth} % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, today=3, -% today label=\textcolor{blue}% -% {Current Week}, +% \begin{ganttchart}[ +% vgrid, +% time slot format=isodate, +% today=2013-05-03, +% today offset=.5, +% today label=Current Week, +% today label node/.append style=% +% {anchor=north west}, +% today label font=\itshape\color{red}, % today rule/.style=% -% {blue, ultra thick}]{6} +% {draw=blue, ultra thick} +% ]{2013-05-01}{2013-05-06} % \gantttitle{Title}{6} \\ -% \ganttbar{}{1}{3} \\ -% \ganttbar{}{4}{6} +% \ganttbar{}{2013-05-01}{2013-05-03} \\ +% \ganttbar{}{2013-05-04}{2013-05-06} % \end{ganttchart} % \end{texcode} % \end{minipage} % % \begin{center} -% \begin{ganttchart}% -% [vgrid, today=2]{6} +% \begin{ganttchart}[ +% vgrid, +% today=2 +% ]{1}{6} % \gantttitle{Title}{6} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{6} % \end{ganttchart} % \hspace{1cm} -% \begin{ganttchart}% -% [vgrid, today=3, -% today label=\textcolor{blue}% -% {Current Week}, +% \begin{ganttchart}[ +% vgrid, +% time slot format=isodate, +% today=2013-05-03, +% today offset=.5, +% today label=Current Week, +% today label node/.append style=% +% {anchor=north west}, +% today label font=\itshape\color{red}, % today rule/.style=% -% {blue, ultra thick}]{6} +% {draw=blue, ultra thick} +% ]{2013-05-01}{2013-05-06} % \gantttitle{Title}{6} \\ -% \ganttbar{}{1}{3} \\ -% \ganttbar{}{4}{6} +% \ganttbar{}{2013-05-01}{2013-05-03} \\ +% \ganttbar{}{2013-05-04}{2013-05-06} % \end{ganttchart} % \end{center} % \end{key} % % % \subsection{Line Breaks between Chart Elements} -% \label{ssc:newline} +% \label{ssc:LineBreaks} % -% \pack{pgfgantt} does not automatically begin a new line after finishing a \DescribeMacro{\ganttnewline}chart element. Instead, you must insert an explicit line break with |\ganttnewline|. Within a |ganttchart| environment, \DescribeMacro{\\}|\\| is defined as a shortcut for |\ganttnewline|, so that the syntax is reminiscent of \LaTeX's |tabular| enviroment. +% \pack{pgfgantt} does not automatically begin a new line after finishing a \DescribeMacro{\ganttnewline}chart element. Instead, you must insert an explicit line break with |\ganttnewline|. +% +% \begin{key}{newline shortcut}{\meta{boolean}}{true} +% If true, \DescribeMacro{\\}|\\| is defined as a shortcut for |\ganttnewline| within a |ganttchart| environment, so that the syntax is reminiscent of \LaTeX's |tabular| enviroment. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[hgrid, vgrid]{6} +% \begin{ganttchart}[hgrid, vgrid]{1}{6} % \gantttitle{Title 1}{3} % \gantttitle{Title 2}{3} \\ % \ganttbar{}{1}{3} \ganttnewline @@ -586,7 +765,7 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[hgrid, vgrid]{6} +% \begin{ganttchart}[hgrid, vgrid]{1}{6} % \gantttitle{Title 1}{3} % \gantttitle{Title 2}{3} \\ % \ganttbar{}{1}{3} \ganttnewline @@ -594,11 +773,64 @@ % \ganttbar{}{5}{6} % \end{ganttchart} % \end{center} +% \end{key} % -% Even if you prefer a canvas without a horizontal grid, you may nevertheless want to separate certain lines by a grid rule. For this purpose, specify the optional argument |[grid]| for |\ganttnewline| (or |\\|), which draws a grid rule in |hgrid style| between the current and the new line. Alternatively, directly give the desired style as optional argument. +% However, enabling this shortcut prevents you from entering multi-line node text (see section~16.4.3 of the \TikZ\ manual). Thus, \pack{pgfgantt} provides the macro \DescribeMacro{\ganttalignnewline}|\ganttalignnewline| for breaking lines in the node text. +% \par\bigskip\noindent +% \begin{minipage}[t]{.5\textwidth} +% \begin{texcode} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% newline shortcut=false, +% bar label node/.append style=% +% {align=left} +% ]{1}{6} +% \gantttitle{Title}{6} \ganttnewline +% \ganttbar{% +% This is a\\ +% multi-line text.% +% }{1}{3} +% \end{ganttchart} +% \end{texcode} +% \end{minipage}\hfill +% \begin{minipage}[t]{.48\textwidth} +% \begin{texcode} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% newline shortcut=true, +% bar label node/.append style=% +% {align=left} +% ]{1}{6} +% \gantttitle{Title}{6} \\ +% \ganttbar{% +% This is a\ganttalignnewline +% multi-line text.% +% }{1}{3} +% \end{ganttchart} +% \end{texcode} +% \end{minipage} +% \begin{center} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% newline shortcut=false, +% bar label node/.append style=% +% {align=left} +% ]{1}{6} +% \gantttitle{Title}{6} \ganttnewline +% \ganttbar% +% {This is a\\ +% multi-line text.% +% }{1}{3} +% \end{ganttchart} +% \end{center} +% +% Even if you prefer a canvas without a horizontal grid, you may nevertheless want to separate certain lines by a grid rule. For this purpose, specify the optional argument |[grid]| for |\ganttnewline| (or |\\|), which draws a grid rule in \opt{hgrid style} between the current and the new line. Alternatively, directly give the desired style as optional argument. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[hgrid style/.style=red]{12} +% \begin{ganttchart}[hgrid style/.style=red]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{}{1}{3} \ganttnewline[thick, blue] % \ganttbar{}{4}{5} \\ @@ -607,7 +839,7 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[hgrid style/.style=red]{12} +% \begin{ganttchart}[hgrid style/.style=red]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{}{1}{3} \ganttnewline[thick, blue] % \ganttbar{}{4}{5} \\ @@ -619,23 +851,23 @@ % % \subsection{Titles} % -% A \textit{title} (comprising one or more lines) at the top of a Gantt chart usually indicates the period of time covered by that chart. For example, the first line could span twelve time slots and display the current year, while the second line could contain twelve elements, each of which corresponds to one month. For these purposes, \pack{pgfgantt} implements two titling commands. +% A \textit{title} (comprising one or more lines) at the top of a Gantt chart usually indicates the period of time covered by that chart. For example, the first line could span twelve time slots and display the current year, while the second line could contain twelve elements, each of which corresponds to one month. For these purposes, \pack{pgfgantt} implements several titling commands. % % \DescribeMacro{\gantttitle}|\gantttitle| draws a single title element: % \begin{texcode} % \gantttitle`\oarg{options}\marg{label}\marg{number of time slots}' % \end{texcode} -% The \meta{label} appears in the center of the title element, which covers the \meta{number of time slots} starting from the right end of the last title element (or from the beginning of the line, if the title element is the first element in this line). Mostly, you will employ |\gantttitle| for titles that span several time slots. +% The \meta{label} appears in the title element, which covers the \meta{number of time slots} starting from the right end of the last title element (or from the beginning of the line, if the title element is the first element in this line). Mostly, you will employ |\gantttitle| for titles that span several time slots. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[hgrid, vgrid]{12} +% \begin{ganttchart}[hgrid, vgrid]{1}{12} % \gantttitle{2011}{12} \\ % \ganttbar{}{1}{4} % \ganttbar{}{6}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[hgrid, vgrid]{12} +% \begin{ganttchart}[hgrid, vgrid]{1}{12} % \gantttitle{2011}{12} \\ % \ganttbar{}{1}{4} % \ganttbar{}{6}{11} @@ -646,189 +878,274 @@ % \begin{texcode} % \gantttitlelist`\oarg{options}\marg{pgffor list}\marg{length of each element}' % \end{texcode} -% This macro generates one title element for each member of the \meta{pgffor list}. The second mandatory argument specifies the \meta{length of each element}. The \TikZ\ manual describes the syntax for the \meta{pgffor list} in more detail, but we will mention two of the most common applications: -% \begin{enumerate}\parskip0pt -% \item In order to draw twelve title elements that contain the numbers from 1 to 12 (indicating the months of a year), enter |1,...,12| as the \meta{pgffor} list. -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart}[hgrid, vgrid]{12} +% This macro generates one title element for each element of the \meta{pgffor list}. The second mandatory argument specifies the \meta{length of each element}. Refer to section~56 of the \TikZ\ manual for the detailed syntax for the \meta{pgffor list}. +% +% A simple application is to draw twelve title elements that contain the numbers from 1 to 12. The \meta{pgffor list} is |1,...,12|. +% \par\bigskip\noindent +% \begin{texcode} +% \begin{ganttchart}[hgrid, vgrid]{1}{12} % \gantttitlelist{1,...,12}{1} \\ % \ganttbar{}{1}{3} % \ganttbar{}{5}{12} % \end{ganttchart} -% \end{texcode} -% \begin{center} -% \begin{ganttchart}[hgrid, vgrid]{12} +% \end{texcode} +% \begin{center} +% \begin{ganttchart}[hgrid, vgrid]{1}{12} % \gantttitlelist{1,...,12}{1} \\ % \ganttbar{}{1}{3} % \ganttbar{}{5}{12} % \end{ganttchart} -% \end{center} -% Note that we would have obtained the same result if we had written -% \begin{texcode} +% \end{center} +% Note that we would have obtained the same result if we had written +% \begin{texcode} % \gantttitle{1}{1} \gantttitle{2}{1} `\dots' \gantttitle{12}{1} \\ -% \end{texcode} -% \item In order to draw seven title elements containing the names of the weekdays (e.\,g., ``Mon'' to ``Sun''), we have to change the |title list options| key:\par -% \begin{key}{title list options}{\meta{pgffor options}}{var=\string\x, evaluate=\string\x} -% This key changes the \meta{pgffor options} of the |\foreach| command called by |\gantttitlelist|. Again, the \TikZ\ manual is the definitive reference on possible \meta{pgffor options}. There is just one thing to keep in mind: The macro that yields the labels to be printed by |\gantttitlelist| must be called |\x|. -% \end{key}\par -% The following example shows how you can implement a title line enumerating the days of the week: -% \par\bigskip\noindent -% \begin{texcode} -% \usepackage{pgfcalendar} -% `$\cdots$' -% \begin{ganttchart}[hgrid, vgrid, x unit=1cm]{7} -% \gantttitlelist[title list options={% -% var=\y, evaluate=\y as \x% -% using "\pgfcalendarweekdayshortname{\y}"% -% }]{0,...,6}{1} \\ +% \end{texcode} +% +% As an advanced example, we will draw seven title elements containing the names of the weekdays (``Mon'' to ``Sun''). To this end, we introduce an additional key: +% +% \begin{key}{title list options}{\meta{pgffor options}}{var=\string\x, evaluate=\string\x} +% Changes the \meta{pgffor options} of the |\foreach| command called by |\gantttitlelist| (see section~56 of the \TikZ\ manual). The macro that yields the labels to be printed by |\gantttitlelist| must be called |\x|. +% \par\bigskip\noindent\shorthandoff{"} +% \begin{texcode} +% \begin{ganttchart}[hgrid, vgrid, x unit=1cm]{1}{7} +% \gantttitlelist[ +% title list options=% +% {var=\y, evaluate=\y as \x% +% using "\pgfcalendarweekdayshortname{\y}"} +% ]{0,...,6}{1} \\ % \ganttbar{}{1}{4} % \ganttbar{}{6}{7} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[hgrid, vgrid, x unit=1cm]{7} -% \gantttitlelist[title list options={% -% var=\y, evaluate=\y as \x% -% using "\pgfcalendarweekdayshortname{\y}"% -% }]{0,...,6}{1} \\ +% \begin{ganttchart}[hgrid, vgrid, x unit=1cm]{1}{7} +% \gantttitlelist[ +% title list options=% +% {var=\y, evaluate=\y as \x% +% using "\pgfcalendarweekdayshortname{\y}"} +% ]{0,...,6}{1} \\ % \ganttbar{}{1}{4} % \ganttbar{}{6}{7} % \end{ganttchart} +% \end{center}\shorthandon{"} +% \end{key} +% +% \bigskip While you actually may build any chart title with the two commands described previously, \DescribeMacro{\gantttitlecalendar}|\gantttitlecalendar| saves a lot of time when you wish to create elaborate calendars: +% \begin{texcode} +% \gantttitlecalendar`\oarg{options}\marg{calendar lines}' +% \end{texcode} +% Prints a title calendar that spans the whole chart and contains one or more \meta{calendar lines}. The starred \DescribeMacro{\gantttitlecalendar*}form of the macro prints a calendar from \meta{start tss} to \meta{end tss}: +% \begin{texcode} +% \gantttitlecalendar*`\oarg{options}\marg{start tss}\marg{end tss}\marg{calendar lines}' +% \end{texcode} +% \meta{calendar lines} is a comma-separated list of line types: +% \begin{center} +% \begin{tabular}{*3l} +% \toprule +% \itshape Line type & \meta{output format} & \itshape Example output \\ +% \midrule +% \texttt{year} & n/a & 2012, 2013, \dots \\[1ex] +% \texttt{month [=}\meta{output format}\texttt{]} & (none) & 01, 02, \dots, 12 \\ +% & \texttt{name} & January, February, \dots \\ +% & \texttt{shortname} & Jan, Feb, \dots \\[1ex] +% \texttt{week [=}\meta{number}\texttt{]} & n/a & Week 1, Week 2, \dots \\[1ex] +% \texttt{weekday [=}\meta{output format}\texttt{]} & (none) & 0, 1, \dots, 6 \\ +% & \texttt{name} & Monday, Tuesday, \dots \\ +% & \texttt{shortname} & Mon, Tue, \dots \\[1ex] +% \texttt{day} & n/a & 01, 02, \dots, 31 \\ +% \bottomrule +% \end{tabular} % \end{center} -% \end{enumerate} -% -% \begin{key}[/.style=]{title}{\meta{style}}{fill=white} -% Sets the appearance of a title element. +% +% The \meta{number} for the \texttt{week} line type is the number of the first week in the calendar. % \par\bigskip\noindent % \begin{texcode} -% \usetikzlibrary{shadows} -% \usetikzlibrary{shadings} -% `$\cdots$' -% \begin{ganttchart}% -% [vgrid, canvas/.style={draw=none}, -% title/.style={fill=blue!20, rounded corners=2mm, drop shadow}]{7} -% \gantttitle{First week}{7} \\ -% \gantttitlelist[title/.style={draw=none, inner color=red}]{1,...,7}{1} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{7} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=4mm, +% time slot format=isodate +% ]{2012-12-25}{2013-02-01} +% \gantttitlecalendar{year, month, day, week=3, weekday} \\ +% \ganttbar{}{2013-01-14}{2013-01-17} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, canvas/.style={draw=none}, -% title/.style={fill=blue!20, rounded corners=2mm, drop shadow}]{7} -% \gantttitle{First week}{7} \\ -% \gantttitlelist[title/.style={draw=none, inner color=red}]{1,...,7}{1} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{7} -% \end{ganttchart} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=4mm, +% time slot format=isodate +% ]{2012-12-25}{2013-02-01} +% \gantttitlecalendar{year, month, day, week=3, weekday} \\ +% \ganttbar{}{2013-01-14}{2013-01-17} +% \end{ganttchart}\hspace*{-51.4pt} % \end{center} -% \end{key} -% -% \begin{key}{title label font}{\meta{font commands}}{\string\small} -% Selects the font of the text inside a title element. In most cases, you can include font format commands directly in the first mandatory argument of |\gantttitle|. However, you \textit{must} use the |title label font| key if you intend to change the font size. Otherwise, the vertical alignment of the title label will be incorrect with the standard anchor. +% +% You can easily add new output formats for \texttt{month} and \texttt{weekday}. The predefined ones use the macros described in section~57.1.3 of the \TikZ\ manual. For example, |weekday=name| calls |\pgfcalendarweekdayname|. Thus, new macros called |\pgfcalendarmonth|\textcolor{RoyalBlue}{\meta{output format}} or |\pgfcalendarweekday|\textcolor{RoyalBlue}{\meta{output format}} will provide additional \meta{output format}s for |month| and |weekday|, respectively. +% +% A weekday output format called |letter|, which displays a weekday as single letter, might be implemented as follows: % \par\bigskip\noindent -% \begin{minipage}[t]{.49\textwidth} % \begin{texcode} -% % Wrong alignment -% -% \begin{ganttchart}% -% [vgrid, hgrid, -% y unit title=1.3cm]{6} -% \gantttitle{% -% \LARGE\color{violet}% -% \scshape Title}{6} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} +% \def\pgfcalendarweekdayletter#1{% +% \ifcase#1M\or T\or W\or T\or F\or S\or S\fi% +% } +% +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=18mm, +% time slot format=little-endian +% ]{7.1.2013}{13.1.2013} +% \gantttitlecalendar*{7.1.2013}{13.1.2013}{ +% month, month=name, month=shortname, weekday, +% weekday=name, weekday=shortname, weekday=letter +% } % \end{ganttchart} % \end{texcode} -% \end{minipage}\hfill -% \begin{minipage}[t]{.49\textwidth} +% \begin{center} +% \def\pgfcalendarweekdayletter#1{% +% \ifcase#1M\or T\or W\or T\or F\or S\or S\fi% +% } +% +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=18mm, +% time slot format=little-endian +% ]{7.1.2013}{13.1.2013} +% \gantttitlecalendar*{7.1.2013}{13.1.2013}{ +% month, month=name, month=shortname, weekday, +% weekday=name, weekday=shortname, weekday=letter +% } +% \end{ganttchart} +% \end{center} +% +% \begin{key}{calendar week text}{\meta{format}}{Week\string~\string\currentweek} +% Changes the text displayed in a week title element. In \meta{format}, four additional macros are available: \DescribeMacro{\currentweek}|\currentweek| is the current week number; \DescribeMacro{\startyear}|\startyear|, \DescribeMacro{\startmonth}|\startmonth| and \DescribeMacro{\startday}|\startday| expand to the year, month and day of the current week's Monday. +% \par\bigskip\noindent % \begin{texcode} -% % Correct alignment -% -% \begin{ganttchart}% -% [vgrid, hgrid, -% y unit title=1.3cm, -% title label font={\LARGE, -% \color{violet},\scshape}]{6} -% \gantttitle{Title}{6} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} +% \ganttset{% +% calendar week text={% +% \pgfcalendarmonthshortname{\startmonth}~\startday, \startyear% +% }% +% } +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=4mm, +% time slot format=isodate +% ]{2012-12-24}{2013-01-20} +% \gantttitlecalendar{year, week, day} \\ +% \ganttbar{}{2013-01-10}{2013-01-17} % \end{ganttchart} % \end{texcode} -% \end{minipage} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, -% y unit title=1.3cm]{6} -% \gantttitle{% -% \LARGE\color{violet}% -% \scshape Title}{6} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} -% \end{ganttchart} -% \hspace{1cm} -% \begin{ganttchart}% -% [vgrid, hgrid, -% y unit title=1.3cm, -% title label font={\LARGE, -% \color{violet},\scshape}]{6} -% \gantttitle{Title}{6} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} +% \ganttset{% +% calendar week text={% +% \pgfcalendarmonthshortname{\startmonth}~\startday, \startyear% +% }% +% } +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% x unit=4mm, +% time slot format=isodate +% ]{2012-12-24}{2013-01-20} +% \gantttitlecalendar{year, week, day} \\ +% \ganttbar{}{2013-01-10}{2013-01-17} % \end{ganttchart} % \end{center} % \end{key} -% -% \begin{key}[/.style=]{title label anchor}{\meta{anchor}}{anchor=mid} -% By default, title labels are vertically centered at half their $x$-height. This yields a good alignment for labels whose letters have equal amounts of ascenders and descenders (e.\,g., lowercase numbers). However, when the letters contain mostly ascenders (e.\,g., uppercase numbers), the label position will appear too high. In this case, you should change the anchor: +% +% \begin{key}{compress calendar}{\meta{boolean}}{false} +% By default, one \textit{calendar day} is one time slot wide. With \opt{compress calendar}\texttt{=true}, one \textit{month} corresponds to one time slot. Consequently, in compressed calendars only |year| and |month| are sensible line types for |\gantttitlecalendar|. The time slot format \texttt{isodate-yearmonth} is especially suited for compressed calendars. % \par\bigskip\noindent -% \begin{minipage}[t]{.44\textwidth} % \begin{texcode} -% % Badly centered label -% -% \begin{ganttchart}% -% [vgrid, hgrid, -% title label font={\LARGE}% -% ]{6} -% \gantttitle{2011}{6} \\ -% \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% time slot format=isodate-yearmonth, +% compress calendar +% ]{2012-01}{2013-5} +% \gantttitlecalendar{year, month} \\ +% \ganttbar{}{2012-05}{2013-01} % \end{ganttchart} % \end{texcode} -% \end{minipage}\hfill -% \begin{minipage}[t]{.54\textwidth} +% \begin{center} +% \begin{ganttchart}[ +% hgrid, +% vgrid, +% time slot format=isodate-yearmonth, +% compress calendar +% ]{2012-01}{2013-5} +% \gantttitlecalendar{year, month} \\ +% \ganttbar{}{2012-05}{2013-01} +% \end{ganttchart} +% \end{center} +% \end{key} +% +% \begin{key}[/.style=]{title}{\meta{style}}{shape=rectangle, inner sep=0pt, draw, fill=white} +% Sets the appearance of a title element. +% \par\bigskip\noindent % \begin{texcode} -% % Nicely centered label -% -% \begin{ganttchart}% -% [vgrid, hgrid, -% title label font={\LARGE}, -% title label anchor/.style=% -% {below=-1.5ex}]{6} -% \gantttitle{2011}{6} \\ +% \usetikzlibrary{shadows} +% \usetikzlibrary{shadings} +% `$\cdots$' +% \begin{ganttchart}[ +% vgrid, +% canvas/.style={draw=none}, +% title/.append style=% +% {fill=blue!20, rounded corners=2mm, drop shadow} +% ]{1}{7} +% \gantttitle{First week}{7} \\ +% \gantttitlelist[ +% title/.style={draw=none, inner color=red} +% ]{1,...,7}{1} \\ % \ganttbar{}{1}{2} -% \ganttbar{}{4}{6} +% \ganttbar{}{4}{7} % \end{ganttchart} % \end{texcode} -% \end{minipage} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, -% title label font={\LARGE}% -% ]{6} +% \begin{ganttchart}[ +% vgrid, +% canvas/.style={draw=none}, +% title/.append style=% +% {fill=blue!20, rounded corners=2mm, drop shadow} +% ]{1}{7} +% \gantttitle{First week}{7} \\ +% \gantttitlelist[ +% title/.style={draw=none, inner color=red} +% ]{1,...,7}{1} \\ +% \ganttbar{}{1}{2} +% \ganttbar{}{4}{7} +% \end{ganttchart} +% \end{center} +% \end{key} +% +% \begin{key}{title label font}{\meta{font commands}}{\string\small} +% \keyline[/.style=]{title label node}{\meta{options}}{anchor=center, font=\string\ganttvalueof\{title label font\}} +% The \meta{font commands} and \meta{options} are applied to the title label node, which is positioned at the center of each title element. +% \par\bigskip\noindent +% \begin{texcode} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% title label font=\LARGE\color{violet}, +% title label node/.append style={anchor=west} +% ]{1}{6} % \gantttitle{2011}{6} \\ % \ganttbar{}{1}{2} % \ganttbar{}{4}{6} % \end{ganttchart} -% \hspace{1cm} -% \begin{ganttchart}% -% [vgrid, hgrid, -% title label font={\LARGE}, -% title label anchor/.style=% -% {below=-1.5ex}]{6} +% \end{texcode} +% \begin{center} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% title label font=\LARGE\color{violet}, +% title label node/.append style={anchor=west} +% ]{1}{6} % \gantttitle{2011}{6} \\ % \ganttbar{}{1}{2} % \ganttbar{}{4}{6} @@ -840,11 +1157,11 @@ % \keyline{title right shift}{\meta{factor}}{0} % \keyline{title top shift}{\meta{factor}}{0} % \keyline{title height}{\meta{factor}}{0.6} -% The first three keys shift the coordinates of a title element's borders (or rather of its corners), while |title height| changes its height. By default, the left upper corner of a title element coincides with the origin of the start time slot; its right lower corner touches the right border of the end time slot $0.6$ units below the upper line border: +% The first three keys shift the coordinates of a title element's borders (or rather of its corners), while \opt{title height} changes its height. By default, the left upper corner of a title element coincides with the origin of the start time slot; its right lower corner touches the right border of the end time slot 0.6~units below the upper line border: % % \begin{center} % \begin{tikzpicture}[x=.5cm, y=1cm] -% \begin{ganttchart}[vgrid, hgrid]{6} +% \begin{ganttchart}[vgrid, hgrid]{1}{6} % \gantttitle{2011}{6} \\ % \ganttbar{}{1}{2} % \ganttbar{}{4}{6} @@ -862,7 +1179,7 @@ % The figure below shows a Gantt chart with two lines and one (large) time slot and indicates the distances modified by these keys. % \begin{center} % \begin{tikzpicture}[x=7cm, y=2cm] -% \begin{ganttchart}[x unit=7cm, y unit title=2cm, title/.style={line width=1.5pt,fill=yellow!10},title left shift=.2,title right shift=-.3,title top shift=.25, title height=.5]{1} +% \begin{ganttchart}[x unit=7cm, y unit title=2cm, title/.append style={line width=1.5pt,fill=yellow!10},title left shift=.2,title right shift=-.3,title top shift=.25, title height=.5]{1}{1} % \gantttitle{}{1} \\ % \end{ganttchart} % \small @@ -886,20 +1203,30 @@ % For example, you might devise a layout where the title element does not touch the borders of the start and end time slot. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, title/.style={fill=teal, draw=none}, +% \begin{ganttchart}[ +% vgrid, +% title/.style={fill=teal, draw=none}, % title label font=\color{white}\bfseries, -% title left shift=.1, title right shift=-.1, -% title top shift=.05, title height=.75]{7} +% title left shift=.1, +% title right shift=-.1, +% title top shift=.05, +% title height=.75 +% ]{1}{7} % \gantttitle{Title}{7} \\ % \ganttbar{}{1}{2} % \ganttbar{}{4}{7} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, title/.style={fill=teal, draw=none}, +% \begin{ganttchart}[ +% vgrid, +% title/.style={fill=teal, draw=none}, % title label font=\color{white}\bfseries, -% title left shift=.1, title right shift=-.1, -% title top shift=.05, title height=.75]{7} +% title left shift=.1, +% title right shift=-.1, +% title top shift=.05, +% title height=.75 +% ]{1}{7} % \gantttitle{Title}{7} \\ % \ganttbar{}{1}{2} % \ganttbar{}{4}{7} @@ -908,21 +1235,29 @@ % \end{key} % % \begin{key}{include title in canvas}{\meta{boolean}}{true} -% The canvas normally comprises all lines of the chart. However, you may wish that your title elements only consist of text lacking any frame or background. In this case, the canvas probably should exclude all lines containing title elements, which you achieve by |include title in canvas=false|. +% The canvas normally comprises all lines of the chart. However, you may wish that your title elements only consist of text lacking any frame or background. In this case, the canvas probably should exclude all lines containing title elements, which you achieve by \opt{include title in canvas}|=false|. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [hgrid={*1{draw=red, thick}}, vgrid, -% title/.style={draw=none, fill=none}, include title in canvas=false]{7} +% \begin{ganttchart}[ +% hgrid={*1{draw=red, thick}}, +% vgrid, +% y unit title=.5cm, +% title/.style={draw=none, fill=none}, +% include title in canvas=false +% ]{1}{7} % \gantttitlelist{1,...,7}{1} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{7} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [hgrid={*1{draw=red, thick}}, vgrid, -% title/.style={draw=none, fill=none}, include title in canvas=false]{7} +% \begin{ganttchart}[ +% hgrid={*1{draw=red, thick}}, +% vgrid, +% y unit title=.5cm, +% title/.style={draw=none, fill=none}, +% include title in canvas=false +% ]{1}{7} % \gantttitlelist{1,...,7}{1} \\ % \ganttbar{}{1}{3} \\ % \ganttbar{}{4}{7} @@ -931,173 +1266,328 @@ % \end{key} % % -% \subsection{Bars} -% \label{ssc:bars} -% -% On a Gantt chart, a \textit{bar} indicates the duration of a task or one of its parts. +% \subsection{Predefined Chart Elements} +% +% \pack{pgfgantt} predefines three chart elements: +% \begin{enumerate} +% \item \DescribeMacro{\ganttbar}\textit{Bars} indicate the duration of a task or one of its parts. +% \begin{texcode} +% \ganttbar`\oarg{options}\marg{label}\marg{start tss}\marg{end tss}' +% \end{texcode} +% \item \DescribeMacro{\ganttgroup}\textit{Groups} combine several subtasks (represented by bars) into a single task. +% \begin{texcode} +% \ganttgroup`\oarg{options}\marg{label}\marg{start tss}\marg{end tss}' +% \end{texcode} +% \item \DescribeMacro{\ganttmilestone}\textit{Milestones} signify that an important task has been completed or that a crucial goal has been reached. % \begin{texcode} -% \ganttbar`\oarg{options}\marg{label}\marg{start time slot}\marg{end time slot}' +% \ganttmilestone`\oarg{options}\marg{label}\marg{tss}' % \end{texcode} -% The \DescribeMacro{\ganttbar}|\ganttbar| macro draws a bar from the \meta{start time slot} to the \meta{end time slot} and adds a \meta{label} at the left of the chart. +% \end{enumerate} +% Each of these macros draws a \meta{label}ed chart element from the \meta{start tss} to the \meta{end tss} (or at the given \meta{tss} in case of |\ganttmilestone|). +% % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ % \ganttbar{Task 1}{1}{3} \\ % \ganttbar{Task 2}{4}{10} \\ -% \ganttbar{Final task}{11}{12} +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ % \ganttbar{Task 1}{1}{3} \\ % \ganttbar{Task 2}{4}{10} \\ -% \ganttbar{Final task}{11}{12} +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{center} % -% \begin{key}{time slot modifier}{\meta{factor}}{-1} -% Note that a bar usually touches the left border of the \meta{start time slot} and not the right, as it would if the \meta{start time slot} were strictly interpreted as an $x$-coordinate. However, you may prefer to work with ``real'' $x$-coordinates instead of time slots. In this case, just set the |time slot modifier| key to zero. This will essentially eliminate the semi-intelligent behavior of \pack{pgfgantt} with respect to the conversion of $x$-coordinates. This feature may prove useful if you decide to use real numbers for some time slots. \changes{v1.1}{2011/04/18}{The \texttt{time slot modifier} key has been added. If set to zero, all $x$-coordinates are interpreted as given, without regarding them as time slots.} +% For \DescribeMacro{\ganttlinkedbar}each predefined chart element, there is also a macro that additionally draws a link \DescribeMacro{\ganttlinkedgroup}from the previous element. Otherwise, these macros work exactly like the standard \DescribeMacro{\ganttlinkedmilestone}versions: +% \begin{texcode} +% \ganttlinkedbar`\oarg{options}\marg{label}\marg{start tss}\marg{end tss}' +% \ganttlinkedgroup`\oarg{options}\marg{label}\marg{start tss}\marg{end tss}' +% \ganttlinkedmilestone`\oarg{options}\marg{label}\marg{tss}' +% \end{texcode} +% In the following example, the code on the left is equivalent to the code on the right. +% \par\bigskip\noindent +% \begin{minipage}[t]{.49\textwidth} +% \begin{texcode} +% % Short version +% +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} +% \gantttitle{Title}{12} \\ +% \ganttbar{Task 1}{1}{4} \\ +% \ganttlinkedbar{Task 2}{5}{6} \\ +% \ganttlinkedmilestone{M 1}{6} \\ +% \ganttlinkedbar{Task 3}{7}{11} +% \end{ganttchart} +% \end{texcode} +% \end{minipage}\hfill +% \begin{minipage}[t]{.47\textwidth} +% \begin{texcode} +% % Long version +% +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} +% \gantttitle{Title}{12} \\ +% \ganttbar{Task 1}{1}{4} \\ +% \ganttbar{Task 2}{5}{6} \\ +% \ganttmilestone{M 1}{6} \\ +% \ganttbar{Task 3}{7}{11} +% \ganttlink{elem0}{elem1} +% \ganttlink{elem1}{elem2} +% \ganttlink{elem2}{elem3} +% \end{ganttchart} +% \end{texcode} +% \end{minipage} +% +% \begin{center} +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} +% \gantttitle{Title}{12} \\ +% \ganttbar{Task 1}{1}{4} \\ +% \ganttlinkedbar{Task 2}{5}{6} \\ +% \ganttlinkedmilestone{M 1}{6} \\ +% \ganttlinkedbar{Task 3}{7}{11} +% \end{ganttchart} +% \end{center} +% +% \begin{key}{chart element start border}{\texttt{left}\space\textbar\space\texttt{right}}{left} +% Determines which border of the start time slot a chart element touches. \texttt{left} is the behavior usually expected, while \texttt{right} strictly interprets the start time slot as an $x$-coordinate. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, time slot modifier=0]{12} +% \begin{ganttchart}[vgrid, hgrid, chart element start border=right]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{0}{10} \\ % \ganttbar{Task 1}{0}{3} \\ % \ganttbar{Task 2}{3}{10} \\ -% \ganttbar{Final task}{10}{12} +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, time slot modifier=0]{12} +% \begin{ganttchart}[vgrid, hgrid, chart element start border=right]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{0}{10} \\ % \ganttbar{Task 1}{0}{3} \\ % \ganttbar{Task 2}{3}{10} \\ -% \ganttbar{Final task}{10}{12} +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{center} % \end{key} +% +% +% \subsubsection{Options: Chart Element Appearance} +% +% The following options are similar for all predefined (and user-defined) chart elements: % -% \begin{key}[/.style=]{bar}{\meta{style}}{fill=white} -% Determines the appearance of the bar. +% \begin{key}[/.style=]{bar}{\meta{style}}{shape=ganttbar, inner sep=0pt, draw, fill=white} +% \keyline[/.style=]{group}{\meta{style}}{shape=ganttgroup, inner sep=0pt, fill=black} +% \keyline[/.style=]{milestone}{\meta{style}}{shape=ganttmilestone, inner sep=0pt, draw, fill=black} +% Determines the appearance of the chart element. The shapes \texttt{ganttbar}, \texttt{ganttgroup} and \texttt{ganttmilestone} are described below. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, bar/.style={fill=red!50}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar/.append style={fill=red!50}, +% group/.append style={draw=black, fill=green!50}, +% milestone/.append style={fill=orange, rounded corners=3pt} +% ]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ % \ganttbar{Task 1}{1}{3} \\ -% \ganttbar[bar/.style={fill=yellow, dashed}]{Task 2}{4}{10} \\ -% \ganttbar[bar/.style={fill=green, draw=none}]{Final task}{11}{12} +% \ganttbar[ +% bar/.append style={shape=ellipse, fill=yellow, dashed} +% ]{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, bar/.style={fill=red!50}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar/.append style={fill=red!50}, +% group/.append style={draw=black, fill=green!50}, +% milestone/.append style={fill=orange, rounded corners=3pt} +% ]{1}{12} % \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ % \ganttbar{Task 1}{1}{3} \\ -% \ganttbar[bar/.style={fill=yellow, dashed}]{Task 2}{4}{10} \\ -% \ganttbar[bar/.style={fill=green, draw=none}]{Final task}{11}{12} +% \ganttbar[ +% bar/.append style={shape=ellipse, fill=yellow, dashed} +% ]{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{center} % \end{key} % +% +% \subsubsection{Options: Label Formatting} +% % \begin{key}{bar label text}{\meta{text}}{\string\strut\#1} +% \keyline{group label text}{\meta{text}}{\string\strut\#1} +% \keyline{milestone label text}{\meta{text}}{\string\strut\#1} % \keyline{bar label font}{\meta{font commands}}{\string\normalsize} -% \keyline[./style=]{bar label anchor}{\meta{anchor}}{anchor=east} -% The |bar label text| key configures the label \meta{text} next to each bar. This key should contain a single parameter token (|#1|), which is replaced by the first mandatory argument of |\ganttbar|. The |\strut| in the standard value ensures equal vertical spacing of the labels. |bar label font| selects the font for the bar label, |bar label anchor| determines its anchor. The last control sequence in \meta{font commands} may take a single argument (like |\textit|). \changes{v1.1}{2011/04/18}{\texttt{bar label text} configures the text of a bar label.} +% \keyline{group label font}{\meta{font commands}}{\string\bfseries} +% \keyline{milestone label font}{\meta{font commands}}{\string\itshape} +% \keyline[./style=]{bar label node}{\meta{options}}{anchor=east, font=\string\ganttvalueof\{bar label font\}} +% \keyline[./style=]{group label node}{\meta{options}}{anchor=east, font=\string\ganttvalueof\{group label font\}} +% \keyline[./style=]{milestone label node}{\meta{options}}{anchor=east, font=\string\ganttvalueof\{milestone label font\}} +% The \opt{\dots\ label text} keys configure the label \meta{text} next to each chart element. Each of these keys should contain a single parameter token (|#1|), which is replaced by the first mandatory argument of |\ganttbar| etc. The |\strut| in the standard value ensures equal vertical spacing of the labels. The \meta{font commands} of \opt{\dots\ label font} and the \meta{options} of \opt{\dots\ label node} are applied to the label node at the left border of the chart (see \opt{inline} below). % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart} -% [vgrid, hgrid, bar label font=\Large, -% bar label text={--#1$\rightarrow$}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar label font=\Large, +% bar label text={--#1$\rightarrow$}, +% group label font=\color{orange}, +% group label text={+#1+}, +% milestone label font=\color{magenta}, +% milestone label node/.append style={rotate=30}, +% milestone label text={#1 !!!} +% ]{1}{12} % \gantttitle{Title}{12} \\ -% \ganttbar[bar label anchor/.style={left=1cm}]{Task 1}{1}{3} \\ -% \ganttbar[bar label font=\color{orange}]{Task 2}{4}{10} \\ -% \ganttbar[bar label font=\MakeUppercase]{Final task}{11}{12} +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar{Task 1}{1}{3} \\ +% \ganttbar{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart} -% [vgrid, hgrid, bar label font=\Large, -% bar label text={--#1$\rightarrow$}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar label font=\Large, +% bar label text={--#1$\rightarrow$}, +% group label font=\color{orange}, +% group label text={+#1+}, +% milestone label font=\color{magenta}, +% milestone label node/.append style={rotate=30}, +% milestone label text={#1 !!!} +% ]{1}{12} % \gantttitle{Title}{12} \\ -% \ganttbar[bar label anchor/.style={left=1cm}]{Task 1}{1}{3} \\ -% \ganttbar[bar label font=\color{orange}]{Task 2}{4}{10} \\ -% \ganttbar[bar label font=\MakeUppercase]{Final task}{11}{12} +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar{Task 1}{1}{3} \\ +% \ganttbar{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{center} % \end{key} -% +% % \begin{key}{inline}{\meta{boolean}}{false} -% \keyline[/.style=]{bar label inline anchor}{\meta{anchor}}{anchor=north} -% \keyline{bar label shape anchor}{\meta{anchor}}{center} -% If two or more chart elements appear in a single line, their labels will overlap at the left border of the chart. Thus, you can place the label adjacent to a bar by setting the boolean key |inline| to |true|. This key instructs the package to draw the label at the |bar label shape anchor| of the chart element and use the anchor given by |bar label inline anchor|. -% \changes{v2.1}{2011/11/10}{The \texttt{inline} key moves labels close to their respective chart elements.} -% \changes{v2.1}{2011/11/10}{Added three keys (\texttt{bar/group/milestone label inline anchor}) for placing inline labels.} +% \keyline{bar inline label anchor}{\meta{anchor}}{center} +% \keyline{group inline label anchor}{\meta{anchor}}{center} +% \keyline{milestone inline label anchor}{\meta{anchor}}{center} +% \keyline[/.style=]{bar inline label node}{\meta{options}}{anchor=center, font=\string\ganttvalueof\{bar label font\}} +% \keyline[/.style=]{group inline label node}{\meta{options}}{anchor=south, font=\string\ganttvalueof\{group label font\}} +% \keyline[/.style=]{milestone inline label node}{\meta{options}}{anchor=south, font=\string\ganttvalueof\{milestone label font\}} +% If two or more chart elements appear in a single line, their labels will overlap at the left border of the chart. Thus, you can place the label adjacent to a chart element by setting the boolean key \opt{inline} to |true|. This key instructs the package to draw the label node at the \opt{\dots\ inline label anchor} of the respective chart element and apply the \meta{options} given by \opt{\dots\ inline label node}. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, inline]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% inline, +% milestone inline label node/.append style={left=5mm} +% ]{1}{12} % \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{1}{3} -% \ganttbar[bar label inline anchor/.style=above]{Task 2}{5}{10} \\ -% \ganttbar[bar label shape anchor=left,% -% bar label inline anchor/.style=right]{Task 3}{2}{7} -% \ganttbar[inline=false]{Final task}{11}{12} +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar{Task 1}{1}{3} \\ +% \ganttbar{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, inline]{12} -% \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{1}{3} -% \ganttbar[bar label inline anchor/.style=above]{Task 2}{5}{10} \\ -% \ganttbar[bar label shape anchor=left,% -% bar label inline anchor/.style=right]{Task 3}{2}{7} -% \ganttbar[inline=false]{Final task}{11}{12} -% \end{ganttchart} -% \end{center} -% Valid \meta{anchor}s for |bar label shape anchor| are \texttt{center}, \texttt{lower left}, \texttt{left}, \texttt{upper left}, \texttt{lower right}, \texttt{right} and \texttt{upper right}. -% \begin{center} -% \begin{ganttchart}[vgrid, hgrid, x unit=1cm, y unit chart=3cm]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% inline, +% milestone inline label node/.append style={left=5mm} +% ]{1}{12} % \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{4}{9} -% \fill [red!0!blue] (elem0.lower left) circle [radius=1.5pt] node [below left] {\texttt{lower left}}; -% \fill [red!20!blue] (elem0.left) circle [radius=1.5pt] node [left] {\texttt{left}}; -% \fill [red!40!blue] (elem0.upper left) circle [radius=1.5pt] node [above left] {\texttt{upper left}}; -% \fill [red!60!blue] (elem0.upper right) circle [radius=1.5pt] node [above right] {\texttt{upper right}}; -% \fill [red!80!blue] (elem0.right) circle [radius=1.5pt] node [right] {\texttt{right}}; -% \fill [red!100!blue] (elem0.lower right) circle [radius=1.5pt] node [below right] {\texttt{lower right}}; -% \fill [black] (elem0.center) circle [radius=1.5pt] node [above] {\texttt{center}}; +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar{Task 1}{1}{3} \\ +% \ganttbar{Task 2}{4}{10} \\ +% \ganttmilestone{Milestone 1}{11} % \end{ganttchart} % \end{center} % \end{key} -% +% +% +% \subsubsection{Options: Chart Element Positioning} +% % \begin{key}{bar left shift}{\meta{factor}}{0} % \keyline{bar right shift}{\meta{factor}}{0} -% \keyline{bar top shift}{\meta{factor}}{0.3} -% \keyline{bar height}{\meta{factor}}{0.4} -% The first three keys shift the coordinates of a bar's borders (or rather of its corners), while |bar height| changes its height. By default, the left upper corner of a bar is 0.3 units below the origin of the start time slot; its right lower corner touches the right border of the end time slot $0.4$ units below the upper line border: -% +% \keyline{bar top shift}{\meta{factor}}{.3} +% \keyline{bar height}{\meta{factor}}{.4} +% \keyline{group left shift}{\meta{factor}}{-.1} +% \keyline{group right shift}{\meta{factor}}{.1} +% \keyline{group top shift}{\meta{factor}}{.4} +% \keyline{group height}{\meta{factor}}{.2} +% \keyline{milestone left shift}{\meta{factor}}{.6} +% \keyline{milestone right shift}{\meta{factor}}{.4} +% \keyline{milestone top shift}{\meta{factor}}{.3} +% \keyline{milestone height}{\meta{factor}}{.4} +% Shift the coordinates of a chart element's borders (\opt{\dots\ shift}) and change its height (\opt{\dots\ height}). +% % \begin{center} % \begin{tikzpicture}[x=.5cm, y=1cm] -% \begin{ganttchart}[vgrid, hgrid]{8} +% \begin{ganttchart}[vgrid, hgrid]{1}{8} % \gantttitle{Title}{8} \\ -% \ganttbar{}{2}{7} \\ -% \ganttbar{}{8}{8} +% \ganttbar{}{2}{7} \\ \\ +% \ganttgroup{}{2}{6} \\ \\ +% \ganttmilestone{}{4} % \end{ganttchart} % \small % \draw[blue, line width=1.5pt, dashed] (1,-1) rectangle (2,-2); +% \draw[blue, line width=1.5pt, dashed] (1,-3) rectangle (2,-4); +% \draw[blue!50!teal, line width=1.5pt, dashed] (3,-5) rectangle (4,-6); % \draw[teal, line width=1.5pt, dashed] (6,-1) rectangle (7,-2); +% \draw[teal, line width=1.5pt, dashed] (5,-3) rectangle (6,-4); % \fill[black!75] (1,-1) circle (1.5pt) node[above left] {$(1, 1)$}; -% \fill[black!75] (7,-2) circle (1.5pt) node[below left] {$(7, 2)$}; -% \fill[red] (1,-1.3) circle (1.5pt) node[left=1pt] {start: $(1, 1+0.3)$}; -% \fill[red] (7,-1.7) circle (1.5pt) node[right=-1pt] {$(7, 1+0.3+0.4)$: stop}; +% \fill[black!75] (7,-2) circle (1.5pt) node[below right] {$(7, 2)$}; +% \fill[black!75] (1,-3) circle (1.5pt) node[above left] {$(1, 3)$}; +% \fill[black!75] (6,-4) circle (1.5pt) node[below right] {$(6, 4)$}; +% \fill[black!75] (3,-5) circle (1.5pt) node[above left] {$(3, 5)$}; +% \fill[black!75] (4,-6) circle (1.5pt) node[below right] {$(4, 6)$}; +% \fill[red] (1,-1.3) circle (1.5pt) node[left] {start: $(1+0, 1+0.3)$}; +% \fill[red] (7,-1.7) circle (1.5pt) node[right] {$(7+0, 1+0.3+0.4)$: stop}; +% \fill[red] (.9,-3.4) circle (1.5pt) node[left] {start: $(1-0.1, 3+0.4)$}; +% \fill[red] (6.1,-3.6) circle (1.5pt) node[right] {$(6+0.1, 3+0.4+0.2)$: stop}; +% \fill[red] (3.6,-5.3) circle (1.5pt) node[left] {start: $(3+0.6, 5+0.3)$}; +% \fill[red] (4.4,-5.7) circle (1.5pt) node[right] {$(4+0.4, 5+0.3+0.4)$: stop}; % \draw[-latex,blue] (.2,.2) node[above=-4pt] {Start time slot (2)} -- (1.5,-1.3); +% \draw[-latex,blue] (-3,-4) node[below=-4pt] {Start time slot (2)} -- (1,-3.8); +% \draw[-latex,blue!50!teal] (-.5,-5.9) node[left] {Time slot (4)} -- (3,-5.8); % \draw[-latex,teal] (7.2,.1) node[above=-4pt] {End time slot (7)} -- (6.5,-1.3); +% \draw[-latex,teal] (8,-4.2) node[right] {End time slot (6)} -- (6,-3.8); % \end{tikzpicture} % \end{center} -% The figure below shows a Gantt chart with two lines and one (large) time slot and indicates the distances modified by these keys. +% +% The three following figures illustrate the distances modified by these keys. The first figure shows a Gantt chart with a bar, two lines and one time slot. % \begin{center} % \begin{tikzpicture}[x=8cm, y=2cm] -% \begin{ganttchart}[x unit=8cm,y unit chart=2cm,bar left shift=.2,bar right shift=-.3,bar top shift=.25, bar height=.5]{1} -% \ganttbar[bar/.style={line width=1.5pt,fill=yellow!10}]{}{1}{1} \\ +% \begin{ganttchart}[ +% x unit=8cm, +% y unit chart=2cm, +% bar left shift=.2, +% bar right shift=-.3, +% bar top shift=.25, +% bar height=.5, +% bar/.append style={line width=1.5pt, fill=yellow!10} +% ]{1}{1} +% \ganttbar[]{}{1}{1} \\ % \end{ganttchart} % \small % \draw[densely dashed] (0,-1) -- (1,-1); @@ -1117,151 +1607,21 @@ % (.6, -.25) -- (.6,-.75) node[align=left,below] {\texttt{bar height}\\(here: \texttt{0.5})}; % \end{tikzpicture} % \end{center} -% For example, you might devise a layout with small, rounded bars that do not touch the borders of their start and end time slots. -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart}[vgrid, bar/.style={fill=red, rounded corners=3pt}, -% bar left shift=.15, bar right shift=-.15, -% bar top shift=.4, bar height=.2]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{2} \\ -% \ganttbar{Task 2}{3}{7} -% \end{ganttchart} -% \end{texcode} -% \begin{center} -% \begin{ganttchart}[vgrid, bar/.style={fill=red, rounded corners=3pt}, -% bar left shift=.15, bar right shift=-.15, -% bar top shift=.4, bar height=.2]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{2} \\ -% \ganttbar{Task 2}{3}{7} -% \end{ganttchart} -% \end{center} -% \end{key} -% -% -% \subsection{Groups} -% -% \textit{Groups} combine several subtasks (represented by bars) into a single task. -% \begin{texcode} -% \ganttgroup`\oarg{options}\marg{label}\marg{start time slot}\marg{end time slot}' -% \end{texcode} -% The \DescribeMacro{\ganttgroup}|\ganttgroup| macro draws a group from the \meta{start time slot} to the \meta{end time slot} and adds a \meta{label} at the left of the chart. Note that a group will start at the left border of the \meta{start time slot} (and not at the right, as it would if the \meta{start time slot} were strictly interpreted as an $x$-coordinate). However, setting |time slot modifier| to zero changes this behavior (see section~\ref{ssc:bars}). -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtask 1}{1}{3} \\ -% \ganttbar{Subtask 2}{4}{10} -% \end{ganttchart} -% \end{texcode} -% \begin{center} -% \begin{ganttchart}[vgrid, hgrid]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtask 1}{1}{3} \\ -% \ganttbar{Subtask 2}{4}{10} -% \end{ganttchart} -% \end{center} -% -% \begin{key}[/.style=]{group}{\meta{style}}{fill=black} -% Changes the appearance of a group. -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart} -% [vgrid, hgrid, -% group/.style={draw=black, fill=green!50}]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtasks}{1}{3} -% \ganttbar{}{5}{10} -% \end{ganttchart} -% \end{texcode} -% \begin{center} -% \begin{ganttchart} -% [vgrid, hgrid, -% group/.style={draw=black, fill=green!50}]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtasks}{1}{3} -% \ganttbar{}{5}{10} -% \end{ganttchart} -% \end{center} -% \end{key} -% -% \begin{key}{group label text}{\meta{text}}{\string\strut\#1} -% \keyline{group label font}{\meta{font commands}}{\string\normalsize\string\bfseries} -% \keyline[/.style=]{group label anchor}{\meta{anchor}}{anchor=east} -% \keyline[/.style=]{group label inline anchor}{\meta{anchor}}{anchor=north} -% \keyline{group label shape anchor}{\meta{anchor}}{center} -% The |group label text| key configures the label \meta{text} next to each group. This key should contain a single parameter token (|#1|), which is replaced by the first mandatory argument of |\ganttgroup|. The |\strut| in the standard value ensures equal vertical spacing of the labels. |group label font| selects the font of the group label, |group label anchor| determines its anchor. The last control sequence in \meta{font commands} may take a single argument (like |\textit|).\par -% The |inline| key moves the label to the |group label shape anchor| of the group, using the anchor given by |group label inline anchor|. For the former key, you may use the same values as for |bar label shape anchor| (see section~\ref{ssc:bars}).\changes{v1.1}{2011/04/18}{\texttt{group label text} configures the text of a group label.}\changes{v3.0}{2012/01/25}{The \texttt{bar/group/milestone label shape anchor} keys allow for a fine-tuned placement of chart element labels.} - - -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid, -% group label font={\fcolorbox{brown}{brown!10}}, -% group label anchor/.style={left=1cm}, -% group label text={+#1+}]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtask 1}{1}{3} -% \ganttgroup[inline, group label inline anchor/.style=above left,% -% group label shape anchor=right]{Subgroup}{5}{10} \\ -% \ganttbar{More Subtasks}{5}{7} -% \ganttbar{}{9}{10} -% \end{ganttchart} -% \end{texcode} -% \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, -% group label font={\fcolorbox{brown}{brown!10}}, -% group label anchor/.style={left=1cm}, -% group label text={+#1+}]{12} -% \gantttitle{Title}{12} \\ -% \ganttgroup{Group}{1}{10} \\ -% \ganttbar{Subtask 1}{1}{3} -% \ganttgroup[inline, group label inline anchor/.style=above left,% -% group label shape anchor=right]{Subgroup}{5}{10} \\ -% \ganttbar{More Subtasks}{5}{7} -% \ganttbar{}{9}{10} -% \end{ganttchart} -% \end{center} -% \end{key} -% -% \begin{key}{group left shift}{\meta{factor}}{-0.1} -% \keyline{group right shift}{\meta{factor}}{0.1} -% \keyline{group top shift}{\meta{factor}}{0.4} -% \keyline{group height}{\meta{factor}}{0.2} -% The first three keys shift the coordinates of a group's borders (or rather of its corners), while |group height| changes its height. By default, the left upper corner of a group is 0.1 units left of and 0.4 units below the start time slot origin; its right lower corner (not counting the peak) lies 0.1 units right of and 0.3 units below the right border of the end time slot: -% -% \begin{center} -% \begin{tikzpicture}[x=.5cm, y=1cm] -% \begin{ganttchart}[vgrid, hgrid]{8} -% \gantttitle{Title}{8} \\ -% \ganttgroup{}{2}{6} \\ -% \ganttbar{}{2}{2} -% \ganttbar{}{4}{6} -% \end{ganttchart} -% \small -% \draw[blue, line width=1.5pt, dashed] (1,-1) rectangle (2,-2); -% \draw[teal, line width=1.5pt, dashed] (5,-1) rectangle (6,-2); -% \fill[black!75] (1,-1) circle (1.5pt) node[above left] {$(1, 1)$}; -% \fill[black!75] (6,-2) circle (1.5pt) node[below right] {$(6, 2)$}; -% \fill[red] (.9,-1.4) circle (1.5pt) node[left] {start: $(1-0.1, 1+0.4)$}; -% \fill[red] (6.1,-1.6) circle (1.5pt) node[right] {$(6+0.1, 1+0.4+0.2)$: stop}; -% \draw[-latex,blue] (.2,.2) node[above=-4pt] {Start time slot (2)} -- (1.5,-1); -% \draw[-latex,teal] (6.2,.1) node[above=-4pt] {End time slot (6)} -- (5.5,-1); -% \end{tikzpicture} -% \end{center} -% The figure below shows a Gantt chart with two lines and one (large) time slot and indicates the distances modified by these keys. +% The second one shows a Gantt chart with a group, two lines and one time slot. % \begin{center} % \begin{tikzpicture}[x=7cm, y=2cm] -% \begin{ganttchart}[x unit=7cm,y unit chart=2cm,group left shift=.2,group right shift=-.3,group top shift=.25, group height=.3,group peaks={.05}{.1}{.2}]{1} -% \ganttgroup[group/.style={draw=black,line width=1.5pt,fill=yellow!10}]{}{1}{1} \\ +% \begin{ganttchart}[ +% x unit=7cm, +% y unit chart=2cm, +% group left shift=.2, +% group right shift=-.3, +% group top shift=.25, +% group height=.3, +% group peaks width=.1, +% group peaks height=.2, +% group/.append style={draw=black, line width=1.5pt, fill=yellow!10} +% ]{1}{1} +% \ganttgroup{}{1}{1} \\ % \end{ganttchart} % \small % \draw[densely dashed] (0,-1) -- (1,-1); @@ -1281,272 +1641,527 @@ % (.55, -.25) -- (.55,-.55) node[align=left,below left=0pt and -10pt] {\texttt{group height}\\(here: \texttt{0.3})}; % \end{tikzpicture} % \end{center} -% \end{key} -% -% \begin{key}{group left peak}{\marg{tip x}\marg{groove x}\marg{tip y}}{} -% \keyline{group right peak}{\marg{tip x}\marg{groove x}\marg{tip y}}{} -% \keyline{group peaks}{\marg{tip x}\marg{groove x}\marg{tip y}}{0.2 0.4 0.1} -% These keys govern the appearance of the peaks at both ends of a group. By default, the tip of each peak lies 0.2 units inward from a group's bottom corner and 0.1 units beneath, while the groove lies 0.4 units inward. While |group left peak| applies only to the left peak and |group right peak| affects only the right peak, |group peaks| sets the dimensions for both peaks simultaneously. You always have to specify three arguments for these keys. However, if you leave one of them blank, the corresponding space parameter retains its current value. -% -% The figure below exemplifies the space parameters as they apply to the left peak. +% The third one shows a Gantt chart with a milestone, two lines and two time slots. % \begin{center} -% \begin{tikzpicture}[x=8cm, y=2cm] +% \begin{tikzpicture}[x=4cm, y=2cm] +% \begin{ganttchart}[ +% x unit=4cm, +% y unit chart=2cm, +% milestone left shift=.2, +% milestone right shift=-.4, +% milestone top shift=.15, +% milestone height=.7, +% milestone/.append style={draw=black, line width=1.5pt, fill=yellow!10} +% ]{1}{2} +% \ganttmilestone{}{1} \\ +% \end{ganttchart} % \small -% \draw (0,0) rectangle (1,-1.3); -% \draw[line width=1.5pt, dashed] (.5,-.2) -- (.7,-.2); -% \draw[line width=1.5pt, solid] (.5,-.2) -- (.2,-.2) -- (.2,-.5) -- (.3,-.8) -- (.4,-.5) -- (.5,-.5); -% \draw[line width=1.5pt, dashed] (.5,-.5) -- (.7,-.5); -% \draw[densely dashed] (.2,-.5) -- (.2,-1.3); -% \draw[densely dashed] (.3,-.8) -- (.3,-1.3); -% \draw[densely dashed] (.3,-.8) -- (1,-.8); +% \draw [densely dashed] (0,-1) -- (2,-1); +% \draw [densely dashed] (1,0) -- (1,-2); +% \draw [dashed, cyan, line width=1pt] (1,-.3) -- (1.4, -0.5) -- (1, -0.7) -- (0.6, -0.5) --cycle; +% \draw [cyan,-latex] (1.2,.3) +% node [above left=0pt and -5pt] {Milestone with standard values} +% -- (1.25,-.4); +% \draw [dashdotted] (.2, -.15) -- (1.5, -.15); % \fill (0,0) circle (1.5pt) node[left] {$(0,0)$}; % \fill (0,-1) circle (1.5pt) node[left] {$(0,1)$}; -% \fill (1,0) circle (1.5pt) node[right] {$(1,0)$}; -% \fill (1,-1) circle (1.5pt) node[right] {$(1,1)$}; -% \draw[-latex,line width=1pt,blue] -% (.2, -.5) node[left=-3pt] {\meta{groove x}} -- (.4,-.5); -% \draw[-latex,line width=1pt,teal] -% (.2, -.9) node[left=-3pt] {\meta{tip x}} -- (.3,-.9); -% \draw[-latex,line width=1pt,red] -% (.5, -.5) node[below right] {\meta{tip y}} -- (.5,-.8); +% \fill (1,0) circle (1.5pt) node[above] {$(1,0)$}; +% \fill (1,-1) circle (1.5pt) node[below right] {$(1,1)$}; +% \fill (2,0) circle (1.5pt) node[above right] {$(2,0)$}; +% \fill (2,-1) circle (1.5pt) node[right] {$(2,1)$}; +% \draw [-latex, line width=1pt, blue] (0, -.5) +% node [align=right, left] {\texttt{milestone left shift}\\(here: \texttt{0.2})} +% -- (.2,-.5); +% \draw [latex-, line width=1pt, blue] (0.6, -.5) -- (1,-.5) +% node [align=left, right] {\texttt{milestone right shift}\\(here: \texttt{-0.4})}; +% \draw [-latex, line width=1pt, red] (1.5, 0) +% node [align=left, above right=0pt and -5pt] {\texttt{milestone top shift}\\(here: \texttt{0.15})} +% -- (1.5,-.15); +% \draw [-latex, line width=1pt, red] (.4, -.15) +% node [align=right, above] {\texttt{milestone height}\\(here: \texttt{0.7})} +% -- (.4,-.85); +% \end{tikzpicture} +% \end{center} +% +% \begin{key}{group right peak tip position}{\meta{fraction}}{0.5} +% \keyline{group right peak width}{\meta{factor}}{0.4} +% \keyline{group right peak height}{\meta{factor}}{0.1} +% \keyline{group left peak tip position}{\meta{fraction}}{0.5} +% \keyline{group left peak width}{\meta{factor}}{0.4} +% \keyline{group left peak height}{\meta{factor}}{0.1} +% \keyline{group peaks tip position}{\meta{fraction}}{\textrm{(none)}} +% \keyline{group peaks width}{\meta{factor}}{\textrm{(none)}} +% \keyline{group peaks height}{\meta{factor}}{\textrm{(none)}} +% Change the appearance of the peaks at both ends of a group. By default, both the left and right peak are 0.4~units wide and 0.1~units high, their tips lie between the peak sides. The \opt{group peaks \dots} keys set the dimensions for both peaks simultaneously. The figure below exemplifies the keys that apply to the left peak. +% +% \begin{center} +% \begin{tikzpicture}[x=8cm, y=2cm] +% \small +% \draw (0,0) rectangle (1,-1.3); +% \draw [line width=1.5pt, dashed] (.5,-.2) -- (.7,-.2); +% \draw [line width=1.5pt, solid] (.5,-.2) -- (.2,-.2) -- (.2,-.5) -- (.3,-.8) -- (.4,-.5) -- (.5,-.5); +% \draw [line width=1.5pt, dashed] (.5,-.5) -- (.7,-.5); +% \draw [densely dashed] (.2,-.5) -- (.2,-1.3); +% \draw [densely dashed] (.3,-.8) -- (.3,-1.3); +% \draw [densely dashed] (.3,-.8) -- (1,-.8); +% \fill (0,0) circle (1.5pt) node [left] {$(0,0)$}; +% \fill (0,-1) circle (1.5pt) node [left] {$(0,1)$}; +% \fill (1,0) circle (1.5pt) node [right] {$(1,0)$}; +% \fill (1,-1) circle (1.5pt) node [right] {$(1,1)$}; +% \draw [-latex, line width=1pt, blue] (.2, -.5) +% node [left] {\texttt{width}} +% -- (.4,-.5); +% \draw [-latex, line width=1pt, teal] (.2, -.9) -- (.3,-.9) +% node [below, align=left] {\texttt{tip position}\\(as fraction of \texttt{width})}; +% \draw [-latex, line width=1pt, red] (.5, -.5) +% node [below right] {\texttt{height}} -- (.5,-.8); % \end{tikzpicture} % \end{center} % \end{key} -% -% For example, you might prefer that your groups stay within the start and end time slot, and that the peaks are more acute: +% +% For example, you might devise the following layout: Bars are small and rounded; they do not touch the borders of their start and end time slots. Groups stay within the start and end time slot, and the peaks are more acute. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, group left shift=0, group right shift=0, -% group peaks={0}{}{.4}]{7} +% \begin{ganttchart}[ +% vgrid, +% bar/.append style={fill=red, rounded corners=3pt}, +% bar left shift=.15, +% bar right shift=-.15, +% bar top shift=.4, +% bar height=.2, +% group left shift=0, +% group right shift=0, +% group peaks tip position=0, +% group peaks height=.4 +% ]{1}{7} % \gantttitle{Title}{7} \\ -% \ganttgroup{Group}{1}{7} \\ -% \ganttbar{Tasks}{1}{2} -% \ganttbar{}{4}{7} +% \ganttgroup{Group 1}{1}{7} \\ +% \ganttbar{Task 1}{1}{2} \\ +% \ganttbar{Task 2}{3}{7} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, group left shift=0, group right shift=0, -% group peaks={0}{}{.4}]{7} +% \begin{ganttchart}[ +% vgrid, +% bar/.append style={fill=red, rounded corners=3pt}, +% bar left shift=.15, +% bar right shift=-.15, +% bar top shift=.4, +% bar height=.2, +% group left shift=0, +% group right shift=0, +% group peaks tip position=0, +% group peaks height=.4 +% ]{1}{7} % \gantttitle{Title}{7} \\ -% \ganttgroup{Group}{1}{7} \\ -% \ganttbar{Tasks}{1}{2} -% \ganttbar{}{4}{7} +% \ganttgroup{Group 1}{1}{7} \\ +% \ganttbar{Task 1}{1}{2} \\ +% \ganttbar{Task 2}{3}{7} % \end{ganttchart} % \end{center} -% -% -% \subsection{Progress Bars and Progress Groups} -% -% \textit{Progress bars} and \textit{progress groups} illustrate the extent to which a (sub-)task has been completed. In order to draw a progress element, you simply specify the |progress| key in the optional argument to the respective standard macro. +% \end{key} +% +% +% \subsubsection{Options: Progress} % -% \begin{key}{progress}{\texttt{none}/\meta{number}}{none} -% \keyline[/.style=]{bar incomplete}{\meta{style}}{} -% \keyline[/.style=]{group incomplete}{\meta{style}}{} -% \keyline[/.style=]{incomplete}{\meta{style}}{fill=black!25} -% The |progress| key specifies that a task (represented by a bar) or a group thereof is \meta{number} percent complete. Starting from the left, \meta{number} percent of the element's area appear in the basic style (i.\,e., |bar| or |group|), while the |bar incomplete| and |group incomplete| keys, respectively, determine the appearance of the remainder. For convenience, the |incomplete| key simultaneously sets the incomplete style for bars and groups. +% The \textit{progress} of a chart element illustrates the extent to which this element has been completed. +% +% \begin{key}{progress}{\texttt{none}\space\textbar\space\texttt{today}\space\textbar\space\meta{number}}{none} +% Indicates that a chart element is \meta{number} percent complete. The value \texttt{none} turns progress calculations off. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid, bar/.style={fill=green},% -% incomplete/.style={fill=red}]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttgroup[progress=45]{Group 1}{1}{12} \\ % \ganttbar[progress=100]{Subtask 1}{1}{3} \\ -% \ganttbar[progress=37, bar incomplete/.style={fill=yellow}]% -% {Subtask 2}{4}{8} \\ -% \ganttbar[progress=10]{Subtask 3}{9}{12} +% \ganttbar[progress=37]{Subtask 2}{4}{8} \\ +% \ganttbar[progress=none]{Subtask 3}{9}{12} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, bar/.style={fill=green},% -% incomplete/.style={fill=red}]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttgroup[progress=45]{Group 1}{1}{12} \\ % \ganttbar[progress=100]{Subtask 1}{1}{3} \\ -% \ganttbar[progress=37, bar incomplete/.style={fill=yellow}]% -% {Subtask 2}{4}{8} \\ -% \ganttbar[progress=10]{Subtask 3}{9}{12} +% \ganttbar[progress=37]{Subtask 2}{4}{8} \\ +% \ganttbar[progress=none]{Subtask 3}{9}{12} % \end{ganttchart} % \end{center} -% \end{key} -% -% \begin{key}{progress label text}{\meta{text}}{\#1\string\% complete} -% \keyline{progress label font}{\meta{font commands}}{\string\scriptsize} -% \keyline[/.style=]{progress label anchor}{\meta{anchor}}{anchor=west} -% The |progress label text| key sets the \meta{text} that appears beside each progress element in order to indicate its completeness. This key may contain a single parameter token (|#1|), which is replaced by the value of |progress|. The label is typeset in the |progress label font|. In addition, |progress label anchor| governs its placement. By changing the default value, you may prevent the label from overlapping with other elements of your chart. -% \par\bigskip\noindent +% The value \texttt{today} instructs \pack{pgfgantt} to calculate progress according to the value of the \opt{today} key. Thus, if the current date $T$ is earlier than the start date $S$ of a chart element, its progress is 0\,\%; if the current date is later than the end date $E$ of a chart element, its progress is 100\,\%; otherwise, its progress $P$ is calculated according to +% \begin{equation} +% P = \frac{T - S}{E - S} \times 100\,\% +% \end{equation} +% \par\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, bar/.style={fill=green}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% time slot format=little-endian, +% progress=today, +% today=4.5.13 +% ]{1.5.13}{12.5.13} % \gantttitle{Title}{12} \\ -% \ganttgroup% -% [progress=45, progress label anchor/.style={below=3pt}]% -% {Group 1}{1}{10} \\ -% \ganttbar% -% [progress=100, progress label font=\color{green!25!black}\textsf]% -% {Subtask 1}{1}{3} \\ -% \ganttbar% -% [progress=10, incomplete/.style={fill=red}, -% progress label text={$\displaystyle\frac{#1}{100}$}]% -% {Subtask 2}{4}{10} +% \ganttgroup{Group 1}{1.5.13}{12.5.13} \\ +% \ganttbar{Subtask 1}{1.5.13}{3.5.13} \\ +% \ganttbar{Subtask 2}{4.5.13}{8.5.13} \\ +% \ganttbar{Subtask 3}{9.5.13}{12.5.13} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, bar/.style={fill=green}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% time slot format=little-endian, +% progress=today, +% today=4.5.13 +% ]{1.5.13}{12.5.13} % \gantttitle{Title}{12} \\ -% \ganttgroup% -% [progress=45, progress label anchor/.style={below=3pt}]% -% {Group 1}{1}{10} \\ -% \ganttbar% -% [progress=100, progress label font=\color{green!25!black}\textsf]% -% {Subtask 1}{1}{3} \\ -% \ganttbar% -% [progress=10, incomplete/.style={fill=red}, -% progress label text={$\displaystyle\frac{#1}{100}$}]% -% {Subtask 2}{4}{10} +% \ganttgroup{Group 1}{1.5.13}{12.5.13} \\ +% \ganttbar{Subtask 1}{1.5.13}{3.5.13} \\ +% \ganttbar{Subtask 2}{4.5.13}{8.5.13} \\ +% \ganttbar{Subtask 3}{9.5.13}{12.5.13} % \end{ganttchart} % \end{center} % \end{key} -% -% -% \subsection{Milestones} -% -% A \textit{milestone} signifies that an important task has been completed or that a crucial goal has been reached. -% \begin{texcode} -% \ganttmilestone`\oarg{options}\marg{label}\marg{time slot}' -% \end{texcode} -% The \DescribeMacro{\ganttmilestone}|\ganttmilestone| macro draws a milestone at the given \meta{time slot} and adds a \meta{label} at the left of the chart. +% +% \begin{key}[/.style=]{bar incomplete}{\meta{style}}{/pgfgantt/bar, fill=black!25} +% \keyline[/.style=]{group incomplete}{\meta{style}}{/pgfgantt/group, fill=black!25} +% \keyline[/.style=]{milestone incomplete}{\meta{style}}{/pgfgantt/milestone, fill=black!25} +% If $P$ is the progress of a chart element, $P\,\%$ of its area (starting from the left) appear in the basic style (i.\,e., \opt{bar}, \opt{group}, \dots), while the remainder is drawn in style \opt{bar incomplete}, \opt{group incomplete} etc. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{4} \\ -% \ganttmilestone{Milestone}{4} \\ -% \ganttbar{Task 2}{5}{7} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% time slot format=isodate, +% today=2013-04-06, +% progress=today, +% bar/.append style={fill=green}, +% bar incomplete/.append style={fill=red}, +% group incomplete/.append style={draw=black,fill=none} +% ]{2013-04-01}{2013-04-12} +% \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{2013-04-01}{2013-04-12} \\ +% \ganttbar{Subtask 1}{2013-04-01}{2013-04-03} \\ +% \ganttbar{Subtask 2}{2013-04-04}{2013-04-08} \\ +% \ganttbar{Subtask 3}{2013-04-09}{2013-04-12} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{4} \\ -% \ganttmilestone{Milestone}{4} \\ -% \ganttbar{Task 2}{5}{7} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% time slot format=isodate, +% today=2013-04-06, +% progress=today, +% bar/.append style={fill=green}, +% bar incomplete/.append style={fill=red}, +% group incomplete/.append style={draw=black,fill=none} +% ]{2013-04-01}{2013-04-12} +% \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{2013-04-01}{2013-04-12} \\ +% \ganttbar{Subtask 1}{2013-04-01}{2013-04-03} \\ +% \ganttbar{Subtask 2}{2013-04-04}{2013-04-08} \\ +% \ganttbar{Subtask 3}{2013-04-09}{2013-04-12} % \end{ganttchart} % \end{center} -% Note that the milestone is usually centered on the vertical grid line between its \meta{time slot} and the following one. -% -% \begin{key}[/.style=]{milestone}{\meta{style}}{fill=black} -% Determines the appearance of the milestone. +% \end{key} +% +% \begin{key}{progress label text}{\meta{text}}{\string\pgfmathprintnumber[precision=0, verbatim]\{\#1\}\string\% complete} +% \keyline{bar progress label anchor}{\meta{anchor}}{east} +% \keyline{bar progress label font}{\meta{font commands}}{\string\scriptsize} +% \keyline[/.style=]{bar progress label node}{\meta{options}}{anchor=west, font=\string\ganttvalueof\{bar progress label font\}} +% \keyline{group progress label anchor}{\meta{anchor}}{east} +% \keyline{group progress label font}{\meta{font commands}}{\string\scriptsize} +% \keyline[/.style=]{group progress label node}{\meta{options}}{anchor=west, font=\string\ganttvalueof\{group progress label font\}} +% \keyline{milestone progress label anchor}{\meta{anchor}}{center} +% \keyline{milestone progress label font}{\meta{font commands}}{\string\scriptsize} +% \keyline[/.style=]{milestone progress label node}{\meta{options}}{anchor=west, font=\string\ganttvalueof\{milestone progress label font\}} +% The \opt{progress label text} key sets the \meta{text} that appears beside each progress element in order to indicate its completeness. This key may contain a single parameter token (|#1|), which is replaced by the (possibly calculated) value of \opt{progress}. The progress label node is drawn at the \opt{\dots\ progress label anchor} of the respective chart element, with the \meta{font commands} given by \opt{\dots\ progress label font} and the \meta{options} given by \opt{\dots\ progress label node}. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid, -% milestone/.style={fill=orange, draw=black, rounded corners=3pt}]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{5} \\ -% \ganttmilestone{Milestone}{5} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar/.append style={fill=green}, +% bar incomplete/.append style={fill=red}, +% progress=today, +% today=6, +% group progress label node/.append style={below=3pt} +% ]{1}{12} +% \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar[ +% bar progress label font=\color{green!25!black}\sffamily +% ]{Subtask 1}{1}{3} \\ +% \ganttbar[ +% progress label text={$\displaystyle\frac{#1}{100}$} +% ]{Subtask 2}{5}{12} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, -% milestone/.style={fill=orange, draw=black, rounded corners=3pt}]{7} -% \gantttitle{Title}{7} \\ -% \ganttbar{Task 1}{1}{5} \\ -% \ganttmilestone{Milestone}{5} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% bar/.append style={fill=green}, +% bar incomplete/.append style={fill=red}, +% progress=today, +% today=6, +% group progress label node/.append style={below=3pt} +% ]{1}{12} +% \gantttitle{Title}{12} \\ +% \ganttgroup{Group 1}{1}{10} \\ +% \ganttbar[ +% bar progress label font=\color{green!25!black}\sffamily +% ]{Subtask 1}{1}{3} \\ +% \ganttbar[ +% progress label text={$\displaystyle\frac{#1}{100}$} +% ]{Subtask 2}{5}{12} % \end{ganttchart} % \end{center} % \end{key} -% -% \begin{key}{milestone label text}{\meta{text}}{\string\strut\#1} -% \keyline{milestone label font}{\meta{font commands}}{\string\normalsize\string\itshape} -% \keyline[/.style=]{milestone label anchor}{\meta{anchor}}{anchor=east} -% \keyline[/.style=]{milestone label inline anchor}{\meta{anchor}}{anchor=south} -% \keyline{milestone label shape anchor}{\meta{anchor}}{center} -% The |milestone label text| key configures the label \meta{text} next to each milestone. This key should contain a single parameter token (|#1|), which is replaced by the first mandatory argument of |\ganttmilestone|. The |\strut| in the standard value ensures equal vertical spacing of the labels. |milestone label font| sets the font of the milestone label, while |milestone label anchor| determines its placement. The last macro in \meta{font commands} may take a single argument, as we show in the following (somewhat silly) example.\par -% The |inline| key moves the label to the |milestone label shape anchor| of the milestone, using the \meta{anchor} given by |milestone label inline anchor|. For the former key, you may use the same values as for |bar label shape anchor| (see section~\ref{ssc:bars}). \changes{v1.1}{2011/04/18}{\texttt{milestone label text} configures the text of a milestone label.} -% \par\bigskip\noindent -% \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid]{10} -% \gantttitle{Title}{10} \\ -% \ganttbar{Task 1}{1}{5} \\ -% \ganttmilestone% -% [milestone label font=\color{magenta}\rotatebox{30}, -% milestone label text={#1 !!!}]{Milestone}{5} -% \ganttmilestone[inline]{2nd}{7} -% \ganttmilestone% -% [inline, milestone label inline anchor/.style=below]{3rd}{9} -% \end{ganttchart} -% \end{texcode} +% +% +% \subsubsection{New Node Shapes} +% \label{sss:NewNodeShapes} +% +% \pack{pgfgantt} defines three new node shapes: +% +% \bigskip\noindent +% (1) The \texttt{ganttbar} node shape derives from shape \texttt{rectangle} (section~48.2 of the \TikZ\ manual). It provides four additional anchors: \texttt{on top}, \texttt{on bottom}, \texttt{on left} and \texttt{on right}. The \meta{fraction} set by the following keys indicates a position between the left and right (for \texttt{on top} and \texttt{on bottom}) or upper and lower border (for \texttt{on left} and \texttt{on right}), similarly to the \opt{/tikz/pos} key. +% +% \begin{key}{on top fraction}{\meta{fraction}}{0.5} +% \keyline{on bottom fraction}{\meta{fraction}}{0.5} +% \keyline{on left fraction}{\meta{fraction}}{0.5} +% \keyline{on right fraction}{\meta{fraction}}{0.5} +% In the following figures, \opt{on top/bottom fraction} is 0.7, whereas \opt{on left/right fraction} is 0.1. % \begin{center} -% \begin{ganttchart}[vgrid, hgrid]{10} -% \gantttitle{Title}{10} \\ -% \ganttbar{Task 1}{1}{5} \\ -% \ganttmilestone% -% [milestone label font=\color{magenta}\rotatebox{30}, -% milestone label text={#1 !!!}]{Milestone}{5} -% \ganttmilestone[inline]{2nd}{7} -% \ganttmilestone% -% [inline, milestone label inline anchor/.style=below]{3rd}{9} -% \end{ganttchart} +% \begin{tikzpicture} +% \ganttset{ +% on top fraction=.7, +% on bottom fraction=.7, +% on left fraction=.1, +% on right fraction=.1 +% } +% \node[ +% name=s, +% shape=ganttbar, +% color=black!30, +% draw, +% fill=yellow!30, +% line width=.3cm, +% inner xsep=2.5cm, +% inner ysep=0.5cm, +% font=\Huge +% ] {ganttbar\vrule width 1pt height 2cm}; +% \foreach \anchor/\placement in +% {north west/above left, north/above, north east/above right, +% west/left, center/above, east/right, +% mid west/right, mid/above, mid east/left, +% base west/left, base/below, base east/right, +% south west/below left, south/below, south east/below right, +% text/below, 10/right, 130/above} +% \draw [shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; +% \foreach \anchor/\placement in +% {on top/above, on bottom/below, on left/left, on right/right} +% \draw [color=red,shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; +% \end{tikzpicture} % \end{center} % \end{key} -% -% \begin{key}{milestone width}{\meta{factor}}{0.8} -% \keyline{milestone height}{\meta{factor}}{0.4} -% \keyline{milestone xshift}{\meta{factor}}{0} -% \keyline{milestone yshift}{\meta{factor}}{0.5} -% These keys set the width and height of a milestone and shift the coordinates of its center. By default, a milestone is 0.8 units wide and 0.4 units high. Since the ideal $x$-vector/$y$-vector ratio is $1:2$, the milestone appears square with these settings. Its center lies on the right border and 0.5 units below the top border of its time slot. -% +% +% \bigskip\noindent +% (2) The \texttt{ganttgroup} node shape also derives from shape \texttt{rectangle}. It provides the additional anchors \texttt{on top}, \texttt{on bottom}, \texttt{on left}, \texttt{on right} (same as above), \texttt{left peak} and \texttt{right peak}. % \begin{center} -% \begin{tikzpicture}[x=.5cm, y=1cm] -% \begin{ganttchart}[vgrid, hgrid]{7} -% \gantttitle{Title}{7} \\ -% \ganttmilestone{}{4} \\ -% \end{ganttchart} -% \small -% \draw[teal, line width=1.5pt, dashed] (3,-1) rectangle (4,-2); -% \fill[red] (4,-1.5) circle (1.5pt) node[right=7pt] {center: $(4+0, 1+0.5)$}; -% \draw[-latex, teal] (1.8,.2) node[above=-4pt] {Time slot (4)} -- (3.5,-1); +% \begin{tikzpicture} +% \ganttset{ +% group peaks tip position=.5, +% group peaks width=4, +% group peaks height=1, +% on top fraction=.7, +% on bottom fraction=.7, +% on left fraction=.1, +% on right fraction=.1 +% } +% \node[ +% name=s, +% shape=ganttgroup, +% color=black!30, +% draw, +% fill=yellow!30, +% line width=.3cm, +% inner xsep=2.5cm, +% inner ysep=0.5cm, +% font=\Huge +% ] {ganttgroup\vrule width 1pt height 2cm}; +% \foreach \anchor/\placement in +% {north west/above left, north/above, north east/above right, +% west/left, center/above, east/right, +% mid west/right, mid/above, mid east/left, +% base west/left, base/below, base east/right, +% south west/below left, south/below, south east/below right, +% text/below, 10/right, 130/above} +% \draw [shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; +% \foreach \anchor/\placement in +% {on top/above, on bottom/below, on left/left, on right/right, +% left peak/below, right peak/below} +% \draw [color=red,shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; % \end{tikzpicture} % \end{center} -% The figure below shows a Gantt chart with a single milestone and two (large) time slots; it indicates the distances modified by the four keys explained above. +% +% \bigskip\noindent +% (3) The \texttt{ganttmilestone} node shape derives from shape \texttt{diamond} (section~48.3 of the \TikZ\ manual), but does not consider any aspect ratio. It provides the additional anchors \texttt{on top}, \texttt{on bottom}, \texttt{on left} and \texttt{on right} (same as above). % \begin{center} -% \begin{tikzpicture}[x=4cm, y=2cm] -% \begin{ganttchart}[x unit=4cm,y unit chart=2cm,milestone width=0.4, milestone height=0.7, milestone xshift=-.2, milestone yshift=.5]{2} -% \ganttmilestone[milestone/.style={draw=black,line width=1.5pt,fill=yellow!10}]{}{1} \\ -% \end{ganttchart} -% \small -% \draw[densely dashed] (0,-1) -- (2,-1); -% \draw[densely dashed] (1,0) -- (1,-1.7); -% \draw[dashed, cyan, line width=1pt] (1,-.3) -- (1.4, -0.5) -- (1, -0.7) -- (0.6, -0.5) --cycle; -% \draw[cyan,-latex] (.8,.3) node[above] {Milestone with standard values} -- (.75,-.4); -% \draw[dashdotted] (.8, -.5) -- (.8, -1.5); -% \draw[dashdotted] (.8, -.5) -- (1.5, -.5); -% \fill[red] (.8,-.5) circle (1.5pt); -% \fill (0,0) circle (1.5pt) node[left] {$(0,0)$}; -% \fill (0,-1) circle (1.5pt) node[left] {$(0,1)$}; -% \fill (1,0) circle (1.5pt) node[above] {$(1,0)$}; -% \fill (1,-1) circle (1.5pt) node[below right] {$(1,1)$}; -% \fill (2,0) circle (1.5pt) node[above right] {$(2,0)$}; -% \fill (2,-1) circle (1.5pt) node[right] {$(2,1)$}; -% \draw[latex-, line width=1pt, blue] -% (0.8, -1.5) node[align=left, below] {\texttt{milestone xshift}\\(here: \texttt{-0.2})} -- (1,-1.5); -% \draw[-latex, line width=1pt, blue] -% (1.4, 0) -- (1.4,-.5) node[align=left, above right] {\texttt{milestone yshift}\\(here: \texttt{0.5})}; -% \draw[latex-latex, line width=1pt, red] -% (.6, -.9) node[align=left, below=4pt] {\texttt{milestone width}\\(here: \texttt{0.4})} -- (1,-.9); -% \draw[latex-latex, line width=1pt, red] -% (.6, -.15) node[align=right, below left=5pt] {\texttt{milestone height}\\(here: \texttt{0.7})} -- (.6,-.85); +% \begin{tikzpicture} +% \ganttset{ +% on top fraction=.7, +% on bottom fraction=.7, +% on left fraction=.1, +% on right fraction=.1 +% } +% \node[ +% name=s, +% shape=ganttmilestone, +% color=black!30, +% draw, +% fill=yellow!30, +% line width=.3cm, +% inner sep=0.5cm, +% font=\Huge +% ] {ganttmilestone\vrule width 1pt height 1cm}; +% \foreach \anchor/\placement in +% {north west/above left, north/above, north east/above right, +% west/left, center/above, east/right, mid/above, base/below, +% south west/below left, south/below, south east/below right, +% text/left, 10/right, 130/above} +% \draw [shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; +% \foreach \anchor/\placement in +% {on top/above, on bottom/below, on left/left, on right/right} +% \draw [color=red,shift=(s.\anchor)] plot [mark=x] coordinates{(0, 0)} +% node [\placement] {\scriptsize\texttt{(s.\anchor)}}; % \end{tikzpicture} % \end{center} -% \end{key} -% +% +% +% \subsection{Defining Custom Chart Elements} +% +% You may define completely new chart elements with +% \begin{texcode} +% \newganttchartelement`\marg{name}\marg{new default key values}' +% \newganttchartelement*`\marg{name}\marg{new default key values}' +% \end{texcode} +% \DescribeMacro{\newganttchartelement}|\newganttchartelement| (unstarred) defines a new chart element |\gantt|\textcolor{RoyalBlue}{\meta{name}} and the corresponding |\ganttlinked|\textcolor{RoyalBlue}{\meta{name}}. These chart element macros take one optional argument \meta{options} and \textit{three} mandatory arguments \meta{label}, \meta{start tss} and \meta{end tss} (like |\ganttbar|). +% +% Chart element macros defined by the starred form, \DescribeMacro{\newganttchartelement*}|\newganttchartelement*|, take the same single optional argument, but \textit{two} mandatory arguments \meta{label} and \meta{tss} (like |\ganttmilestone|). +% +% For each new chart element, |\newganttchartelement| also introduces a set of nine value-storing keys and five style keys and assigns default values to them: +% \begin{center} +% \begin{tabular}{l >{\ttfamily}l} +% \toprule +% \itshape Key & \rmfamily\itshape Default value \\ +% \midrule +% \multicolumn{2}{l}{\bfseries Style keys} \\ +% \meta{name} & shape=rectangle, inner sep=0pt, draw, fill=white \\ +% \meta{name}\texttt{ incomplete} & /pgfgantt/\textrm{\meta{name}}, fill=black!25 \\ +% \meta{name}\texttt{ label node} & anchor=east, font=\string\ganttvalueof\{\textrm{\meta{name}} label font\} \\ +% \meta{name}\texttt{ inline label node} & anchor=center, font=\string\ganttvalueof\{\textrm{\meta{name}} label font\} \\ +% \meta{name}\texttt{ progress label node} & anchor=west, font=\string\ganttvalueof\{\textrm{\meta{name}} progress label font\} \\ +% \midrule +% \multicolumn{2}{l}{\bfseries Value-storing keys} \\ +% \meta{name}\texttt{ label font} & \string\normalsize \\ +% \meta{name}\texttt{ inline label anchor} & center \\ +% \meta{name}\texttt{ progress label anchor} & east \\ +% \meta{name}\texttt{ progress label font} & \string\scriptsize \\ +% \meta{name}\texttt{ left shift} & 0 \\ +% \meta{name}\texttt{ right shift} & 0 \\ +% \meta{name}\texttt{ top shift} & .3 \\ +% \meta{name}\texttt{ height} & .4 \\ +% \meta{name}\texttt{ label text} & \string\strut\#1 \\ +% \bottomrule +% \end{tabular}\hspace*{-120pt} +% \end{center} +% Consequently, a new chart element will look like the standard |\ganttbar| unless you introduce some \meta{new default key values}. +% +% Let us define a new chart element called ``foobar'', which is basically a fancy-colored and -shaped bar: +% \par\bigskip\noindent +% \begin{texcode} +% \definecolor{foobarblue}{RGB}{0,153,255} +% \definecolor{foobaryellow}{RGB}{234,187,0} +% +% \newganttchartelement{foobar}{ +% foobar/.style={ +% shape=rounded rectangle, +% inner sep=0pt, +% draw=foobarblue!50!black, +% very thick, +% top color=white, +% bottom color=foobarblue!50 +% }, +% foobar incomplete/.style={ +% /pgfgantt/foobar, +% draw=foobaryellow, +% bottom color=foobaryellow!50 +% }, +% foobar label font=\slshape, +% foobar left shift=-.1, +% foobar right shift=.1 +% } +% +% \begin{ganttchart}[ +% vgrid, +% progress=today, +% progress label text=\relax, +% today=6 +% ]{1}{12} +% \gantttitlecalendar{day} \\[grid] +% \ganttfoobar{Foobar 1}{1}{2} \\ +% \ganttfoobar{Foobar 2}{3}{7} \\ +% \ganttlinkedfoobar{Foobar 3}{9}{12} +% \end{ganttchart} +% \end{texcode} +% \begin{center} +% \definecolor{foobarblue}{RGB}{0,153,255} +% \definecolor{foobaryellow}{RGB}{234,187,0} +% +% \newganttchartelement{foobar}{ +% foobar/.style={ +% shape=rounded rectangle, +% inner sep=0pt, +% draw=foobarblue!50!black, +% very thick, +% top color=white, +% bottom color=foobarblue!50 +% }, +% foobar incomplete/.style={ +% /pgfgantt/foobar, +% draw=foobaryellow, +% bottom color=foobaryellow!50 +% }, +% foobar label font=\slshape, +% foobar left shift=-.1, +% foobar right shift=.1 +% } +% +% \begin{ganttchart}[ +% vgrid, +% progress=today, +% progress label text=\relax, +% today=6 +% ]{1}{12} +% \gantttitlecalendar{day} \\[grid] +% \ganttfoobar{Foobar 1}{1}{2} \\ +% \ganttfoobar{Foobar 2}{3}{7} \\ +% \ganttlinkedfoobar{Foobar 3}{9}{12} +% \end{ganttchart} +% \end{center} +% % % \subsection{Links} -% \label{ssc:links} +% \label{ssc:Links} % % So far, we have drawn charts whose elements were quite independent of each other. However, relations or \textit{links} between these elements frequently appear on real Gantt charts. For example, a task may only start if a previous one has been completed, or finishing a task may constitute a milestone. % \begin{texcode} @@ -1554,12 +2169,14 @@ % \end{texcode} % % \begin{key}{name}{\meta{name}}{\textrm{(empty)}} -% The \DescribeMacro{\ganttlink}|\ganttlink| macro connects two elements, which are specified by their \meta{name}s. By default, chart elements are named automatically: The first one receives the name |elem0|, the second one is called |elem1| and so on. However, the |name| key allows you to assign a name to each chart element. +% The \DescribeMacro{\ganttlink}|\ganttlink| macro connects two elements, which are specified by their \meta{name}s. By default, chart elements are named automatically: The first one receives the name \texttt{elem0}, the second one is called \texttt{elem1} and so on. However, the \opt{name} key allows you to assign a name to each chart element. % \par\bigskip\noindent % \begin{minipage}[t]{.44\textwidth} % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{1}{4} \\ % \ganttbar{Task 2}{5}{7} \\ @@ -1571,8 +2188,10 @@ % \end{minipage}\hfill % \begin{minipage}[t]{.44\textwidth} % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar[name=b1]% % {Task 1}{1}{4} \\ @@ -1586,8 +2205,10 @@ % \end{texcode} % \end{minipage} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar[name=b1]% % {Task 1}{1}{4} \\ @@ -1600,14 +2221,16 @@ % \end{ganttchart} % \end{center} % \end{key} -% +% % \begin{key}[/.style=]{link}{\meta{style}}{-latex, rounded corners=1pt} % Sets the appearance of the link. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid, -% link/.style={[-to, line width=1pt, blue}]{7} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link/.style={[-to, line width=1pt, blue} +% ]{1}{7} % \gantttitle{Title}{7} \\ % \ganttbar{Task 1}{1}{4} \\ % \ganttbar{Task 2}{5}{7} @@ -1615,9 +2238,11 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, -% link/.style={[-to, line width=1pt, blue}]{7} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link/.style={[-to, line width=1pt, blue} +% ]{1}{7} % \gantttitle{Title}{7} \\ % \ganttbar{Task 1}{1}{4} \\ % \ganttbar{Task 2}{5}{7} @@ -1627,19 +2252,19 @@ % \end{key} % % \begin{key}{link type}{\meta{type}}{auto} -% Link types fall into several categories:\changes{v3.0}{2012/01/25}{Completely rewrote the code for links (again). Definition of new link types is now possible (via \cs{newganttlinktype} and \cs{newganttlinktypealias}).} +% Link types fall into several categories: % \begin{enumerate}\parskip0pt % \item \textit{Automatic links} are arrow-like. As you can see from the examples above, they consist of three segments (two horizontal, one vertical) if their start and end time slots are sufficiently separated. Otherwise, they comprise five segments (three horizontal, two vertical). Three keys further modify the appearance of automatic links: % % \begin{key}{link mid}{\meta{factor}}{0.5} -% The |link mid| key changes the position of the single vertical segment (in three-part links) or of the middle horizontal segment (in five-part links). By default, these segments are horizontally centered between the left and the right vertical segment, or vertically centered between the upper and the lower horizontal segment, respectively.\par\bigskip +% Changes the position of the single vertical segment (in three-part links) or of the middle horizontal segment (in five-part links). By default, these segments are horizontally centered between the left and the right vertical segment, or vertically centered between the upper and the lower horizontal segment, respectively.\par\bigskip % \keyline{link bulge}{\meta{factor}}{0.4} -% In five-part links, the upper and lower vertical segments are shifted along the $x$-axis by $+$|link bulge| and $-$|link bulge|, respectively.\par\bigskip +% In five-part links, the upper and lower vertical segments are shifted along the $x$-axis by $+$\meta{factor} and $-$\meta{factor}, respectively.\par\bigskip % \keyline{link tolerance}{\meta{factor}}{0.6} -% This key governs whether \pack{pgfgantt} draws a five- or a three-part link. If the true $x$-coordinates of the link start and end differ by at least |link tolerance| (this is the case for the second link in the example below), the package draws a five-part link.\changes{v1.1}{2011/04/18}{\texttt{link tolerance} decides whether a five- or a three-part link is drawn.} +% Decides whether \pack{pgfgantt} draws a five- or a three-part link. If the true $x$-coordinates of the link start and end differ by at least \meta{factor} (this is the case for the second link in the example below), the package draws a five-part link. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, link mid=.25, link bulge=1.3]{12} +% \begin{ganttchart}[vgrid, hgrid, link mid=.25, link bulge=1.3]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{1}{4} \\ % \ganttbar{Task 2}{5}{7} \\ @@ -1649,7 +2274,7 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, link mid=.25, link bulge=1.3]{12} +% \begin{ganttchart}[vgrid, hgrid, link mid=.25, link bulge=1.3]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{1}{4} \\ % \ganttbar{Task 2}{5}{7} \\ @@ -1660,10 +2285,14 @@ % \end{center} % \end{key} % -% \item \textit{Straight links} are only meant for connecting two bars in order to establish start-to-finish relations (|s-f|), start-to-start relations (|s-s|) etc. Their \meta{type} identifiers commemorate the syntax for specifying arrow tips in \TikZ: Each identifier is composed of two letters separated by a hyphen. +% \item \textit{Straight links} are only meant for connecting two bars in order to establish start-to-finish relations (\texttt{s-f}), start-to-start relations (\texttt{s-s}) etc. Their \meta{type} identifiers are reminiscent of the syntax for specifying arrow tips in \TikZ: Each identifier is composed of two letters separated by a hyphen. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, link/.style={-latex, red}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link/.style={-latex, draw=red, fill=red} +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{5} \\ @@ -1675,7 +2304,11 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, link/.style={-latex, red}]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link/.style={-latex, draw=red, fill=red} +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{5} \\ @@ -1688,12 +2321,15 @@ % \end{center} % % \item \textit{Custom links} allow you to define completely new link types. Strictly speaking, automatic and straight links are predefined custom links whose code supports the keys mentioned above (section~\ref{ssc:ImplLinks} presents the \TikZ\ code of these links).\par -% For instance, \pack{pgfgantt} provides one additional link type, |dr| (short for ``down-right''). This type is convenient for connecting inline-labeled bars if the label of the start bar protrudes from its right border. +% For instance, \pack{pgfgantt} provides one additional link type, \texttt{dr} (short for ``down-right''). This type is convenient for connecting inline-labeled bars if the label of the start bar protrudes from its right border. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [vgrid, hgrid, inline, -% link/.style={->, ultra thick}]{15} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% inline, +% link/.style={->, ultra thick} +% ]{1}{15} % \gantttitle{Title}{15} \\ % \ganttbar{A really long label}{1}{3} % \ganttbar{Another really long label}{10}{12} \\ @@ -1704,9 +2340,12 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid, inline, -% link/.style={->, ultra thick}]{15} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% inline, +% link/.style={->, ultra thick} +% ]{1}{15} % \gantttitle{Title}{15} \\ % \ganttbar{A really long label}{1}{3} % \ganttbar{Another really long label}{10}{12} \\ @@ -1717,49 +2356,33 @@ % \end{ganttchart} % \end{center} % -% The central macro for creating link types is +% The following macro creates new link types: % \begin{texcode} % \newganttlinktype`\marg{type}\marg{TikZ code}' % \end{texcode} % \DescribeMacro{\newganttlinktype}It defines a new link \meta{type} which is drawn by the given \meta{TikZ code}. When you write this code, you do not have to know the final absolute coordinates of each link type instance. On the contrary, several commands that are only available in the second argument of |\newganttlinktype| help you to design generic link types: % \begin{itemize} -% \item First, you have to choose the border points of the chart elements the link will connect. For this purpose, \DescribeMacro{\ganttsetstartanchor}|\ganttsetstartanchor{|\meta{anchor}|}| and \DescribeMacro{\ganttsetendanchor}|\ganttsetendanchor{|\meta{anchor}|}| select an \meta{anchor} of the start and end element, respectively. Valid \meta{anchor}s are \texttt{lower left}, \texttt{left} etc. (see section~\ref{ssc:bars}) and the special anchors \texttt{on left}, \texttt{on top}, \texttt{on right} and \texttt{on bottom}. You may specify a value between 0 and 1 for each of the latter four anchors (the default value is |0.5|). This fraction indicates a position between the left and right (for \texttt{on top} and \texttt{on bottom}) or upper and lower border (for \texttt{on left} and \texttt{on right}), similarly to the |/tikz/pos| key.\changes{v3.0}{2012/01/25}{New auxiliary macros for \cs{newganttlinkstyle}: \cs{xLeft}, \cs{xRight}, \cs{yUpper}, \cs{yLower}, \cs{ganttsetstartanchor}, \cs{ganttsetendanchor} and \cs{ganttlinklabel}.} -% \begin{center}\makeatletter -% \begin{ganttchart}[vgrid, hgrid, x unit=.9cm, y unit chart=3.2cm]{12} -% \gantttitle{Title}{12} \\ -% \ganttbar[inline]{Task 1}{4}{9} -% \def\@gtt@linkanchorfraction{0.1} -% \fill [red!0!blue] (elem0.on bottom) circle [radius=1.5pt] node [below left] {\texttt{on bottom=0.1}}; -% \def\@gtt@linkanchorfraction{0.4} -% \fill [red!20!blue] (elem0.on bottom) circle [radius=1.5pt] node [below] {\texttt{on bottom=0.4}}; -% \def\@gtt@linkanchorfraction{0.85} -% \fill [red!40!blue] (elem0.on bottom) circle [radius=1.5pt] node [below right] {\texttt{on bottom=0.85}}; -% \def\@gtt@linkanchorfraction{0.15} -% \fill [red!60!blue] (elem0.on right) circle [radius=1.5pt] node [above right] {\texttt{on right=0.15}}; -% \def\@gtt@linkanchorfraction{0.5} -% \fill [red!80!blue] (elem0.on right) circle [radius=1.5pt] node [right] {\texttt{on right=0.5}}; -% \def\@gtt@linkanchorfraction{0.7} -% \fill [red!100!blue] (elem0.on right) circle [radius=1.5pt] node [below right] {\texttt{on right=0.7}}; -% \end{ganttchart} -% \end{center} -% \pack{pgfgantt} sets the default anchors to |\ganttsetstartanchor{right}| and |\ganttsetendanchor{left}|, so you even may omit these two commands. -% \item The two macro pairs |\xLeft|/|\yUpper| and |\xRight|/|\yLower| provide the $x$- and $y$-coordinates of the link start and end points, respectively. +% \item First, you have to choose the border points of the chart elements the link will connect. For this purpose, \DescribeMacro{\ganttsetstartanchor}|\ganttsetstartanchor{|\meta{anchor}|}| and \DescribeMacro{\ganttsetendanchor}|\ganttsetendanchor{|\meta{anchor}|}| select an \meta{anchor} of the start and end element, respectively. See the figures in section~\ref{sss:NewNodeShapes} for possible \meta{anchor}s of the default chart element shapes. You may specify a certain \meta{fraction} for anchors like \texttt{on top} by |\ganttsetstartanchor{on top=|\meta{fraction}|}|. +% +% \pack{pgfgantt} sets the default anchors to |\ganttsetstartanchor{east}| and |\ganttsetendanchor{west}|, so you even may omit these two commands. +% \item The two macro pairs \DescribeMacro{\xLeft}|\xLeft|/\DescribeMacro{\yUpper}|\yUpper| and \DescribeMacro{\xRight}|\xRight|/\DescribeMacro{\yLower}|\yLower| provide the $x$- and $y$-coordinates of the link start and end points, respectively. % \begin{center}\makeatletter -% \begin{ganttchart}[vgrid, hgrid, x unit=.9cm, y unit chart=2cm, link/.style={draw=black!30, ultra thick, ->, rounded corners=5pt}]{12} +% \begin{ganttchart}[vgrid, hgrid, x unit=.9cm, y unit chart=2cm, link/.style={draw=black!30, ultra thick, ->, rounded corners=5pt}]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar[inline]{Task 1}{2}{4} \\ % \ganttbar[inline]{Task 2}{7}{9} % \ganttlink{elem0}{elem1} -% \fill [red!10!blue] (elem0.right) circle [radius=1.5pt] node [above right] {(\texttt{\string\xLeft}, \texttt{\string\yUpper})}; -% \fill [red!90!blue] (elem1.left) circle [radius=1.5pt] node [below left] {(\texttt{\string\xRight}, \texttt{\string\yLower})}; +% \fill [red!10!blue] (elem0.east) circle [radius=1.5pt] node [above right] {(\texttt{\string\xLeft}, \texttt{\string\yUpper})}; +% \fill [red!90!blue] (elem1.west) circle [radius=1.5pt] node [below left] {(\texttt{\string\xRight}, \texttt{\string\yLower})}; % \end{ganttchart} % \end{center} -% \item \DescribeMacro{\ganttlinklabel}|\ganttlinklabel| contains the label that you may assign to each link type via |\setganttlinklabel| or the |link label| key (see below). -% \item You can access any values stored in the package's \meta{key}s with the macro \DescribeMacro{\ganttvalueof}|\ganttvalueof{|\meta{key}|}|. -% \item Remember that you can use the style |/pgfgantt/link| to ensure a uniform appearance of all your link types. +% \item \DescribeMacro{\ganttlinklabel}|\ganttlinklabel| contains the label that you may assign to each link type via |\setganttlinklabel| or the \opt{link label} key (see below). +% \item You can access any values stored in the package's \meta{key}s with the macro \DescribeMacro{\ganttvalueof}|\ganttvalueof|\marg{key}. +% \item Remember that you can use the style \opt{/pgfgantt/link} to ensure a uniform appearance of all your link types. % \end{itemize} % \end{enumerate} % \end{key} +% % \begin{texcode} % \newganttlinktypealias`\marg{new type}\marg{existing type}' % \end{texcode} @@ -1768,14 +2391,14 @@ % \begin{texcode} % \setganttlinklabel`\marg{type}\marg{label}' % \end{texcode} -% \DescribeMacro{\setganttlinklabel}|\setganttlinklabel| sets a \meta{label} for the given link \meta{type}. In the following example, note how |sta-to-sta| and |s-s| share a common label, while we change the label of |fin-to-fin|. +% \DescribeMacro{\setganttlinklabel}|\setganttlinklabel| sets a \meta{label} for the given link \meta{type}. In the following example, note how \texttt{sta-to-sta} and \texttt{s-s} share a common label, while we change the label of \texttt{fin-to-fin}. % \par\bigskip\noindent % \begin{texcode} % \newganttlinktypealias{sta-to-sta}{s-s} % \newganttlinktypealias{fin-to-fin}{f-f} % \setganttlinklabel{fin-to-fin}{f2f} % -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{8} \\ @@ -1789,7 +2412,7 @@ % \newganttlinktypealias{fin-to-fin}{f-f} % \setganttlinklabel{fin-to-fin}{f2f} % -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{8} \\ @@ -1798,20 +2421,20 @@ % \ganttlink[link type=fin-to-fin]{elem1}{elem2} % \end{ganttchart} % \end{center} -% \par\bigskip Let's put it all together and devise two new link types. Firstly, |zigzag| connects the lower right corner of the start element and the upper left corner of the end element with a thick, cyan line decorated by a zigzag pattern. +% \par\bigskip Let's put it all together and devise two new link types. Firstly, \texttt{zigzag} connects the lower right corner of the start element and the upper left corner of the end element with a thick, cyan line decorated by a zigzag pattern. % \par\bigskip\noindent % \begin{texcode} % \usetikzlibrary{decorations.pathmorphing} % -% \newganttlinktype{zigzag}{% -% \ganttsetstartanchor{on right=1}% -% \ganttsetendanchor{on left=0}% +% \newganttlinktype{zigzag}{ +% \ganttsetstartanchor{on right=1} +% \ganttsetendanchor{on left=0} % \draw [decoration=zigzag, decorate, thick, cyan] % (\xLeft, \yUpper) -- -% (\xRight, \yLower);% +% (\xRight, \yLower); % } % -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{7}{12} @@ -1819,26 +2442,26 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \newganttlinktype{zigzag}{% -% \ganttsetstartanchor{on right=1}% -% \ganttsetendanchor{on left=0}% +% \newganttlinktype{zigzag}{ +% \ganttsetstartanchor{on right=1} +% \ganttsetendanchor{on left=0} % \draw [decoration=zigzag, decorate, thick, cyan] % (\xLeft, \yUpper) -- -% (\xRight, \yLower);% +% (\xRight, \yLower); % } -% \begin{ganttchart}[vgrid, hgrid]{12} +% \begin{ganttchart}[vgrid, hgrid]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{7}{12} % \ganttlink[link type=zigzag]{elem0}{elem1} % \end{ganttchart} % \end{center} -% Secondly, |drur| (short for down-right-up-right) draws a labelled arrow in the default style |link|. The link starts at the bottom of the first element and connects to the left border of the second one. In addition, the known keys |link mid| and |link bulge| decide where the line going up is positioned and how far the first line going right is below the start coordinate, respectively. +% Secondly, \texttt{drur} (short for down-right-up-right) draws a labelled arrow in the default style \opt{link}. The link starts at the bottom of the first element and connects to the left border of the second one. In addition, the known keys \opt{link mid} and \opt{link bulge} decide where the line going up is positioned and how far the first line going right is below the start coordinate, respectively. % \par\bigskip\noindent % \begin{texcode} -% \newganttlinktype{drur}{% -% \ganttsetstartanchor{on bottom=0.75}% -% \ganttsetendanchor{left}% +% \newganttlinktype{drur}{ +% \ganttsetstartanchor{on bottom=0.75} +% \ganttsetendanchor{on left} % \draw [/pgfgantt/link] % % first segment (down) % (\xLeft, \yUpper) -- @@ -1859,15 +2482,17 @@ % ($(\xLeft, \yLower)!% % \ganttvalueof{link mid}!% % (\xRight, \yLower)$) -- -% (\xRight, \yLower);% +% (\xRight, \yLower); % } % \setganttlinklabel{drur}{a fancy link} % -% \begin{ganttchart}% -% [vgrid, hgrid, +% \begin{ganttchart}[ +% vgrid, +% hgrid, % link/.style={thick, ->, green!50!black, rounded corners=2mm}, % link label anchor/.style=below, -% link mid=.7, link bulge=.6]{12} +% link mid=.7, link bulge=.6 +% ]{1}12} % \gantttitle{Title}{12} \\ % \ganttbar[inline]{Task 1}{2}{4} % \ganttbar[inline]{Task 2}{8}{11} \\ @@ -1875,9 +2500,9 @@ % \end{ganttchart} % \end{texcode} % \begin{center} -% \newganttlinktype{drur}{% -% \ganttsetstartanchor{on bottom=0.75}% -% \ganttsetendanchor{left}% +% \newganttlinktype{drur}{ +% \ganttsetstartanchor{on bottom=0.75} +% \ganttsetendanchor{on left} % \draw [/pgfgantt/link] % (\xLeft, \yUpper) -- % (\xLeft, \yUpper - @@ -1893,31 +2518,36 @@ % ($(\xLeft, \yLower)!% % \ganttvalueof{link mid}!% % (\xRight, \yLower)$) -- -% (\xRight, \yLower);% +% (\xRight, \yLower); % } % \setganttlinklabel{drur}{a fancy link} % -% \begin{ganttchart}% -% [vgrid, hgrid, +% \begin{ganttchart}[ +% vgrid, +% hgrid, % link/.style={thick, ->, green!50!black, rounded corners=2mm}, % link label anchor/.style=below, -% link mid=.7, link bulge=.6]{12} +% link mid=.7, link bulge=.6 +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar[inline]{Task 1}{2}{4} % \ganttbar[inline]{Task 2}{8}{11} \\ % \ganttlink[link type=drur]{elem0}{elem1} % \end{ganttchart} % \end{center} -% (Please do not include the comments following the |\draw| command if you copy the code above -- they might confuse \TikZ\ and generate tons of errors.) +% (Please remove the comments if you copy the code above -- they will confuse \TikZ\ and generate tons of errors.) % % \begin{key}{link label}{\meta{label}}{\textrm{(empty)}} -% \keyline{link label font}{\meta{font}}{\string\scriptsize\string\itshape\string\normalcolor} -% \keyline[/.style=]{link label anchor}{\meta{anchor}}{anchor=west} -% The |link label| key locally overrides any label specified by |\setganttlinklabel|. |link label font| sets the \meta{font} for the label, |link label anchor| determines its placement (by default, the label appears to the right of the straight link's center). +% \keyline{link label font}{\meta{font commands}}{\string\scriptsize\string\itshape} +% \keyline[/.style=]{link label node}{\meta{options}}{anchor=west, font=\string\ganttvalueof\{link label font\}} +% The \opt{link label} key locally overrides any label specified by |\setganttlinklabel|. The \meta{font commands} and \meta{options} are applied to the link label node. By default, the label appears to the right of the straight link's center. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}[vgrid, hgrid, -% link label font=\small\color{purple}\textbf]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link label font=\small\bfseries\color{purple} +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{5} \\ @@ -1926,15 +2556,22 @@ % \ganttbar{Task 5}{4}{7} % \ganttlink[link type=s-s]{elem0}{elem1} % \ganttlink[link type=f-s, link label={f$\to$s}]{elem1}{elem2} -% \ganttlink[link type=f-f, link label anchor/.style={anchor=east}]% -% {elem2}{elem3} -% \ganttlink[link type=s-f, link label anchor/.style={anchor=base}]% -% {elem3}{elem4} +% \ganttlink[ +% link type=f-f, +% link label node/.append style={anchor=east} +% ]{elem2}{elem3} +% \ganttlink[ +% link type=s-f, +% link label node/.append style={anchor=base} +% ]{elem3}{elem4} % \end{ganttchart} % \end{texcode} % \begin{center} -% \begin{ganttchart}[vgrid, hgrid, -% link label font=\small\color{purple}\textbf]{12} +% \begin{ganttchart}[ +% vgrid, +% hgrid, +% link label font=\small\bfseries\color{purple} +% ]{1}{12} % \gantttitle{Title}{12} \\ % \ganttbar{Task 1}{2}{3} \\ % \ganttbar{Task 2}{2}{5} \\ @@ -1943,158 +2580,112 @@ % \ganttbar{Task 5}{4}{7} % \ganttlink[link type=s-s]{elem0}{elem1} % \ganttlink[link type=f-s, link label={f$\to$s}]{elem1}{elem2} -% \ganttlink[link type=f-f, link label anchor/.style={anchor=east}]% -% {elem2}{elem3} -% \ganttlink[link type=s-f, link label anchor/.style={anchor=base}]% -% {elem3}{elem4} +% \ganttlink[ +% link type=f-f, +% link label node/.append style={anchor=east} +% ]{elem2}{elem3} +% \ganttlink[ +% link type=s-f, +% link label node/.append style={anchor=base} +% ]{elem3}{elem4} % \end{ganttchart} % \end{center} % \end{key} % % -% \subsection{Linked Bars and Linked Milestones} -% -% Since you'll most likely draw a lot of arrow-like links between bars and milestones, \pack{pgfgantt} provides two convenient shortcuts for these tasks: -% \begin{texcode} -% \ganttlinkedbar`\oarg{options}\marg{label}\marg{start time slot}\marg{end time slot}' -% \ganttlinkedmilestone`\oarg{options}\marg{label}\marg{time slot}' -% \end{texcode} -% These \DescribeMacro{\ganttlinkedbar}macros work exactly like the standard versions, but they additionally draw a link from the previous \DescribeMacro{\ganttlinkedmilestone}element to the bar or milestone. In the following example, the code on the left is equivalent to the code on the right. - -% \begingroup\lstset{alsoletter={-}} -% \begin{minipage}[t]{.49\textwidth} -% \begin{texcode} -% % Short version -% -% \begin{ganttchart}% -% [vgrid, hgrid]{12} -% \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{1}{4} \\ -% \ganttlinkedbar{Task 2}{5}{6} \\ -% \ganttlinkedmilestone{M 1}{6} \\ -% \ganttlinkedbar{Task 3}{7}{11} -% \end{ganttchart} -% \end{texcode} -% \end{minipage}\hfill -% \begin{minipage}[t]{.47\textwidth} -% \begin{texcode} -% % Long version -% -% \begin{ganttchart}% -% [vgrid, hgrid]{12} -% \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{1}{4} \\ -% \ganttbar{Task 2}{5}{6} \\ -% \ganttmilestone{M 1}{6} \\ -% \ganttbar{Task 3}{7}{11} -% \ganttlink{elem0}{elem1} -% \ganttlink{elem1}{elem2} -% \ganttlink{elem2}{elem3} -% \end{ganttchart} -% \end{texcode} -% \end{minipage} -% -% \begin{center} -% \begin{ganttchart}% -% [vgrid, hgrid]{12} -% \gantttitle{Title}{12} \\ -% \ganttbar{Task 1}{1}{4} \\ -% \ganttlinkedbar{Task 2}{5}{6} \\ -% \ganttlinkedmilestone{M 1}{6} \\ -% \ganttlinkedbar{Task 3}{7}{11} -% \end{ganttchart} -% \end{center} -% \endgroup -% -% % \subsection{Style Examples} % % The first example plays around with colors and notably uses equal $x$- and $y$-vectors. % \par\bigskip\noindent % \begin{texcode} -% \begin{ganttchart}% -% [y unit title=0.4cm, +% \begin{ganttchart}[ +% y unit title=0.4cm, % y unit chart=0.5cm, % vgrid, -% title/.style={draw=none, fill=RoyalBlue!50!black}, +% time slot format=isodate-yearmonth, +% compress calendar, +% title/.append style={draw=none, fill=RoyalBlue!50!black}, % title label font=\sffamily\bfseries\color{white}, -% title label anchor/.style={below=-1.6ex}, +% title label node/.append style={below=-1.6ex}, % title left shift=.05, % title right shift=-.05, % title height=1, -% bar/.style={draw=none, fill=OliveGreen!75}, +% bar/.append style={draw=none, fill=OliveGreen!75}, % bar height=.6, % bar label font=\normalsize\color{black!50}, % group right shift=0, % group top shift=.6, % group height=.3, -% group peaks={}{}{.2}, -% incomplete/.style={fill=Maroon}]{16} -% \gantttitle{2010}{4} -% \gantttitle{2011}{12} \\ -% \ganttbar% -% [progress=100, progress label font=\small\color{OliveGreen!75}, -% progress label anchor/.style={right=4pt}, -% bar label font=\normalsize\color{OliveGreen}, -% name=pp]% -% {Preliminary Project}{1}{4} \\ +% group peaks height=.2, +% bar incomplete/.append style={fill=Maroon} +% ]{2010-09}{2011-12} +% \gantttitlecalendar{year} \\ +% \ganttbar[ +% progress=100, +% bar progress label font=\small\color{OliveGreen!75}, +% bar progress label node/.append style={right=4pt}, +% bar label font=\normalsize\color{OliveGreen}, +% name=pp +% ]{Preliminary Project}{2010-09}{2010-12} \\ % \ganttset{progress label text={}, link/.style={black, -to}} -% \ganttgroup{Objective 1}{5}{16} \\ -% \ganttbar[progress=4, name=T1A]{Task A}{5}{10} \\ -% \ganttlinkedbar[progress=0]{Task B}{11}{16} \\ -% \ganttgroup{Objective 2}{5}{16} \\ -% \ganttbar[progress=15, name=T2A]{Task A}{5}{13} \\ -% \ganttlinkedbar[progress=0]{Task B}{14}{16} \\ -% \ganttgroup{Objective 3}{9}{12} \\ -% \ganttbar[progress=0]{Task A}{9}{12} +% \ganttgroup{Objective 1}{2011-01}{2011-12} \\ +% \ganttbar[progress=4, name=T1A]{Task A}{2011-01}{2011-06} \\ +% \ganttlinkedbar[progress=0]{Task B}{2011-07}{2011-12} \\ +% \ganttgroup{Objective 2}{2011-01}{2011-12} \\ +% \ganttbar[progress=15, name=T2A]{Task A}{2011-01}{2011-09} \\ +% \ganttlinkedbar[progress=0]{Task B}{2011-10}{2011-12} \\ +% \ganttgroup{Objective 3}{2011-05}{2011-08} \\ +% \ganttbar[progress=0]{Task A}{2011-05}{2011-08} % \ganttset{link/.style={OliveGreen}} % \ganttlink[link mid=.4]{pp}{T1A} % \ganttlink[link mid=.159]{pp}{T2A} % \end{ganttchart} % \end{texcode} -% % \begin{center} -% \begin{ganttchart}% -% [y unit title=0.4cm, +% \begin{ganttchart}[ +% y unit title=0.4cm, % y unit chart=0.5cm, % vgrid, -% title/.style={draw=none, fill=RoyalBlue!50!black}, +% time slot format=isodate-yearmonth, +% compress calendar, +% title/.append style={draw=none, fill=RoyalBlue!50!black}, % title label font=\sffamily\bfseries\color{white}, -% title label anchor/.style={below=-1.6ex}, +% title label node/.append style={below=-1.6ex}, % title left shift=.05, % title right shift=-.05, % title height=1, -% bar/.style={draw=none, fill=OliveGreen!75}, +% bar/.append style={draw=none, fill=OliveGreen!75}, % bar height=.6, % bar label font=\normalsize\color{black!50}, % group right shift=0, % group top shift=.6, % group height=.3, -% group peaks={}{}{.2}, -% incomplete/.style={fill=Maroon}]{16} -% \gantttitle{2010}{4} -% \gantttitle{2011}{12} \\ -% \ganttbar% -% [progress=100, progress label font=\small\color{OliveGreen!75}, -% progress label anchor/.style={right=4pt}, -% bar label font=\normalsize\color{OliveGreen}, -% name=pp]% -% {Preliminary Project}{1}{4} \\ +% group peaks height=.2, +% bar incomplete/.append style={fill=Maroon} +% ]{2010-09}{2011-12} +% \gantttitlecalendar{year} \\ +% \ganttbar[ +% progress=100, +% bar progress label font=\small\color{OliveGreen!75}, +% bar progress label node/.append style={right=4pt}, +% bar label font=\normalsize\color{OliveGreen}, +% name=pp +% ]{Preliminary Project}{2010-09}{2010-12} \\ % \ganttset{progress label text={}, link/.style={black, -to}} -% \ganttgroup{Objective 1}{5}{16} \\ -% \ganttbar[progress=4, name=T1A]{Task A}{5}{10} \\ -% \ganttlinkedbar[progress=0]{Task B}{11}{16} \\ -% \ganttgroup{Objective 2}{5}{16} \\ -% \ganttbar[progress=15, name=T2A]{Task A}{5}{13} \\ -% \ganttlinkedbar[progress=0]{Task B}{14}{16} \\ -% \ganttgroup{Objective 3}{9}{12} \\ -% \ganttbar[progress=0]{Task A}{9}{12} +% \ganttgroup{Objective 1}{2011-01}{2011-12} \\ +% \ganttbar[progress=4, name=T1A]{Task A}{2011-01}{2011-06} \\ +% \ganttlinkedbar[progress=0]{Task B}{2011-07}{2011-12} \\ +% \ganttgroup{Objective 2}{2011-01}{2011-12} \\ +% \ganttbar[progress=15, name=T2A]{Task A}{2011-01}{2011-09} \\ +% \ganttlinkedbar[progress=0]{Task B}{2011-10}{2011-12} \\ +% \ganttgroup{Objective 3}{2011-05}{2011-08} \\ +% \ganttbar[progress=0]{Task A}{2011-05}{2011-08} % \ganttset{link/.style={OliveGreen}} % \ganttlink[link mid=.4]{pp}{T1A} % \ganttlink[link mid=.159]{pp}{T2A} % \end{ganttchart} % \end{center} -% +% % \bigskip % The second example demonstrates that \pack{pgfgantt} is really flexible: Even an appearance quite different from the standard layout is possible. (More precisely, the code below tries to reproduce the Gantt chart from the English Wikipedia site, see \url{http://en.wikipedia.org/wiki/Gantt_chart}.) % \par\bigskip\noindent @@ -2105,58 +2696,74 @@ % \renewcommand\sfdefault{phv} % \renewcommand\mddefault{mc} % \renewcommand\bfdefault{bc} +% \setganttlinklabel{s-s}{START-TO-START} +% \setganttlinklabel{f-s}{FINISH-TO-START} +% \setganttlinklabel{f-f}{FINISH-TO-FINISH} % \sffamily -% \begin{ganttchart}% -% [canvas/.style={fill=none, draw=black!5, line width=.75pt}, +% \begin{ganttchart}[ +% canvas/.append style={fill=none, draw=black!5, line width=.75pt}, % hgrid style/.style={draw=black!5, line width=.75pt}, % vgrid={*1{draw=black!5, line width=.75pt}}, -% today=7.1, -% today rule/.style={draw=black!64, -% dash pattern=on 3.5pt off 4.5pt, line width=1.5pt}, -% today label={\small\bfseries TODAY}, +% today=7, +% today rule/.style={ +% draw=black!64, +% dash pattern=on 3.5pt off 4.5pt, +% line width=1.5pt +% }, +% today label font=\small\bfseries, % title/.style={draw=none, fill=none}, % title label font=\bfseries\footnotesize, -% title label anchor/.style={below=7pt}, +% title label node/.append style={below=7pt}, % include title in canvas=false, % bar label font=\mdseries\small\color{black!70}, -% bar label anchor/.style={left=2cm}, -% bar/.style={draw=none, fill=black!63}, -% bar incomplete/.style={fill=barblue}, -% progress label font=\mdseries\footnotesize\color{black!70}, -% group incomplete/.style={fill=groupblue}, +% bar label node/.append style={left=2cm}, +% bar/.append style={draw=none, fill=black!63}, +% bar incomplete/.append style={fill=barblue}, +% bar progress label font=\mdseries\footnotesize\color{black!70}, +% group incomplete/.append style={fill=groupblue}, % group left shift=0, % group right shift=0, % group height=.5, -% group peaks={0}{}{}, -% group label anchor/.style={left=.6cm}, +% group peaks tip position=0, +% group label node/.append style={left=.6cm}, +% group progress label font=\bfseries\small, % link/.style={-latex, line width=1.5pt, linkred}, -% link label font=\scriptsize\bfseries\color{linkred}\MakeUppercase, -% link label anchor/.style={below left=-2pt and 0pt} -% ]{13} -% \gantttitle[title label anchor/.style={below left=7pt and -3pt}]% -% {WEEKS:\quad1}{1} +% link label font=\scriptsize\bfseries, +% link label node/.append style={below left=-2pt and 0pt} +% ]{1}{13} +% \gantttitle[ +% title label node/.append style={below left=7pt and -3pt} +% ]{WEEKS:\quad1}{1} % \gantttitlelist{2,...,13}{1} \\ -% \ganttgroup[progress=57, progress label font=\bfseries\small]% -% {WBS 1 Summary Element 1}{1}{10} \\ -% \ganttbar[progress=75, name=WBS1A]% -% {\textbf{WBS 1.1} Activity A}{1}{8} \\ -% \ganttbar[progress=67, name=WBS1B]% -% {\textbf{WBS 1.2} Activity B}{1}{3} \\ -% \ganttbar[progress=50, name=WBS1C]% -% {\textbf{WBS 1.3} Activity C}{4}{10} \\ -% \ganttbar[progress=0, name=WBS1D]% -% {\textbf{WBS 1.4} Activity D}{4}{10} \\[grid] -% \ganttgroup[progress=0, progress label font=\bfseries\small]% -% {WBS 2 Summary Element 2}{4}{10} \\ +% \ganttgroup[progress=57]{WBS 1 Summary Element 1}{1}{10} \\ +% \ganttbar[ +% progress=75, +% name=WBS1A +% ]{\textbf{WBS 1.1} Activity A}{1}{8} \\ +% \ganttbar[ +% progress=67, +% name=WBS1B +% ]{\textbf{WBS 1.2} Activity B}{1}{3} \\ +% \ganttbar[ +% progress=50, +% name=WBS1C +% ]{\textbf{WBS 1.3} Activity C}{4}{10} \\ +% \ganttbar[ +% progress=0, +% name=WBS1D +% ]{\textbf{WBS 1.4} Activity D}{4}{10} \\[grid] +% \ganttgroup[progress=0]{WBS 2 Summary Element 2}{4}{10} \\ % \ganttbar[progress=0]{\textbf{WBS 2.1} Activity E}{4}{5} \\ % \ganttbar[progress=0]{\textbf{WBS 2.2} Activity F}{6}{8} \\ % \ganttbar[progress=0]{\textbf{WBS 2.3} Activity G}{9}{10} % \ganttlink[link type=s-s]{WBS1A}{WBS1B} % \ganttlink[link type=f-s]{WBS1B}{WBS1C} -% \ganttlink[link type=f-f, link label anchor/.style={left}]{WBS1C}{WBS1D} +% \ganttlink[ +% link type=f-f, +% link label node/.append style=left +% ]{WBS1C}{WBS1D} % \end{ganttchart} % \end{texcode} -% % \begin{center} % \definecolor{barblue}{RGB}{153,204,254} % \definecolor{groupblue}{RGB}{51,102,254} @@ -2164,55 +2771,72 @@ % \renewcommand\sfdefault{phv} % \renewcommand\mddefault{mc} % \renewcommand\bfdefault{bc} +% \setganttlinklabel{s-s}{START-TO-START} +% \setganttlinklabel{f-s}{FINISH-TO-START} +% \setganttlinklabel{f-f}{FINISH-TO-FINISH} % \sffamily -% \begin{ganttchart}% -% [canvas/.style={fill=none, draw=black!5, line width=.75pt}, +% \begin{ganttchart}[ +% canvas/.append style={fill=none, draw=black!5, line width=.75pt}, % hgrid style/.style={draw=black!5, line width=.75pt}, % vgrid={*1{draw=black!5, line width=.75pt}}, -% today=7.1, -% today rule/.style={draw=black!64, -% dash pattern=on 3.5pt off 4.5pt, line width=1.5pt}, -% today label={\small\bfseries TODAY}, +% today=7, +% today rule/.style={ +% draw=black!64, +% dash pattern=on 3.5pt off 4.5pt, +% line width=1.5pt +% }, +% today label font=\small\bfseries, % title/.style={draw=none, fill=none}, % title label font=\bfseries\footnotesize, -% title label anchor/.style={below=7pt}, +% title label node/.append style={below=7pt}, % include title in canvas=false, % bar label font=\mdseries\small\color{black!70}, -% bar label anchor/.style={left=2cm}, -% bar/.style={draw=none, fill=black!63}, -% bar incomplete/.style={fill=barblue}, -% progress label font=\mdseries\footnotesize\color{black!70}, -% group incomplete/.style={fill=groupblue}, +% bar label node/.append style={left=2cm}, +% bar/.append style={draw=none, fill=black!63}, +% bar incomplete/.append style={fill=barblue}, +% bar progress label font=\mdseries\footnotesize\color{black!70}, +% group incomplete/.append style={fill=groupblue}, % group left shift=0, % group right shift=0, % group height=.5, -% group peaks={0}{}{}, -% group label anchor/.style={left=.6cm}, +% group peaks tip position=0, +% group label node/.append style={left=.6cm}, +% group progress label font=\bfseries\small, % link/.style={-latex, line width=1.5pt, linkred}, -% link label font=\scriptsize\bfseries\color{linkred}\MakeUppercase, -% link label anchor/.style={below left=-2pt and 0pt} -% ]{13} -% \gantttitle[title label anchor/.style={below left=7pt and -3pt}]% -% {WEEKS:\quad1}{1} +% link label font=\scriptsize\bfseries, +% link label node/.append style={below left=-2pt and 0pt} +% ]{1}{13} +% \gantttitle[ +% title label node/.append style={below left=7pt and -3pt} +% ]{WEEKS:\quad1}{1} % \gantttitlelist{2,...,13}{1} \\ -% \ganttgroup[progress=57, progress label font=\bfseries\small]% -% {WBS 1 Summary Element 1}{1}{10} \\ -% \ganttbar[progress=75, name=WBS1A]% -% {\textbf{WBS 1.1} Activity A}{1}{8} \\ -% \ganttbar[progress=67, name=WBS1B]% -% {\textbf{WBS 1.2} Activity B}{1}{3} \\ -% \ganttbar[progress=50, name=WBS1C]% -% {\textbf{WBS 1.3} Activity C}{4}{10} \\ -% \ganttbar[progress=0, name=WBS1D]% -% {\textbf{WBS 1.4} Activity D}{4}{10} \\[grid] -% \ganttgroup[progress=0, progress label font=\bfseries\small]% -% {WBS 2 Summary Element 2}{4}{10} \\ +% \ganttgroup[progress=57]{WBS 1 Summary Element 1}{1}{10} \\ +% \ganttbar[ +% progress=75, +% name=WBS1A +% ]{\textbf{WBS 1.1} Activity A}{1}{8} \\ +% \ganttbar[ +% progress=67, +% name=WBS1B +% ]{\textbf{WBS 1.2} Activity B}{1}{3} \\ +% \ganttbar[ +% progress=50, +% name=WBS1C +% ]{\textbf{WBS 1.3} Activity C}{4}{10} \\ +% \ganttbar[ +% progress=0, +% name=WBS1D +% ]{\textbf{WBS 1.4} Activity D}{4}{10} \\[grid] +% \ganttgroup[progress=0]{WBS 2 Summary Element 2}{4}{10} \\ % \ganttbar[progress=0]{\textbf{WBS 2.1} Activity E}{4}{5} \\ % \ganttbar[progress=0]{\textbf{WBS 2.2} Activity F}{6}{8} \\ % \ganttbar[progress=0]{\textbf{WBS 2.3} Activity G}{9}{10} % \ganttlink[link type=s-s]{WBS1A}{WBS1B} % \ganttlink[link type=f-s]{WBS1B}{WBS1C} -% \ganttlink[link type=f-f, link label anchor/.style={left}]{WBS1C}{WBS1D} +% \ganttlink[ +% link type=f-f, +% link label node/.append style=left +% ]{WBS1C}{WBS1D} % \end{ganttchart} % \end{center} % @@ -2225,52 +2849,32 @@ % % \subsection{Packages} % -% \pack{pgfgantt} is modest in terms of dependencies: It only requires the \TikZ\ package and some of its libraries. +% \pack{pgfgantt} is modest in terms of dependencies: It only requires the \TikZ\ and \pack{pgfcalendar} packages. % % \iffalse %<*pgfgantt> % \fi % \begin{macrocode} \RequirePackage{tikz} - \usetikzlibrary{arrows,backgrounds,calc,patterns,positioning} - -% \end{macrocode} -% -% \subsection{Global Counters and Booleans} -% -% We define a number of global counters: |gtt@width| equals the number of time slots. |gtt@currentline| holds the current line; it starts from 0 and decreases. |gtt@lasttitleline| equals the line of the title element drawn last. Furthermore, |gtt@lasttitleslot| corresponds to the $x$-coordinate of its right border. |gtt@elementid| enumerates the automatic names of chart elements. |gtt@currgrid| is the index of the current grid line drawn. -% \begin{macrocode} -\newcounter{gtt@width} -\newcounter{gtt@currentline} -\newcounter{gtt@lasttitleline} -\newcounter{gtt@lasttitleslot} -\newcounter{gtt@elementid} -\newcounter{gtt@currgrid} -% \end{macrocode} -% \begin{intmacro}{\gtt@lastelement}\begin{intmacro}{\gtt@currentelement}\begin{intmacro}{\ifgtt@intitle} -% The macros |\gtt@lastelement| and |\gtt@currentelement| save the name of the current and last chart element drawn. Thereby, the |\ganttlinked...| macros can add a link connecting them. -% -% The boolean |\ifgtt@intitle| is true at the start of a |ganttchart| environment and set to false as soon as the first non-title element is encountered. -% \begin{macrocode} -\def\gtt@lastelement{} -\def\gtt@currentelement{} -\newif\ifgtt@intitle +\usetikzlibrary{% + arrows, backgrounds, calc,% + patterns, positioning, shapes.geometric% +} +\RequirePackage{pgfcalendar} % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro} % % -% \subsection{Macros for Key Management} +% \subsection{Macros for Key and Error Management} % % \begin{macro}{\ganttset} % |\ganttset| changes the current key path to |/pgfgantt/| and then executes the keys in its mandatory argument. % \begin{macrocode} \def\ganttset#1{\pgfqkeys{/pgfgantt}{#1}} - % \end{macrocode} % \end{macro} % \begin{intmacro}{\@gtt@keydef} -% The following three auxiliary macros save us some code when we devise keys later on. Firstly, |\@gtt@keydef|\marg{key}\marg{initial value} declares the key |/pgfgantt/|\meta{key} and stores its \meta{initial value}.\changes{v3.0}{2012/01/25}{\cs{@gtt@keydef} and \cs{@gtt@stylekeydef} have been rewritten to support \texttt{pgfkey}'s abilities to store key values.} +% The following auxiliary macros save us some code when we devise keys later on. |\@gtt@keydef|\marg{key}\marg{initial value} declares the key |/pgfgantt/|\meta{key} and stores its \meta{initial value}. % \begin{macrocode} \def\@gtt@keydef#1#2{% \pgfkeyssetvalue{/pgfgantt/#1}{#2}% @@ -2278,7 +2882,7 @@ % \end{macrocode} % \end{intmacro} % \begin{macro}{\ganttvalueof} -% Secondly, |\ganttvalueof|\marg{key} retrieves the value stored by a \meta{key}. Link type authors should be able to use this macro in their code; thus, it lacks any |@|s.\changes{v3.0}{2012/01/25}{\cs{@gtt@get} has been renamed to \cs{ganttvalueof} to provide a convenient access for link type authors.} +% |\ganttvalueof|\marg{key} retrieves the value stored by a \meta{key}. Link type authors should be able to use this macro in their code; thus, it lacks any |@|s. % \begin{macrocode} \def\ganttvalueof#1{% \pgfkeysvalueof{/pgfgantt/#1}% @@ -2286,18 +2890,51 @@ % \end{macrocode} % \end{macro} % \begin{intmacro}{\@gtt@stylekeydef} -% Thirdly, |\@gtt@stylekeydef|\marg{key}\marg{initial style} declares a style \meta{key} with an \meta{initial style}. +% |\@gtt@stylekeydef|\marg{key}\marg{initial style} declares a style \meta{key} with an \meta{initial style}. % \begin{macrocode} \def\@gtt@stylekeydef#1#2{% \pgfkeys{/pgfgantt/#1/.style={#2}}% } % \end{macrocode} % \end{intmacro} +% \begin{intmacro}{\@gtt@PackageError} +% \begin{intmacro}{\@gtt@PackageWarning} +% |\@gtt@PackageError|\marg{message} and |\@gtt@PackageWarning|\marg{message} issue a package error or warning \meta{message}, respectively. +% \begin{macrocode} +\def\@gtt@PackageError#1{% + \PackageError{pgfgantt}{#1}{}% +} +\def\@gtt@PackageWarning#1{% + \PackageWarning{pgfgantt}{#1}% +} + +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} % -% \subsection{Option Declarations} % -% \begin{option}{hgrid}\begin{option}{hgrid style}\begin{intmacro}{\ifgtt@hgrid}\begin{intmacro}{\gtt@hgridstyle} -% |hgrid| checks whether its value is |false| and sets the boolean |\ifgtt@hgrid| accordingly. If the value is |true| or missing, horizontal grid lines appear |dotted|. +% \subsection{The Horizontal and Vertical Grid} +% +% \begin{intmacro}{\gtt@currentline} +% \begin{intmacro}{\gtt@lasttitleline} +% \begin{intmacro}{\gtt@currgrid} +% \begin{intmacro}{\gtt@chartwidth} +% The count register |\gtt@currentline| holds the current line; it starts from 0 and decreases. |\gtt@lasttitleline| equals the line of the title element drawn last. |\gtt@currgrid| is the index of the current grid line drawn. |\gtt@chartwidth| equals the number of time slots. +% \begin{macrocode} +\newcount\gtt@currentline +\newcount\gtt@lasttitleline +\newcount\gtt@currgrid +\newcount\gtt@chartwidth +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \begin{option}{hgrid} +% \begin{option}{hgrid style} +% \begin{intmacro}{\ifgtt@hgrid} +% \begin{intmacro}{\gtt@hgridstyle} +% \opt{hgrid} checks whether its value is false and sets the boolean |\ifgtt@hgrid| accordingly. If the value is true or missing, horizontal grid lines appear dotted. % \begin{macrocode} \@gtt@stylekeydef{hgrid style}{dotted} \newif\ifgtt@hgrid @@ -2321,9 +2958,60 @@ } % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{option}\end{option} -% \begin{option}{vgrid}\begin{intmacro}{\ifgtt@vgrid}\begin{intmacro}{\gtt@vgridstyle} -% Analogously, we declare |vgrid|. +% \end{intmacro} +% \end{intmacro} +% \end{option} +% \end{option} +% \begin{intmacro}{\gtt@hgrid@do} +% The |\gtt@hgrid@do| macro decomposes the style list for the horizontal grid into its comma-separated items. Each item is analyzed (see below) only if some grid lines are still left to draw. Note the ``elegant'' quadruple |\expandafter| construction, which enables tail recursion. +% \begin{macrocode} +\def\gtt@hgrid@do#1,{% + \ifx\relax#1\else + \ifnum\gtt@currgrid<\gtt@currentline\else% + \gtt@hgrid@analyze#1\relax% + \expandafter\expandafter\expandafter\gtt@hgrid@do% + \expandafter\fi% + \fi% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{intmacro}{\gtt@hgrid@analyze} +% In the absence of a star as the first token in a style list item, |\gtt@hgrid@analyze| adds the multiplier |1| to the input stream. +% \begin{macrocode} +\def\gtt@hgrid@analyze{% + \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{intmacro}{\gtt@hgrid@draw} +% |\gtt@hgrid@draw| draws as many grid lines as required by the multiplier. It increases |\gtt@currgrid| after each line drawn and breaks the loop as soon as all grid rules have been drawn. +% \begin{macrocode} +\def\gtt@hgrid@draw#1#2\relax{% + \foreach \i in {1,...,#1} {% + \pgfmathsetmacro\y@upper{% + \gtt@lasttitleline * \ganttvalueof{y unit title} +% + (\gtt@currgrid - \gtt@lasttitleline)% + * \ganttvalueof{y unit chart}% + }% + \draw [#2] + (0pt, \y@upper pt) -- + (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);% + \global\advance\gtt@currgrid by-1\relax% + \ifnum\gtt@currgrid<\gtt@currentline\breakforeach\fi% + }% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{option}{vgrid} +% \begin{intmacro}{\ifgtt@vgrid} +% \begin{intmacro}{\gtt@vgridstyle} +% \begin{intmacro}{\gtt@vgrid@do} +% \begin{intmacro}{\gtt@vgrid@analyze} +% \begin{intmacro}{\gtt@vgrid@draw} +% Analogously, we declare options and macros for printing the vertical grid. % \begin{macrocode} \newif\ifgtt@vgrid \ganttset{% @@ -2345,386 +3033,428 @@ vgrid/.default=dotted } -% \end{macrocode} -% \end{intmacro}\end{intmacro}\end{option} +\def\gtt@vgrid@do#1,{% + \ifx\relax#1\else% + \ifnum\gtt@currgrid>\gtt@chartwidth\else% + \gtt@vgrid@analyze#1\relax% + \expandafter\expandafter\expandafter\gtt@vgrid@do% + \expandafter\fi% + \fi% +} -% \begin{option}{x unit}\begin{option}{y unit title}\begin{option}{y unit chart} -% The following three keys store the basis vectors for the chart. -% \begin{macrocode} -\@gtt@keydef{x unit}{.5cm} -\@gtt@keydef{y unit title}{1cm} -\@gtt@keydef{y unit chart}{1cm} +\def\gtt@vgrid@analyze{% + \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% +} + +\def\gtt@vgrid@draw#1#2\relax{% + \foreach \i in {1,...,#1} {% + \draw [#2] + (\gtt@currgrid * \ganttvalueof{x unit}, \y@upper pt) --% + (\gtt@currgrid * \ganttvalueof{x unit}, \y@lower pt);% + \global\advance\gtt@currgrid by1\relax% + \ifnum\gtt@currgrid>\gtt@chartwidth\breakforeach\fi% + }% +} % \end{macrocode} -% \end{option}\end{option}\end{option} -% \begin{option}{canvas}\begin{option}{today}\begin{option}{today rule}\begin{option}{today label} -% Here is a set of keys related to the canvas \dots +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{option} +% +% +% \subsection{Time Slot Formats} +% +% \begin{intmacro}{\gtt@smugglecount} +% |\gtt@smugglecount|\marg{count} smuggles the local value of a count register over the end of a \TeX\ group. % \begin{macrocode} -\@gtt@stylekeydef{canvas}{fill=white} -\@gtt@keydef{today}{none} -\@gtt@stylekeydef{today rule}{dashed, line width=1pt} -\@gtt@keydef{today label}{TODAY} +\def\gtt@smugglecount#1\endgroup{% + \edef\@tempa{\the#1}% + \expandafter\endgroup\expandafter#1\expandafter=\@tempa% +} % \end{macrocode} -% \end{option}\end{option}\end{option}\end{option} -% \begin{option}{title}\begin{option}{title label font}\begin{option}{title label anchor}\begin{option}{title list options}\begin{option}{title left shift}\begin{option}{title right shift}\begin{option}{title top shift}\begin{option}{title height}\begin{intmacro}{\gtt@titlelistoptions} -% \dots\ and of keys that influence the title. Note that |\@gtt@keydef| cannot define |title list options|, since |\@gtt@titlelistoptions| is expanded after a |\foreach| statement, where |\ganttvalueof| will not work. +% \end{intmacro} +% \begin{intmacro}{\gtt@juliantotimeslot} +% |\gtt@juliantotimeslot|\marg{count 1}\marg{count 2} converts the Julian date stored in \meta{count 1} to a time slot and stores the latter in \meta{count 2}. This macro is called after the start of Gantt chart. Thus, |\gtt@startyear|, |\gtt@startmonth| and |\gtt@startjulian| (see section~\ref{ssc:ImplMain}) have already been initialized. If the chart is compressed, one time slot corresponds to one month; otherwise, it corresponds to one day. % \begin{macrocode} -\@gtt@stylekeydef{title}{fill=white} -\@gtt@keydef{title label font}{\small} -\@gtt@stylekeydef{title label anchor}{anchor=mid} -\ganttset{% - title list options/.code={% - \def\gtt@titlelistoptions{[#1]}% - },% - title list options={var=\x, evaluate=\x}% +\newcommand\gtt@juliantotimeslot[2]{% + \begingroup% + \@tempcnta=#1\relax% + \ifgtt@compresscalendar% + \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}% + \@tempcnta=\@tempa\relax% + \advance\@tempcnta by-\gtt@startyear\relax% + \multiply\@tempcnta by12\relax% + \advance\@tempcnta by\@tempb\relax% + \advance\@tempcnta by-\gtt@startmonth\relax% + \advance\@tempcnta by1\relax% + \else% + \advance\@tempcnta by-\gtt@startjulian\relax% + \advance\@tempcnta by1\relax% + \fi% + #2=\@tempcnta\relax% + \gtt@smugglecount#2% + \endgroup% } -\@gtt@keydef{title left shift}{0} -\@gtt@keydef{title right shift}{0} -\@gtt@keydef{title top shift}{0} -\@gtt@keydef{title height}{.6} % \end{macrocode} -% \end{intmacro}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% \begin{option}{include title in canvas}\begin{intmacro}{\ifgtt@includetitle} -% |include title in canvas| is one of two boolean keys in the package. +% \end{intmacro} +% \begin{macro}{\newgantttimeslotformat} +% |\newgantttimeslotformat|\marg{name}\marg{code} defines the macro\\|\gtt@tsstojulian@|\meta{name}\marg{tss}\marg{count}. This macro executes \meta{code} (within a group), which should convert \meta{tss} to a Julian date and store the date in \meta{count}. % \begin{macrocode} -\newif\ifgtt@includetitle -\ganttset{% - include title in canvas/.is if=gtt@includetitle,% - include title in canvas +\newcommand\newgantttimeslotformat[2]{% + \expandafter\def\csname gtt@tsstojulian@#1\endcsname##1##2{% + \begingroup#2\gtt@smugglecount##2\endgroup% + }% } % \end{macrocode} -% \end{intmacro}\end{option} -% \begin{option}{name}\begin{option}{time slot modifier}\begin{option}{inline}\begin{intmacro}{\ifgtt@inline} -% The |name| key saves unique names for chart elements. The |time slot modifier| option controls the semi-intelligent behaviour of the package regarding the conversion of title slots to $x$-coordinates. A value of |0| essentially means ``interpret all end time slots as $x$-coordinates''. The |inline| key moves labels close to their respective chart elements. +% \end{macro} +% The predefined time slot formats |simple|, |isodate| and |isodate-yearmonth| are straight forward. % \begin{macrocode} -\@gtt@keydef{name}{} -\@gtt@keydef{time slot modifier}{-1} -\newif\ifgtt@inline -\ganttset{% - inline/.is if=gtt@inline,% - inline=false% +\newgantttimeslotformat{simple}{% + #2=#1\relax% + \advance#2 by\gtt@tsf@startjulian\relax% + \advance#2 by-1\relax% +} + +\newgantttimeslotformat{isodate}{% + \pgfcalendardatetojulian{#1}{#2}% +} + +\newgantttimeslotformat{isodate-yearmonth}{% + \pgfcalendardatetojulian{#1-01}{#2}% } % \end{macrocode} -% \end{intmacro}\end{option}\end{option}\end{option} -% \begin{option}{bar}\begin{option}{bar label text}\begin{option}{bar label font}\begin{option}{bar label anchor}\begin{option}{bar label inline anchor}\begin{option}{bar left shift}\begin{option}{bar right shift}\begin{option}{bar top shift}\begin{option}{bar height}\begin{intmacro}{\gtt@barlabeltext} -% Some standard key declarations for bars \dots +% \begin{intmacro}{\gtt@tsf@getdmy} +% |\gtt@tsf@getdmy|\marg{date} decomposes a \meta{date} |day|[|sep|]|month|[|sep|]|year| (with [|sep|] representing a period, hyphen or slash) into |day|, |month| and |year| and stores these numbers in |\local@day|, |\local@month| and |\local@year|, respectively. % \begin{macrocode} -\@gtt@stylekeydef{bar}{fill=white} -\ganttset{% - bar label text/.code={% - \def\gtt@barlabeltext##1{#1}% - },% - bar label text={\strut#1}% +\newcommand\gtt@tsf@getdmy[1]{% + \edef\local@firstarg{#1}% + \def\local@decompose##1.##2.##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg..\relax% + \ifx\local@month\@empty% + \def\local@decompose##1/##2/##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg//\relax% + \ifx\local@month\@empty% + \def\local@decompose##1-##2-##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg--\relax% + \ifx\local@month\@empty% + \@gtt@PackageError{Illegal time slot specifier `#1'.}% + \else% + \def\local@decompose##1--{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% + \fi% + \else% + \def\local@decompose##1//{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% + \fi% + \else% + \def\local@decompose##1..{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% + \fi% } -\@gtt@keydef{bar label font}{\normalsize} -\@gtt@stylekeydef{bar label anchor}{anchor=east} -\@gtt@stylekeydef{bar label inline anchor}{anchor=center} -\@gtt@keydef{bar label shape anchor}{center} -\@gtt@keydef{bar left shift}{0} -\@gtt@keydef{bar right shift}{0} -\@gtt@keydef{bar top shift}{.3} -\@gtt@keydef{bar height}{.4} % \end{macrocode} -% \end{intmacro}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% \begin{option}{group}\begin{option}{group label text}\begin{option}{group label font}\begin{option}{group label anchor}\begin{option}{group label inline anchor}\begin{option}{group left shift}\begin{option}{group right shift}\begin{option}{group top shift}\begin{option}{group height}\begin{intmacro}{\gtt@grouplabeltext} -% \dots\ and groups. +% \end{intmacro} +% Time slot formats |little-endian|, |big-endian| and |middle-endian| only differ in their call of |\pgfcalendardatetojulian|. If the year (stored in |\local@year| or |\local@day|) lacks a century (e.\,g., 13 instead of 2013), it is completed according to the value of \opt{time slot format/base century}. % \begin{macrocode} -\@gtt@stylekeydef{group}{fill=black} -\ganttset{% - group label text/.code={% - \def\gtt@grouplabeltext##1{#1}% - },% - group label text={\strut#1}% +\newgantttimeslotformat{little-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@year<100\relax% + \edef\local@year{\gtt@tsf@basecentury\local@year}% + \fi% + \pgfcalendardatetojulian{\local@year-\local@month-\local@day}{#2}% } -\@gtt@keydef{group label font}{\normalsize\bfseries} -\@gtt@stylekeydef{group label anchor}{anchor=east} -\@gtt@stylekeydef{group label inline anchor}{anchor=south} -\@gtt@keydef{group label shape anchor}{center} -\@gtt@keydef{group left shift}{-.1} -\@gtt@keydef{group right shift}{.1} -\@gtt@keydef{group top shift}{.4} -\@gtt@keydef{group height}{.2} + +\newgantttimeslotformat{big-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@day<100\relax% + \edef\local@day{\gtt@tsf@basecentury\local@day}% + \fi% + \pgfcalendardatetojulian{\local@day-\local@month-\local@year}{#2}% +} + +\newgantttimeslotformat{middle-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@year<100\relax% + \edef\local@year{\gtt@tsf@basecentury\local@year}% + \fi% + \pgfcalendardatetojulian{\local@year-\local@day-\local@month}{#2}% +} + % \end{macrocode} -% \end{intmacro}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% \begin{option}{group left peak}\begin{intmacro}{\gtt@groupleftpeakmidx}\begin{intmacro}{\gtt@groupleftpeakinnerx}\begin{intmacro}{\gtt@groupleftpeaky} -% |gantt left peak| checks for each of its three values whether it is non-empty and only then changes the corresponding length macro. +% \begin{option}{time slot format} +% \begin{intmacro}{\gtt@tsstojulian} +% The key \opt{time slot format}|=|\meta{name} checks whether the format \meta{name} exists and then defines the macro |\gtt@tsstojulian| to be equivalent to\\|\gtt@tsstojulian@|\meta{name}. % \begin{macrocode} \ganttset{% - group left peak/.code n args={3}{% - \def\@tempa{#1}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeakmidx{#1}\fi% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeakinnerx{#2}\fi% - \def\@tempa{#3}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeaky{#3}\fi% + time slot format/.code={% + \@ifundefined{gtt@tsstojulian@#1}{% + \@gtt@PackageError{% + Time slot format `#1' undefined.% + }% + }{}% + \expandafter\let\expandafter\gtt@tsstojulian% + \csname gtt@tsstojulian@#1\endcsname% },% + time slot format=simple,% % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro}\end{option} -% \begin{option}{group right peak}\begin{intmacro}{\gtt@grouprightpeakmidx}\begin{intmacro}{\gtt@grouprightpeakinnerx}\begin{intmacro}{\gtt@grouprightpeaky} -% |group right peak| works similar, but a |-| also counts as an empty value (the reason for this will soon become apparent). +% \end{intmacro} +% \end{option} +% \begin{option}{time slot format/base century} +% \begin{intmacro}{\gtt@tsf@basecentury} +% \opt{time slot format/base century}|=|\meta{year} extracts the century from the four-digit \meta{year} (e.\,g., 20 from 2000) and stores it in |\gtt@tsf@basecentury|. % \begin{macrocode} - group right peak/.code n args={3}{% - \def\@tempa{#1}% - \def\@tempb{-}% - \ifx\@tempa\@empty\else% - \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakmidx{#1}\fi% - \fi% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakinnerx{#2}\fi% - \fi% - \def\@tempa{#3}% - \ifx\@tempa\@empty\else\def\gtt@grouprightpeaky{#3}\fi% + time slot format/base century/.code={% + \begingroup% + \@tempcnta=#1\relax% + \divide\@tempcnta by100\relax% + \xdef\gtt@tsf@basecentury{\the\@tempcnta}% + \endgroup% },% + time slot format/base century=2000,% % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro}\end{option} -% \begin{option}{group peaks} -% |group peaks| simultaneously sets |group left peak| and |group right peak|. In order to preserve the symmetry of the peaks, the key adds a negative sign (i.\,e., a hyphen in the source code) to \meta{groove x} and \meta{inner x} of |group right peak|. Therefore, the latter key must interpret its first and second value as ``empty'' even if they contain a single hyphen. +% \end{intmacro} +% \end{option} +% \begin{option}{time slot format/start date} +% \begin{intmacro}{\gtt@tsf@startjulian} +% \opt{time slot format/start date}|=|\meta{isodate} stores the Julian date corresponding to \meta{isodate} in |\gtt@tsf@startjulian|. % \begin{macrocode} - group peaks/.code n args={3}{% - \ganttset{% - group left peak={#1}{#2}{#3},% - group right peak={-#1}{-#2}{#3}% - }% + time slot format/start date/.code={% + \begingroup% + \pgfcalendardatetojulian{#1}{\@tempcnta}% + \xdef\gtt@tsf@startjulian{\the\@tempcnta}% + \endgroup% },% - group peaks={.2}{.4}{.1} + time slot format/start date=2000-01-01% } % \end{macrocode} +% \end{intmacro} % \end{option} -% \begin{option}{progress}\begin{option}{bar incomplete}\begin{option}{group incomplete}\begin{option}{incomplete}\begin{option}{progress label text}\begin{option}{progress label font}\begin{option}{progress label anchor}\begin{intmacro}{\gtt@progress}\begin{intmacro}{\gtt@progresslabeltext} -% The keys below manage the progress elements. Note the way in which we declare |progress label text|, so that a |#1| in its value is replaced by the argument of |\gtt@progresslabeltext|. +% +% +% \subsection{The Main Environment} +% \label{ssc:ImplMain} +% +% \begin{option}{x unit} +% \begin{option}{y unit title} +% \begin{option}{y unit chart} +% Keys that store the basis vectors of the chart. % \begin{macrocode} -\ganttset{% - progress/.code={% - \def\gtt@progress{#1}% - },% - progress=none% -} -\@gtt@stylekeydef{bar incomplete}{} -\@gtt@stylekeydef{group incomplete}{} -\ganttset{% - incomplete/.style/.code={% - \ganttset{bar incomplete/.style={#1}, group incomplete/.style={#1}}% - },% - incomplete/.style={fill=black!25} -} -\ganttset{% - progress label text/.code={% - \def\gtt@progresslabeltext##1{#1}% - },% - progress label text={#1\% complete} -} -\@gtt@keydef{progress label font}{\scriptsize} -\@gtt@stylekeydef{progress label anchor}{anchor=west} - +\@gtt@keydef{x unit}{.5cm} +\@gtt@keydef{y unit title}{1cm} +\@gtt@keydef{y unit chart}{1cm} % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% \begin{option}{milestone}\begin{option}{milestone label text}\begin{option}{milestone label font}\begin{option}{milestone label anchor}\begin{option}{milestone label inline anchor}\begin{option}{milestone width}\begin{option}{milestone height}\begin{option}{milestone xshift}\begin{option}{milestone yshift}\begin{intmacro}{\gtt@milestonelabeltext} -% Here are the declarations of the milestone-related keys. +% \end{option} +% \end{option} +% \end{option} +% \begin{option}{canvas} +% \begin{option}{today} +% \begin{option}{today offset} +% \begin{option}{today rule} +% \begin{option}{today label} +% \begin{option}{today label font} +% \begin{option}{today label node} +% Keys related to the canvas and the today rule. % \begin{macrocode} -\@gtt@stylekeydef{milestone}{fill=black} -\ganttset{% - milestone label text/.code={% - \def\gtt@milestonelabeltext##1{#1}% - },% - milestone label text={\strut#1}% +\@gtt@stylekeydef{canvas}{shape=rectangle, draw, fill=white} +\@gtt@keydef{today}{none} +\@gtt@keydef{today offset}{1} +\@gtt@stylekeydef{today rule}{dashed, line width=1pt} +\@gtt@keydef{today label}{TODAY} +\@gtt@keydef{today label font}{\normalfont} +\@gtt@stylekeydef{today label node}{% + anchor=north, font=\ganttvalueof{today label font}% } -\@gtt@keydef{milestone label font}{\normalsize\itshape} -\@gtt@stylekeydef{milestone label anchor}{anchor=east} -\@gtt@stylekeydef{milestone label inline anchor}{anchor=south} -\@gtt@keydef{milestone label shape anchor}{center} -\@gtt@keydef{milestone width}{.8} -\@gtt@keydef{milestone height}{.4} -\@gtt@keydef{milestone xshift}{0} -\@gtt@keydef{milestone yshift}{.5} - % \end{macrocode} -% \end{intmacro}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% \begin{option}{link}\begin{option}{link type}\begin{option}{link mid}\begin{option}{link bulge}\begin{option}{link tolerance}\begin{option}{link label}\begin{option}{link label font}\begin{option}{link label anchor} -% Next, we declare the keys that modify links. -% \begin{macrocode} -\@gtt@stylekeydef{link}{-latex, rounded corners=1pt} -\@gtt@keydef{link type}{auto} -\@gtt@keydef{link mid}{.5} -\@gtt@keydef{link bulge}{.4} -\@gtt@keydef{link tolerance}{.6} -\@gtt@keydef{link label}{} -\@gtt@keydef{link label font}{\scriptsize\itshape\normalcolor} -\@gtt@stylekeydef{link label anchor}{anchor=west} - -% \end{macrocode} -% \end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option}\end{option} -% -% -% \subsection{The Horizontal and Vertical Grid} -% -% \begin{intmacro}{\gtt@vgrid@do} -% The |\gtt@vgrid@do| macro decomposes the style list for the vertical grid into its comma-separated items. The item is analyzed (see below) only if some grid lines are still left to draw. Note the ``elegant'' quadruple |\expandafter| construction, which enables tail recursion. +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \begin{intmacro}{\ifgtt@newlineshortcut} +% \begin{option}{newline shortcut} +% Boolean key that determines if |\\| is equivalent to |\ganttnewline|. % \begin{macrocode} -\def\gtt@vgrid@do#1,{% - \ifx\relax#1\else% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\else% - \gtt@vgrid@analyze#1\relax% - \expandafter\expandafter\expandafter\gtt@vgrid@do% - \expandafter\fi% - \fi% +\newif\ifgtt@newlineshortcut +\ganttset{% + newline shortcut/.is if=gtt@newlineshortcut,% + newline shortcut=true% } % \end{macrocode} +% \end{option} % \end{intmacro} -% \begin{intmacro}{\gtt@vgrid@analyze} -% In the absence of a star as the first token in a style list item, |\gtt@vgrid@analyze| adds the multiplier |1| to the input stream. +% \begin{intmacro}{\ifgtt@tikzpicture} +% \begin{intmacro}{\ifgtt@intitle} +% \begin{intmacro}{\gtt@lasttitleslot} +% \begin{intmacro}{\gtt@elementid} +% \begin{intmacro}{\gtt@today@slot} +% \begin{intmacro}{\gtt@startjulian} +% \begin{intmacro}{\gtt@endjulian} +% The boolean |\ifgtt@tikzpicture| is true if a Gantt chart appears within a \TikZ\ picture. |\ifgtt@intitle| is true at the start of a |ganttchart| environment and set to false as soon as the first non-title element is encountered. |\gtt@lasttitleslot| corresponds to the $x$-coordinate of its right border. |\gtt@elementid| enumerates the automatic names of chart elements. |\gtt@today@slot| is the time slot of the today rule. |\gtt@startjulian| and |\gtt@endjulian| contain the Julian dates corresponding to the first and last time slot, respectively. % \begin{macrocode} -\def\gtt@vgrid@analyze{% - \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% -} - +\newif\ifgtt@tikzpicture +\newif\ifgtt@intitle +\newcount\gtt@lasttitleslot +\newcount\gtt@elementid +\newcount\gtt@today@slot +\newcount\gtt@startjulian +\newcount\gtt@endjulian % \end{macrocode} % \end{intmacro} -% \begin{intmacro}{\gtt@vgrid@draw} -% |\gtt@vgrid@draw| draws as many grid lines as required by the multiplier. It increases |gtt@currgrid| after each line drawn and breaks the loop as soon as all grid rules have been drawn. +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \begin{environment}{ganttchart} +% At the beginning of a |ganttchart| environment, the keys in its optional argument are executed. Initialize the macros and counts that contain start dates, end dates, the chart width, \dots % \begin{macrocode} -\def\gtt@vgrid@draw#1#2\relax{% - \foreach \i in {1,...,#1} {% - \draw [#2] - (\value{gtt@currgrid} * \ganttvalueof{x unit}, \y@upper pt) --% - (\value{gtt@currgrid} * \ganttvalueof{x unit}, \y@lower pt);% - \stepcounter{gtt@currgrid}% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi% - }% -} - +\newenvironment{ganttchart}[3][]{% + \ganttset{#1}% + \gtt@tsstojulian{#2}{\gtt@startjulian}% + \global\gtt@startjulian=\gtt@startjulian\relax% + \gtt@tsstojulian{#3}{\gtt@endjulian}% + \global\gtt@endjulian=\gtt@endjulian\relax% + \pgfcalendarjuliantodate{\gtt@startjulian}% + {\gtt@startyear}{\gtt@startmonth}{\@tempa}% + \xdef\gtt@startyear{\gtt@startyear}% + \xdef\gtt@startmonth{\gtt@startmonth}% + \gtt@juliantotimeslot{\gtt@endjulian}{\gtt@chartwidth} + \global\gtt@chartwidth=\gtt@chartwidth\relax% % \end{macrocode} -% \end{intmacro} -% \begin{intmacro}{\gtt@hgrid@do}\begin{intmacro}{\gtt@hgrid@analyze}\begin{intmacro}{\gtt@hgrid@draw} -% The corresponding macros for the horizontal grid work like their vertical grid analogues. +% \dots\ the time slot of the today rule, \dots. % \begin{macrocode} -\def\gtt@hgrid@do#1,{% - \ifx\relax#1\else - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\else% - \gtt@hgrid@analyze#1\relax% - \expandafter\expandafter\expandafter\gtt@hgrid@do% - \expandafter\fi% + \def\@tempa{none}% + \edef\@tempb{\ganttvalueof{today}}% + \ifx\@tempa\@tempb\else% + \gtt@tsstojulian{\ganttvalueof{today}}{\gtt@today@slot} + \gtt@juliantotimeslot{\gtt@today@slot}{\gtt@today@slot}% \fi% -} - -\def\gtt@hgrid@analyze{% - \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% -} - -\def\gtt@hgrid@draw#1#2\relax{% - \foreach \i in {1,...,#1} {% - \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} +% - (\value{gtt@currgrid} - \value{gtt@lasttitleline})% - * \ganttvalueof{y unit chart}% - }% - \draw [#2] - (0pt, \y@upper pt) -- - (\value{gtt@width} * \ganttvalueof{x unit}, \y@upper pt);% - \addtocounter{gtt@currgrid}{-1}% - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi% - }% -} - % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro} -% -% -% \subsection{The Main Environment} -% -% \begin{environment}{ganttchart}\begin{intmacro}{\ifgtt@tikzpicture}\begin{macro}{\\} -% If a |ganttchart| appears outside of a |tikzpicture|, we implicitly start this environment. ``Within a |tikzpicture|'' means that |\useasboundingbox| is defined.\par -% At the beginning of a |ganttchart| environment, the keys in its optional argument are executed. |gtt@width| saves the environment's mandatory argument (i.\,e., the number of time slots). All counters are set to |0|. Since we expect a chart to start with at least one title element, |\ifgtt@intitle| is true. Within the environment, the control symbol |\\| is equivalent to |\ganttnewline| (similar to the syntax of a \LaTeX\ table). +% \dots\ the current element number, and information for drawing actions. +% \begin{macrocode} + \global\gtt@elementid=0\relax% + \global\gtt@currentline=0\relax% + \global\gtt@lasttitleline=0\relax% + \global\gtt@lasttitleslot=0\relax% +% \end{macrocode} +% \begin{macro}{\\} +% \begin{macro}{\ganttalignnewline} +% If a |ganttchart| appears outside of a |tikzpicture|, we implicitly start this environment. ``Within a |tikzpicture|'' means that |\useasboundingbox| is defined. Since we expect a chart to start with at least one title element, |\ifgtt@intitle| is true. If \opt{newline shortcut} is true, make the control symbol |\\| equivalent to |\ganttnewline|. In any case, |\ganttalignnewline| is defined. % \begin{macrocode} -\newif\ifgtt@tikzpicture - -\newenvironment{ganttchart}[2][]{% \@ifundefined{useasboundingbox}% {\gtt@tikzpicturefalse\begin{tikzpicture}}% {\gtt@tikzpicturetrue}% - \ganttset{#1}% - \setcounter{gtt@width}{#2}% - \setcounter{gtt@currentline}{0}% - \setcounter{gtt@lasttitleline}{0}% - \setcounter{gtt@elementid}{0}% - \setcounter{gtt@currgrid}{1}% \gtt@intitletrue% - \let\\\ganttnewline% -}{% + \ifgtt@newlineshortcut% + \let\\\ganttnewline% + \fi% + \let\ganttalignnewline\tikz@align@newline% +}{ % \end{macrocode} -% \end{macro}\end{intmacro} -% \begin{intmacro}{\x@left}\begin{intmacro}{\x@right}\begin{intmacro}{\y@upper}\begin{intmacro}{\y@lower} -% After the contents of the environment have been drawn, we add the canvas to the background layer. The |ganttchart| environment and all |\gantt...| macros save their $x$- and $y$-coordinates in local internal macros called |\x@left|, |\x@right|, |\y@upper| and |\y@lower|. The upper $y$-coordinate of the canvas is either zero or excludes the title lines if |include title in canvas| is false. The lower $y$-coordinate must take into account different $y$-units in the title and the rest of the chart. +% \end{macro} +% \end{macro} +% \begin{intmacro}{\y@upper} +% \begin{intmacro}{\y@lower} +% \begin{intmacro}{\y@mid} +% \begin{intmacro}{\y@size} +% \begin{intmacro}{\x@size} +% After the contents of the environment have been drawn, we add the canvas to the background layer. \pack{pgfgantt} saves $x$- and $y$-coordinates in local internal macros called |\x@left|, |\x@right|, |\x@mid|, |\x@size|, |\y@upper|, |\y@lower|, |\y@mid| and |\y@size|. % \begin{macrocode} \begin{scope}[on background layer]% \ifgtt@includetitle% \def\y@upper{0}% \else% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% + \gtt@lasttitleline * \ganttvalueof{y unit title}% }% \fi% \pgfmathsetmacro\y@lower{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + + (\gtt@currentline - \gtt@lasttitleline - 1)% * \ganttvalueof{y unit chart}% }% - \draw [/pgfgantt/canvas] - (0pt, \y@upper pt) rectangle - (\value{gtt@width} * \ganttvalueof{x unit}, \y@lower pt);% - \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% }% + \pgfmathsetmacro\y@size{% + abs(\y@lower - \y@upper)% + }% + \pgfmathsetmacro\x@size{% + \gtt@chartwidth * \ganttvalueof{x unit}% + }% + \node [/pgfgantt/canvas, minimum width=\x@size pt, + minimum height=\y@size pt] + at (\x@size pt / 2, \y@mid pt) {};% % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro}\end{intmacro} -% The contents of the vertical grid style list are evaluated at most |gtt@width|-times, but the loop breaks as soon as all grid lines have been drawn. +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% The contents of the vertical grid style list are evaluated at most |\gtt@chartwidth|-times, but the loop breaks as soon as all grid lines have been drawn. % \begin{macrocode} + \pgfmathsetmacro\y@upper{% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + }% \ifgtt@vgrid - \addtocounter{gtt@width}{-1}% - \foreach \x in {1,...,\value{gtt@width}} {% + \gtt@currgrid=1\relax% + \global\advance\gtt@chartwidth by-1\relax% + \foreach \x in {1,...,\gtt@chartwidth} {% \expandafter\gtt@vgrid@do\gtt@vgridstyle,\relax,% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi% + \ifnum\gtt@currgrid>\gtt@chartwidth\relax\breakforeach\fi% }% - \stepcounter{gtt@width}% + \global\advance\gtt@chartwidth by1\relax% \fi% % \end{macrocode} -% \begin{intmacro}{\hgrid@upper} % Now, we draw the horizontal grid. If we exclude the title from the canvas, we omit the uppermost horizontal grid line since it would coincide with the canvas border. % \begin{macrocode} \ifgtt@hgrid% - \ifgtt@includetitle% - \setcounter{gtt@currgrid}{\value{gtt@lasttitleline}}% - \else% - \pgfmathsetcounter{gtt@currgrid}{\value{gtt@lasttitleline}-1}% + \gtt@currgrid=\gtt@lasttitleline\relax% + \ifgtt@includetitle\else% + \advance\gtt@currgrid by-1\relax \fi% - \edef\hgrid@upper{\thegtt@currgrid}% - \foreach \t in {\hgrid@upper,...,\value{gtt@currentline}} {% + \edef\@tempa{\the\gtt@currgrid}% + \foreach \t in {\@tempa,...,\gtt@currentline} {% \expandafter\gtt@hgrid@do\gtt@hgridstyle,\relax,% - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi% + \ifnum\gtt@currgrid<\gtt@currentline\relax\breakforeach\fi% }% \fi% % \end{macrocode} -% \end{intmacro} +% \begin{intmacro}{\x@mid} % The last task of |ganttchart| is to apply the |today| key if its value differs from |none|. % \begin{macrocode} \def\@tempa{none}% \edef\@tempb{\ganttvalueof{today}}% \ifx\@tempa\@tempb\else% + \pgfmathsetmacro\x@mid{% + (\gtt@today@slot - 1 + \ganttvalueof{today offset})% + * \ganttvalueof{x unit}% + }% \draw [/pgfgantt/today rule] - (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@upper pt) -- - (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@lower pt);% - \node at (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@lower pt) - [anchor=north] {\ganttvalueof{today label}};% + (\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt) + node [/pgfgantt/today label node] {\ganttvalueof{today label}};% \fi% \end{scope}% % \end{macrocode} +% \end{intmacro} % At the end of a |ganttchart|, we also close the |tikzpicture| if we started it implicitly. % \begin{macrocode} \ifgtt@tikzpicture\else\end{tikzpicture}\fi% @@ -2737,70 +3467,147 @@ % \subsection{Starting a New Line} % % \begin{macro}{\ganttnewline} -% Unless the optional argument of |\ganttnewline| is empty, this macro adds a horizontal grid rule between the current and the new line. The style of this line is either |hgrid style| or the style specified in the optional argument. Anyway, |\ganttnewline| decreases |gtt@currentline| and, if we are still in the title, |gtt@lasttitleline|. Since the new line starts at time slot zero, |gtt@lasttitleslot| is reset.\changes{v2.0}{2011/10/10}{The optional argument of \cs{ganttnewline} now also accepts a style.} +% \begin{intmacro}{\local@drawarg} +% Unless the optional argument of |\ganttnewline| is empty, this macro adds a horizontal grid rule between the current and the new line. The style of this line, which is stored in |\local@drawarg|, is either |hgrid style| or the style specified in the optional argument. Anyway, |\ganttnewline| decreases |\gtt@currentline| and, if we are still in the title, |\gtt@lasttitleline|. Since the new line starts at time slot zero, |\gtt@lasttitleslot| is reset. % \begin{macrocode} \newcommand\ganttnewline[1][]{% - \def\@tempa{#1}% - \def\@tempb{grid}% - \ifx\@tempa\@empty\else - \ifx\@tempa\@tempb% - \def\@tempa{/pgfgantt/hgrid style}% + \begingroup% + \def\local@drawarg{#1}% + \def\@tempa{grid}% + \ifx\local@drawarg\@empty\else% + \ifx\local@drawarg\@tempa% + \def\local@drawarg{/pgfgantt/hgrid style}% \fi% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + + (\gtt@currentline - \gtt@lasttitleline - 1)% * \ganttvalueof{y unit chart}% } - \expandafter\draw\expandafter[\@tempa] + \expandafter\draw\expandafter[\local@drawarg] (0pt, \y@upper pt) -- - (\value{gtt@width} * \ganttvalueof{x unit}, \y@upper pt);% + (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);% \fi% - \addtocounter{gtt@currentline}{-1}% - \ifgtt@intitle\addtocounter{gtt@lasttitleline}{-1}\fi% - \setcounter{gtt@lasttitleslot}{0}% + \global\advance\gtt@currentline by-1\relax% + \ifgtt@intitle\global\advance\gtt@lasttitleline by-1\relax\fi% + \global\gtt@lasttitleslot=0\relax% + \endgroup% } % \end{macrocode} +% \end{intmacro} % \end{macro} % % -% \subsection{Title Elements} -% +% \subsection{Titles} +% +% \begin{option}{title} +% \begin{option}{title label font} +% \begin{option}{title label node} +% \begin{option}{title list options} +% \begin{intmacro}{\gtt@titlelistoptions} +% \begin{option}{title left shift} +% \begin{option}{title right shift} +% \begin{option}{title top shift} +% \begin{option}{title height} +% \begin{option}{include title in canvas} +% \begin{intmacro}{\ifgtt@includetitle} +% Keys that influence title elements. Note that |\@gtt@keydef| cannot define \opt{title list options}, since |\@gtt@titlelistoptions| is expanded after a |\foreach| statement, where |\ganttvalueof| will not work. +% \begin{macrocode} +\@gtt@stylekeydef{title}{shape=rectangle, inner sep=0pt, draw, fill=white} +\@gtt@keydef{title label font}{\small} +\@gtt@stylekeydef{title label node}{% + anchor=center, font=\ganttvalueof{title label font}% +} +\ganttset{% + title list options/.code={% + \def\gtt@titlelistoptions{[#1]}% + },% + title list options={var=\x, evaluate=\x}% +} +\@gtt@keydef{title left shift}{0} +\@gtt@keydef{title right shift}{0} +\@gtt@keydef{title top shift}{0} +\@gtt@keydef{title height}{.6} +\newif\ifgtt@includetitle +\ganttset{% + include title in canvas/.is if=gtt@includetitle,% + include title in canvas +} +% \end{macrocode} +% \end{intmacro} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{intmacro} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \begin{option}{calendar week text} +% \begin{option}{compress calendar} +% \begin{intmacro}{\ifgtt@compresscalendar} +% Keys for title calendars. +% \begin{macrocode} +\@gtt@keydef{calendar week text}{Week~\currentweek} +\newif\ifgtt@compresscalendar +\ganttset{% + compress calendar/.is if=gtt@compresscalendar,% + compress calendar=false% +} + +% \end{macrocode} +% \end{intmacro} +% \end{option} +% \end{option} % \begin{macro}{\gantttitle} -% |\gantttitle| draws a title element (i.\,e., a rectangle with a single node at its center). For reasons that will become clear below, the rectangle essentially starts at the $x$-coordinate stored in |gtt@lasttitleslot|. This counter is updated at the end of the macro. -% -% Note that in order to keep key changes local, all macros that draw chart elements set the keys specified as their optional argument within a group. +% \begin{intmacro}{\x@left} +% \begin{intmacro}{\x@right} +% |\gantttitle| draws a title element (i.\,e., a rectangle with a single node at its center). For reasons that will become clear below, the element essentially starts at the $x$-coordinate stored in |\gtt@lasttitleslot|. This count is updated at the end of the macro. % \begin{macrocode} \newcommand\gantttitle[3][]{% \begingroup% \ganttset{#1}% \pgfmathsetmacro\x@left{% - (\value{gtt@lasttitleslot} + \ganttvalueof{title left shift})% + (\gtt@lasttitleslot + \ganttvalueof{title left shift})% * \ganttvalueof{x unit}% }% \pgfmathsetmacro\x@right{% - (\value{gtt@lasttitleslot} + #3 + \ganttvalueof{title right shift})% + (\gtt@lasttitleslot + #3 + \ganttvalueof{title right shift})% * \ganttvalueof{x unit}% }% + \pgfmathsetmacro\x@mid{% + (\x@left + \x@right) / 2% + }% + \pgfmathsetmacro\x@size{% + \x@right - \x@left% + }% \pgfmathsetmacro\y@upper{% - (\value{gtt@currentline} - \ganttvalueof{title top shift})% + (\gtt@currentline - \ganttvalueof{title top shift})% * \ganttvalueof{y unit title}% }% \pgfmathsetmacro\y@lower{% - (\value{gtt@currentline} - \ganttvalueof{title top shift}% + (\gtt@currentline - \ganttvalueof{title top shift}% - \ganttvalueof{title height}) * \ganttvalueof{y unit title}% }% - \draw [/pgfgantt/title] - (\x@left pt, \y@upper pt) rectangle - (\x@right pt, \y@lower pt);% - \ganttvalueof{title label font}% - \node at ($(\x@left pt,\y@upper pt)!.5!(\x@right pt,\y@lower pt)$) - [/pgfgantt/title label anchor] {#2};% - \addtocounter{gtt@lasttitleslot}{#3}% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% + }% + \pgfmathsetmacro\y@size{% + \y@upper - \y@lower% + }% + \path (\x@mid pt, \y@mid pt) + node [/pgfgantt/title, minimum width=\x@size pt, + minimum height=\y@size pt] {} + node [/pgfgantt/title label node] {#2};% + \global\advance\gtt@lasttitleslot by#3\relax% \endgroup% } % \end{macrocode} +% \end{intmacro} +% \end{intmacro} % \end{macro} % \begin{macro}{\gantttitlelist} % |\gantttitlelist| generates title elements by repeatedly calling |\gantttitle|. Since the latter always starts after the last time slot occupied by the previous element, |\gantttitlelist| does not have to calculate the respective $x$-coordinates explicitly. @@ -2814,182 +3621,476 @@ % \end{macrocode} % \end{macro} +% \begin{intmacro}{\ifgtt@titlecalendarstar} +% \begin{macro}{\gantttitlecalendar} +% \begin{macro}{\gantttitlecalendar*} +% |\gantttitlecalendar| checks whether it is invoked in the starred or nonstarred form, sets |\ifgtt@titlecalendarstar| accordingly and then starts a command relaying chain. +% \begin{macrocode} +\newif\ifgtt@titlecalendarstar +\newcommand\gantttitlecalendar{% + \@ifstar% + {\gtt@titlecalendarstartrue\@gantttitlecalendar}% + {\gtt@titlecalendarstarfalse\@gantttitlecalendar}% +} + +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{intmacro} +% \begin{intmacro}{\@gantttitlecalendar} +% The first command in the relaying chain, |\@gantttitlecalendar|\oarg{options}, processes the \meta{options}. If it was executed by the starred form of |\gantttitlecalendar|, it calls the second command in the chain. Otherwise, it directly calls the third command in the chain. +% \begin{macrocode} +\newcommand\@gantttitlecalendar[1][]{ + \begingroup% + \ganttset{#1}% + \ifgtt@titlecalendarstar% + \expandafter\@@gantttitlecalendar% + \else% + \expandafter\@@@gantttitlecalendar\expandafter% + {\expandafter\gtt@startjulian\expandafter}\expandafter% + {\expandafter\gtt@endjulian\expandafter}% + \fi% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{intmacro}{\@@gantttitlecalendar} +% The second command in the relaying chain,\\|\@@gantttitlecalendar|\marg{start tss}\marg{end tss},\\reads two mandatory arguments from the input stream and converts them to Julian dates. Finally, it calls the third command in the chain. +% \begin{macrocode} +\newcommand\@@gantttitlecalendar[2]{ + \gtt@tsstojulian{#1}{\@tempcnta}% + \gtt@tsstojulian{#2}{\@tempcntb}% + \@@@gantttitlecalendar{\@tempcnta}{\@tempcntb}% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{intmacro}{\@@@gantttitlecalendar} +% \begin{intmacro}{\gtt@calendar@startdate} +% \begin{intmacro}{\gtt@calendar@enddate} +% The third and last command in the relaying chain, |\@@@gantttitlecalendar|\marg{start Julian}\marg{end Julian}\marg{calendar lines}, stores the start and end ISO-standard dates of the calendar in |\gtt@calendar@startdate| and |\gtt@calendar@enddate|, respectively. Then, it executes the keys in \meta{calendar lines}, which reside in path |/pgfgantt/calendar|. +% \begin{macrocode} +\newcommand\@@@gantttitlecalendar[3]{% + \pgfcalendarjuliantodate{#1}{\@tempa}{\@tempb}{\@tempc}% + \edef\gtt@calendar@startdate{\@tempa-\@tempb-\@tempc}% + \pgfcalendarjuliantodate{#2}{\@tempa}{\@tempb}{\@tempc}% + \edef\gtt@calendar@enddate{\@tempa-\@tempb-\@tempc}% + \gtt@calendar@eolfalse% + \pgfqkeys{/pgfgantt/calendar}{#3}% + \endgroup% +} +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \begin{intmacro}{\ifgtt@calendar@eol} +% \begin{intmacro}{\gtt@calendar@slots} +% \begin{intmacro}{\gtt@calendar@weeknumber} +% \begin{intmacro}{\gtt@calendar@startofweek} +% Booleans and counts for drawing title calendars: |\ifgtt@calendar@eol| is true if |\ganttcalendar| should start a new calendar line. |\gtt@calendar@slots| is the number of time slots a calendar element will cover. |\gtt@calendar@weeknumber| is the current week number in a calendar line of type |week|. |\gtt@calendar@startofweek| is the Julian date of the Monday in the current week. +% \begin{macrocode} +\newif\ifgtt@calendar@eol +\newcount\gtt@calendar@slots +\newcount\gtt@calendar@weeknumber +\newcount\gtt@calendar@startofweek +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% For each \meta{line type}, we define a corresponding key |/pgfgantt/calendar/|\meta{line type}. This key performs the necessary calculations and draws one or several |\gantttitle|s. Line type |year| draws years. +% \begin{macrocode} +\ganttset{% + calendar/year/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \ifgtt@compresscalendar% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{equals=12-31}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \gtt@calendar@slots=1\relax% + }{% + \ifdate{end of month=1}{% + \advance\gtt@calendar@slots by1\relax% + }{}% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifdate{end of month=1}{% + \advance\gtt@calendar@slots by-1\relax% + }{}% + \ifdate{equals=12-31}{}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + }% + }{}% + }% + \else% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{equals=12-31}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \gtt@calendar@slots=1\relax% + }{% + \advance\gtt@calendar@slots by1\relax% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \fi% + }{}% + }% + \fi% + \endgroup% + \gtt@calendar@eoltrue% + },% +% \end{macrocode} +% Line type |month|=\meta{format} draws months. Internally, a month is represented by a number between 1 (January) and 12 (December). However, when the title element is drawn, this number is fed to the macro |\pgfcalendarmonth|\meta{format} and possibly converted. +% \begin{macrocode} + calendar/month/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{end of month=1}{% + \gantttitle{% + \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% + }{% + \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + }% + \gtt@calendar@slots=1\relax% + }{% + \advance\gtt@calendar@slots by1\relax% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gantttitle{% + \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% + }{% + \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + }% + \fi% + }{}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% +% \end{macrocode} +% \begin{macro}{\startyear} +% \begin{macro}{\startmonth} +% \begin{macro}{\startday} +% \begin{macro}{\currentweek} +% Line type |week|=\meta{number} draws weeks. The first week receives \meta{number}, which is also saved in |\currentweek|. This key also defines the macros |\startyear|, |\startmonth| and |\startday|, which store the year, month and day of the current week's Monday. These four macros can be used in the value of \opt{calendar week text}. +% \begin{macrocode} + calendar/week/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \gtt@calendar@weeknumber=#1\relax% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{Sunday}{% + \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax% + \advance\gtt@calendar@startofweek by1\relax% + \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax% + \pgfcalendarjuliantodate{\gtt@calendar@startofweek}% + {\startyear}{\startmonth}{\startday}% + \def\currentweek{\the\gtt@calendar@weeknumber}% + \gantttitle{% + \ganttvalueof{calendar week text}% + }{% + \the\gtt@calendar@slots% + }% + \gtt@calendar@slots=1\relax% + \advance\gtt@calendar@weeknumber by1\relax% + }{% + \advance\gtt@calendar@slots by1% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax% + \advance\gtt@calendar@startofweek by1\relax% + \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax% + \pgfcalendarjuliantodate{\gtt@calendar@startofweek}% + {\startyear}{\startmonth}{\startday}% + \def\currentweek{\the\gtt@calendar@weeknumber}% + \gantttitle{% + \ganttvalueof{calendar week text}% + }{% + \the\gtt@calendar@slots% + }% + \fi% + }{}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% + calendar/week/.default=1,% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% Line type |weekday|=\meta{format} draws weekdays. Internally, a weekday is represented by a number between 0 (Monday) and 6 (Sunday). However, when the title element is drawn, this number is fed to the macro |\pgfcalendarweekday|\meta{format} and possibly converted. +% \begin{macrocode} + calendar/weekday/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \gantttitle{% + \csname pgfcalendarweekday#1\endcsname{\pgfcalendarcurrentweekday}% + }{1}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% +% \end{macrocode} +% Line type |day|=\meta{format} draws days of the month. +% \begin{macrocode} + calendar/day/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \gantttitle{\pgfcalendarcurrentday}{1}% + }% + \endgroup% + \gtt@calendar@eoltrue% + }% +} + +% \end{macrocode} +% % -% % \subsection{Chart Elements} -% -% All chart elements that can be linked (i.\,e. bars, groups and milestones) add a node of shape |chart element|, whose name equals the value of the |name| key (or ``|elem|\meta{number}'' if |name| is empty).\par -% A |chart element| node is a rectangle with eleven anchors: One in the center of the chart element (|center|); six anchors at the top, middle and bottom of the element's sides (|lower left| etc.); and four special anchors (|on left| etc.) that indicate a fractional coordinate between two corners of the shape. This fraction is stored in |\@gtt@linkanchorfraction|. The |\ganttlink| macro relies on these anchors for calculating the link coordinates.\par -% Whenever a chart element node is created, the four macros |\x@left|, |\x@right|, |\y@upper| and |\y@lower| must expand to a number which represents a dimension in points (e.\,g., see section~\ref{ssc:ImplBars}). Furthermore, if one calls the anchors |on left| etc., |\@gtt@linkanchorfraction| must contain a number between 0 and 1 (see section~\ref{ssc:ImplLinks}).\changes{v3.0}{2012/01/25}{The \texttt{chart element} shape supports four additional anchors (\texttt{on left}, \texttt{on top}, \texttt{on right} and \texttt{on bottom}).} +% +% \begin{option}{progress} +% \begin{intmacro}{\gtt@progress} +% \begin{option}{progress label text} +% \begin{intmacro}{\gtt@progresslabeltext} +% \begin{option}{name} +% \begin{option}{chart element start border} +% \begin{intmacro}{\ifgtt@ce@startatleftborder} +% \begin{option}{inline} +% \begin{intmacro}{\ifgtt@inline} +% Keys that apply to all chart elements. The parameter token |#1| in the value of \opt{progress label text} is replaced by the argument of |\gtt@progresslabeltext|. % \begin{macrocode} -\pgfdeclareshape{chart element}{% - \savedanchor\lowerleft{% - \pgfpoint{\x@left pt}{\y@lower pt}% - }% - \savedanchor\upperleft{% - \pgfpoint{\x@left pt}{\y@upper pt}% - }% - \savedanchor\lowerright{% - \pgfpoint{\x@right pt}{\y@lower pt}% - }% - \savedanchor\upperright{% - \pgfpoint{\x@right pt}{\y@upper pt}% - }% - \savedanchor\centerpoint{% - \pgfpoint{\x@right pt / 2 + \x@left pt / 2}% - {\y@upper pt / 2 + \y@lower pt / 2}% - }% - \anchor{on bottom}{% - \lowerleft% - \pgf@xa\pgf@x% - \lowerright% - \pgf@xb\pgf@x% - \advance\pgf@xb-\pgf@xa% - \advance\pgf@xa\@gtt@linkanchorfraction\pgf@xb% - \pgf@x\pgf@xa% - }% - \anchor{on left}{% - \upperleft% - \pgf@ya\pgf@y% - \lowerleft% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya\@gtt@linkanchorfraction\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{on top}{% - \upperleft% - \pgf@xa\pgf@x% - \upperright% - \pgf@xb\pgf@x% - \advance\pgf@xb-\pgf@xa% - \advance\pgf@xa\@gtt@linkanchorfraction\pgf@xb% - \pgf@x\pgf@xa% - }% - \anchor{on right}{% - \upperright% - \pgf@ya\pgf@y% - \lowerright% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya\@gtt@linkanchorfraction\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{center}{\centerpoint}% - \anchor{lower left}{\lowerleft}% - \anchor{left}{% - \upperleft% - \pgf@ya\pgf@y% - \lowerleft% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya.5\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{upper left}{\upperleft}% - \anchor{lower right}{\lowerright}% - \anchor{right}{% - \upperright% - \pgf@ya\pgf@y% - \lowerright% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya.5\pgf@yb% - \pgf@y\pgf@ya% +\ganttset{% + progress/.code={% + \def\gtt@progress{#1}% + },% + progress=none,% + progress label text/.code={% + \def\gtt@progresslabeltext##1{#1}% + },% + progress label text={% + \pgfmathprintnumber[precision=0, verbatim]{#1}\% complete% }% - \anchor{upper right}{\upperright}% +} +\@gtt@keydef{name}{} +\newif\ifgtt@ce@startatleftborder +\ganttset{% + chart element start border/.is choice,% + chart element start border/left/.code=\gtt@ce@startatleftbordertrue,%, + chart element start border/right/.code=\gtt@ce@startatleftborderfalse,% + chart element start border=left% +} +\newif\ifgtt@inline +\ganttset{% + inline/.is if=gtt@inline,% + inline=false% } % \end{macrocode} -% -% -% \subsection{Bars} -% \label{ssc:ImplBars} -% -% \begin{macro}{\ganttbar}\begin{intmacro}{\gtt@name} -% |\ganttbar| first defines the usual coordinate macros and adds a |chart element| node. This node is called |elem|\meta{number} if the |name| key is empty. +% \end{intmacro} +% \end{option} +% \end{intmacro} +% \end{option} +% \end{option} +% \end{intmacro} +% \end{option} +% \end{intmacro} +% \end{option} +% \begin{intmacro}{\gtt@lastelement} +% \begin{intmacro}{\gtt@currentelement} +% \begin{intmacro}{\ifgtt@draw@complete} +% \begin{intmacro}{\ifgtt@draw@incomplete} +% \begin{intmacro}{\ifgtt@draw@clip} +% \begin{intmacro}{\gtt@left@slot} +% \begin{intmacro}{\gtt@right@slot} +% The macros |\gtt@lastelement| and |\gtt@currentelement| save the name of the current and last chart element drawn. Thereby, the |\ganttlinked...| macros can add a link connecting them. |\ifgtt@draw@complete|, |\ifgtt@draw@incomplete| and |\ifgtt@draw@clip| decide whether to draw the complete and incomplete part of a chart element and if these parts are clipped. |\gtt@left@slot| and |\gtt@right@slot| store a chart element's start and end time slot, respectively. +% \begin{macrocode} +\def\gtt@lastelement{} +\def\gtt@currentelement{} +\newif\ifgtt@draw@complete +\newif\ifgtt@draw@incomplete +\newif\ifgtt@draw@clip +\newcount\gtt@left@slot +\newcount\gtt@right@slot + +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \end{intmacro} +% \begin{intmacro}{\gtt@chartelement} +% \begin{intmacro}{\local@timeslotmodifier} +% \begin{intmacro}{\gtt@name} +% |\gtt@chartelement|\oarg{options}\marg{label}\marg{start tss}\marg{end tss}\marg{type}\\is the generic command for drawing chart elements of a certain \meta{type}. First, |\gtt@chartelement| converts \meta{start tss} to |\gtt@left@slot| and \meta{end tss} to |\gtt@right@slot|. Then it calculates the usual coordinates. |\gtt@name| stores the name of the chart element. % \begin{macrocode} -\newcommand\ganttbar[4][]{% +\newcommand\gtt@chartelement[5][]{% \begingroup% \ganttset{#1}% + \gtt@tsstojulian{#3}{\gtt@left@slot}% + \gtt@juliantotimeslot{\gtt@left@slot}{\gtt@left@slot}% + \gtt@tsstojulian{#4}{\gtt@right@slot}% + \gtt@juliantotimeslot{\gtt@right@slot}{\gtt@right@slot}% + \def\local@timeslotmodifier{-1}% + \ifgtt@ce@startatleftborder\else% + \ifnum\gtt@left@slot=\gtt@right@slot\relax\else% + \def\local@timeslotmodifier{0}% + \fi% + \fi% \pgfmathsetmacro\x@left{% - (#3 + \ganttvalueof{time slot modifier}% - + \ganttvalueof{bar left shift})% + (\gtt@left@slot + \local@timeslotmodifier% + + \ganttvalueof{#5 left shift})% * \ganttvalueof{x unit}% }% \pgfmathsetmacro\x@right{% - (#4 + \ganttvalueof{bar right shift}) * \ganttvalueof{x unit}% + (\gtt@right@slot + \ganttvalueof{#5 right shift})% + * \ganttvalueof{x unit}% + }% + \pgfmathsetmacro\x@mid{% + (\x@left + \x@right) / 2% + }% + \pgfmathsetmacro\x@size{% + \x@right - \x@left% }% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - - \ganttvalueof{bar top shift}) * \ganttvalueof{y unit chart}% + \gtt@lasttitleline * \ganttvalueof{y unit title} + + (\gtt@currentline - \gtt@lasttitleline + - \ganttvalueof{#5 top shift}) * \ganttvalueof{y unit chart}% }% \pgfmathsetmacro\y@lower{% - \y@upper - \ganttvalueof{bar height} * \ganttvalueof{y unit chart}% + \y@upper - \ganttvalueof{#5 height} * \ganttvalueof{y unit chart}% + }% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% + }% + \pgfmathsetmacro\y@size{% + \y@upper - \y@lower% }% \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; + \ifx\gtt@name\@empty\edef\gtt@name{elem\the\gtt@elementid}\fi% % \end{macrocode} % \end{intmacro} -% \begin{intmacro}{\gtt@pl@draw} -% |\gtt@pl@draw| saves the commands that will produce the progress label. This macro does nothing unless (a) the |progress| key differs from |none| and (b) |progress label text| differs from |\relax|. Otherwise, it creates a vertically centered node to the right of the bar. +% \end{intmacro} +% \begin{intmacro}{\local@none} +% Depending on the values of \opt{progress} and \opt{today}, we determine the correct value for |\gtt@progress|. A value between 0 and 100 corresponds to a percentage of completeness. A value of 999 indicates that the chart element has no associated progress. % \begin{macrocode} - \def\@tempa{none}% - \ifx\gtt@progress\@tempa% - \def\gtt@progress{100}% - \let\gtt@pl@draw\relax% - \else - \expandafter\ifx\gtt@progresslabeltext\relax\relax% - \let\gtt@pl@draw\relax% - \else% - \def\gtt@pl@draw{% - \node at ($(\x@right pt, \y@upper pt)!.5! - (\x@right pt, \y@lower pt)$) - [/pgfgantt/progress label anchor] {% - \ganttvalueof{progress label font}{% - \gtt@progresslabeltext{\gtt@progress}% - }% - };% - }% + \def\local@none{none}% + \ifx\gtt@progress\local@none% + \def\gtt@progress{999}% + \else% + \def\@tempa{today}% + \ifx\gtt@progress\@tempa% + \edef\@tempa{\ganttvalueof{today}}% + \ifx\@tempa\local@none% + \@gtt@PackageWarning{% + Value of today is `none'. Ignoring `progress=today'% + }% + \def\gtt@progress{999}% + \else\ifnum\gtt@today@slot>\gtt@right@slot\relax% + \def\gtt@progress{100}% + \else\ifnum\gtt@today@slot<\gtt@left@slot\relax% + \def\gtt@progress{0}% + \else% + \pgfmathsetmacro\gtt@progress{% + (\gtt@today@slot - \gtt@left@slot - \local@timeslotmodifier)% + / (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)% + * 100% + }% + \fi\fi\fi% \fi% \fi% % \end{macrocode} % \end{intmacro} -% In order to draw the left (complete) and right (incomplete) part of a progress bar, we clip the corresponding rectangles depending on the value of |progress|. Note that we turn off the border of these rectangles and draw it with an additional, third command. +% \begin{intmacro}{\x@clip@size} +% Now we determine whether only the complete part of the chart element, only its incomplete one or both are drawn. In the former two cases, we refrain from clipping the (in)complete part. % \begin{macrocode} - \begin{scope}% - \clip (\x@left pt, \y@upper pt) rectangle - ($(\x@left pt, \y@lower pt)!\gtt@progress/100! - (\x@right pt, \y@lower pt)$);% - \draw [/pgfgantt/bar, draw=none] (\x@left pt, \y@upper pt) - rectangle (\x@right pt, \y@lower pt);% - \end{scope}% - \begin{scope}% - \clip ($(\x@left pt, \y@upper pt)!\gtt@progress/100! - (\x@right pt, \y@upper pt)$) - rectangle (\x@right pt, \y@lower pt);% - \draw [/pgfgantt/bar incomplete, draw=none] - (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);% - \end{scope}% - \draw [/pgfgantt/bar, fill=none] - (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);% - \gtt@pl@draw% + \gtt@draw@completetrue% + \gtt@draw@incompletetrue% + \gtt@draw@cliptrue% + \ifdim\gtt@progress pt<0.001pt\relax% + \gtt@draw@completefalse% + \gtt@draw@clipfalse% + \else\ifdim\gtt@progress pt>99.999pt\relax% + \gtt@draw@incompletefalse% + \gtt@draw@clipfalse% + \fi\fi% + \ifgtt@draw@clip% + \pgfmathsetmacro\x@clip@size{% + (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)% + * \gtt@progress / 100% + } + \pgfmathsetmacro\x@clip{% + (\gtt@left@slot + \local@timeslotmodifier + \x@clip@size% + + \ganttvalueof{today offset} - 1) * \ganttvalueof{x unit}% + }% + \fi% +% \end{macrocode} +% \end{intmacro} +% We draw the chart element within a |pgfinterruptboundingbox|, since we clip a large area of the canvas in order to avoid removing parts of the chart element border. +% \begin{macrocode} + \begin{pgfinterruptboundingbox}% + \begin{scope}% + \ifgtt@draw@clip% + \clip (\x@left pt - 10cm, \y@upper pt + 10cm) rectangle + (\x@clip pt, \y@lower pt - 10cm);% + \fi% + \ifgtt@draw@complete% + \node [/pgfgantt/#5, minimum width=\x@size pt, + minimum height=\y@size pt] + (\gtt@name) at (\x@mid pt, \y@mid pt) {};% + \fi% + \end{scope}% + \begin{scope}% + \ifgtt@draw@clip% + \clip (\x@clip pt, \y@upper pt + 10cm) rectangle + (\x@right pt + 10cm, \y@lower pt - 10cm);% + \fi% + \ifgtt@draw@incomplete% + \node [/pgfgantt/#5 incomplete, minimum width=\x@size pt, + minimum height=\y@size pt] + (\gtt@name) at (\x@mid pt, \y@mid pt) {};% + \fi% + \end{scope}% + \end{pgfinterruptboundingbox}% +% \end{macrocode} +% If \opt{progress} differs from |none| and \opt{progress label text} differs from |\relax|, the progress label is drawn. +% \begin{macrocode} + \ifdim\gtt@progress pt=999pt\relax\else% + \expandafter\ifx\gtt@progresslabeltext\relax\relax\else% + \node at (\gtt@name.\ganttvalueof{#5 progress label anchor}) + [/pgfgantt/#5 progress label node] + {\gtt@progresslabeltext{\gtt@progress}};% + \fi% + \fi% % \end{macrocode} -% If the first mandatory argument of |\ganttbar| is not empty, we print a label. Its anchor is either at the |bar label shape anchor| of the previously defined |chart element| node (|inline=true|) or at the left canvas border halfway between the upper and lower $y$-coordinate of the bar (|inline=false|). +% If \meta{label} is not empty, a label is printed. Its anchor is either at the \textcolor{OliveGreen}{\meta{type}}\opt{ inline label anchor} of the chart element (|inline=true|) or at the left canvas border halfway between the upper and lower $y$-coordinate of the chart element (|inline=false|). % \begin{macrocode} \def\@tempa{#2}% \ifx\@tempa\@empty\else% \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{bar label shape anchor}) - [/pgfgantt/bar label inline anchor] - {\ganttvalueof{bar label font}{\gtt@barlabeltext{#2}}};% + \node at (\gtt@name.\ganttvalueof{#5 inline label anchor}) + [/pgfgantt/#5 inline label node] + {\csname gtt@#5labeltext\endcsname{#2}};% \else% - \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$) - [/pgfgantt/bar label anchor] - {\ganttvalueof{bar label font}{\gtt@barlabeltext{#2}}};% + \node at (0, \y@mid pt) + [/pgfgantt/#5 label node] + {\csname gtt@#5labeltext\endcsname{#2}};% \fi% \fi% % \end{macrocode} @@ -2997,72 +4098,693 @@ % \begin{macrocode} \xdef\gtt@lastelement{\gtt@currentelement}% \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% + \global\advance\gtt@elementid by1\relax% \global\gtt@intitlefalse% \endgroup% } % \end{macrocode} +% \end{intmacro} +% \begin{macro}{\newganttchartelement} +% \begin{macro}{\newganttchartelement*} +% |\newganttchartelement| checks whether it was invoked in the starred or nonstarred form and executes |\@newganttchartelement@one| or |\@newganttchartelement@two|, respectively. +% \begin{macrocode} +\def\newganttchartelement{% + \@ifstar\@newganttchartelement@one\@newganttchartelement@two% +} + +% \end{macrocode} +% \end{macro} % \end{macro} +% \begin{intmacro}{\@newganttchartelement@one} +% \begin{intmacro}{\@newganttchartelement@two} +% Both |\@newganttchartelement@one|\marg{type} and |...two|\marg{type} define two macros |\gantt|\meta{type} and |\ganttlinked|\meta{type}, which draw a singular chart element or one that is linked to its predecessor. However, the newly defined macros will take three or four mandatory arguments (cf. |\ganttmilestone| vs. |\ganttbar|). At the end, we execute |\@newganttchartelement@definekeys| to process the second mandatory argument of |\newganttchartelement|. +% \begin{macrocode} +\newcommand\@newganttchartelement@one[1]{% + \expandafter\newcommand\csname gantt#1\endcsname[3][]{% + \gtt@chartelement[##1]{##2}{##3}{##3}{#1}% + }% + \expandafter\newcommand\csname ganttlinked#1\endcsname[3][]{% + \begingroup% + \ganttset{##1}% + \gtt@chartelement{##2}{##3}{##3}{#1}% + \ganttlink{\gtt@lastelement}{\gtt@currentelement}% + \endgroup% + }% + \@newganttchartelement@definekeys{#1}% +} + +\newcommand\@newganttchartelement@two[1]{% + \expandafter\newcommand\csname gantt#1\endcsname[4][]{% + \gtt@chartelement[##1]{##2}{##3}{##4}{#1}% + }% + \expandafter\newcommand\csname ganttlinked#1\endcsname[4][]{% + \begingroup% + \ganttset{##1}% + \gtt@chartelement{##2}{##3}{##4}{#1}% + \ganttlink{\gtt@lastelement}{\gtt@currentelement}% + \endgroup% + }% + \@newganttchartelement@definekeys{#1}% +} + +% \end{macrocode} +% \end{intmacro} +% \end{intmacro} +% \begin{intmacro}{\@newganttchartelement@definekeys} +% |\@newganttchartelement@definekeys|\marg{type}\marg{key-value list} introduces 14 keys for the newly generated chart element \meta{type}. +% \begin{macrocode} +\newcommand\@newganttchartelement@definekeys[2]{% + \@gtt@stylekeydef{#1}{shape=rectangle, inner sep=0pt, draw, fill=white}% + \@gtt@stylekeydef{#1 incomplete}{/pgfgantt/#1, fill=black!25}% + \@gtt@keydef{#1 label font}{\normalsize}% + \@gtt@stylekeydef{#1 label node}{% + anchor=east, font=\ganttvalueof{#1 label font}% + }% + \@gtt@keydef{#1 inline label anchor}{center}% + \@gtt@stylekeydef{#1 inline label node}{% + anchor=center, font=\ganttvalueof{#1 label font}% + }% + \@gtt@keydef{#1 progress label anchor}{east}% + \@gtt@keydef{#1 progress label font}{\scriptsize}% + \@gtt@stylekeydef{#1 progress label node}{% + anchor=west, font=\ganttvalueof{#1 progress label font}% + }% + \@gtt@keydef{#1 left shift}{0}% + \@gtt@keydef{#1 right shift}{0}% + \@gtt@keydef{#1 top shift}{.3}% + \@gtt@keydef{#1 height}{.4}% + \ganttset{% + #1 label text/.code={% + \expandafter\def\csname gtt@#1labeltext\endcsname####1{##1}% + },% + #1 label text=\strut##1,% + #2% + }% +} + +% \end{macrocode} +% \end{intmacro} +% \begin{macro}{\ganttbar} % \begin{macro}{\ganttlinkedbar} -% The shortcut version |\ganttlinkedbar| calls both |\ganttbar| and |\ganttlink|. +% \begin{option}{bar} +% \begin{option}{bar incomplete} +% \begin{option}{bar label text} +% \begin{option}{bar label font} +% \begin{option}{bar label node} +% \begin{option}{bar inline label anchor} +% \begin{option}{bar inline label node} +% \begin{option}{bar progress label anchor} +% \begin{option}{bar progress label font} +% \begin{option}{bar progress label node} +% \begin{option}{bar left shift} +% \begin{option}{bar right shift} +% \begin{option}{bar top shift} +% \begin{option}{bar height} +% Code for the predefined chart element type |bar|. % \begin{macrocode} -\newcommand\ganttlinkedbar[4][]{% - \begingroup% - \ganttset{#1}% - \ganttbar{#2}{#3}{#4}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% - \endgroup% +\newganttchartelement{bar}{% + bar/.style={shape=ganttbar, inner sep=0pt, draw, fill=white},% + bar incomplete/.style={/pgfgantt/bar, fill=black!25},% + bar label text=\strut#1,% + bar label font=\normalsize,% + bar label node/.style={% + anchor=east, font=\ganttvalueof{bar label font}% + },% + bar inline label anchor=center,% + bar inline label node/.style={% + anchor=center, font=\ganttvalueof{bar label font}% + },% + bar progress label anchor=east,% + bar progress label font=\scriptsize,% + bar progress label node/.style={% + anchor=west, font=\ganttvalueof{bar progress label font}% + },% + bar left shift=0,% + bar right shift=0,% + bar top shift=.3,% + bar height=.4% +} + +% \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{macro} +% \end{macro} +% \clearpage +% \begin{macro}{\ganttgroup} +% \begin{macro}{\ganttlinkedgroup} +% \begin{option}{group} +% \begin{option}{group incomplete} +% \begin{option}{group label text} +% \begin{option}{group label font} +% \begin{option}{group label node} +% \begin{option}{group inline label anchor} +% \begin{option}{group inline label node} +% \begin{option}{group progress label anchor} +% \begin{option}{group progress label font} +% \begin{option}{group progress label node} +% \begin{option}{group left shift} +% \begin{option}{group right shift} +% \begin{option}{group top shift} +% \begin{option}{group height} +% Code for the predefined chart element type |group|. +% \begin{macrocode} +\newganttchartelement{group}{% + group/.style={shape=ganttgroup, inner sep=0pt, fill=black},% + group incomplete/.style={/pgfgantt/group, fill=black!25},% + group label text=\strut#1,% + group label font=\bfseries,% + group label node/.style={% + anchor=east, font=\ganttvalueof{group label font}% + },% + group inline label anchor=center,% + group inline label node/.style={% + anchor=south, font=\ganttvalueof{group label font}% + },% + group progress label anchor=east,% + group progress label font=\scriptsize,% + group progress label node/.style={% + anchor=west, font=\ganttvalueof{group progress label font}% + },% + group left shift=-.1,% + group right shift=.1,% + group top shift=.4,% + group height=.2% +} +% \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{macro} +% \end{macro} +% \begin{option}{group right peak tip position} +% \begin{option}{group right peak width} +% \begin{option}{group right peak height} +% \begin{option}{group left peak tip position} +% \begin{option}{group left peak width} +% \begin{option}{group left peak height} +% \begin{option}{group peaks tip position} +% \begin{option}{group peaks width} +% \begin{option}{group peaks height} +% More keys for the appearance of groups. +% \begin{macrocode} +\@gtt@keydef{group right peak tip position}{.5} +\@gtt@keydef{group right peak width}{.4} +\@gtt@keydef{group right peak height}{.1} +\@gtt@keydef{group left peak tip position}{.5} +\@gtt@keydef{group left peak width}{.4} +\@gtt@keydef{group left peak height}{.1} +\ganttset{% + group peaks tip position/.code={% + \ganttset{% + group left peak tip position=#1,% + group right peak tip position=#1% + }% + },% + group peaks width/.code={% + \ganttset{% + group left peak width=#1,% + group right peak width=#1% + }% + },% + group peaks height/.code={% + \ganttset{% + group left peak height=#1,% + group right peak height=#1% + }% + }% +} + +% \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \begin{macro}{\ganttmilestone} +% \begin{macro}{\ganttlinkedmilestone} +% \begin{option}{milestone} +% \begin{option}{milestone incomplete} +% \begin{option}{milestone label text} +% \begin{option}{milestone label font} +% \begin{option}{milestone label node} +% \begin{option}{milestone inline label anchor} +% \begin{option}{milestone inline label node} +% \begin{option}{milestone progress label anchor} +% \begin{option}{milestone progress label font} +% \begin{option}{milestone progress label node} +% \begin{option}{milestone left shift} +% \begin{option}{milestone right shift} +% \begin{option}{milestone top shift} +% \begin{option}{milestone height} +% Code for the predefined chart element type |milestone|. +% \begin{macrocode} +\newganttchartelement*{milestone}{% + milestone/.style={% + shape=ganttmilestone, inner sep=0pt, draw, fill=black% + },% + milestone incomplete/.style={/pgfgantt/milestone, fill=black!25},% + milestone label text=\strut#1,% + milestone label font=\itshape,% + milestone label node/.style={% + anchor=east, font=\ganttvalueof{milestone label font}% + },% + milestone inline label anchor=center,% + milestone inline label node/.style={% + anchor=south, font=\ganttvalueof{milestone label font}% + },% + milestone progress label anchor=center,% + milestone progress label font=\scriptsize,% + milestone progress label node/.style={% + anchor=west, font=\ganttvalueof{milestone progress label font}% + },% + milestone left shift=.6,% + milestone right shift=.4,% + milestone top shift=.3,% + milestone height=.4% } % \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} % \end{macro} +% \end{macro} +% +% +% \subsection{Node Shapes} +% +% \begin{option}{on top fraction} +% \begin{option}{on bottom fraction} +% \begin{option}{on left fraction} +% \begin{option}{on right fraction} +% Keys for configuring the additional anchors of the new node shapes. +% \begin{macrocode} +\@gtt@keydef{on top fraction}{.5} +\@gtt@keydef{on bottom fraction}{.5} +\@gtt@keydef{on left fraction}{.5} +\@gtt@keydef{on right fraction}{.5} + +% \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% Code for node shape |ganttbar|. Anchors and background path derive from node shape |rectangle|. The four additional anchors |on top|, |on bottom|, |on left| and |on right| are defined. +% \begin{macrocode} +\pgfdeclareshape{ganttbar}{ + \inheritsavedanchors[from=rectangle] + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{south east} + \inheritanchorborder[from=rectangle] + \anchor{on top}{ + \southwest + \pgf@xa=\pgf@x + \northeast + \pgf@xb=\pgf@x + \advance\pgf@xb by-\pgf@xa + \pgf@xb=\ganttvalueof{on top fraction}\pgf@xb + \advance\pgf@xa by\pgf@xb + \pgf@x=\pgf@xa + } + \anchor{on bottom}{ + \northeast + \pgf@xb=\pgf@x + \southwest + \pgf@xa=\pgf@x + \advance\pgf@xb by-\pgf@xa + \pgf@xb=\ganttvalueof{on bottom fraction}\pgf@xb + \advance\pgf@xa by\pgf@xb + \pgf@x=\pgf@xa + } + \anchor{on left}{ + \northeast + \pgf@ya=\pgf@y + \southwest + \pgf@yb=\pgf@y + \advance\pgf@yb by-\pgf@ya + \pgf@yb=\ganttvalueof{on left fraction}\pgf@yb + \advance\pgf@ya by\pgf@yb + \pgf@y=\pgf@ya + } + \anchor{on right}{ + \southwest + \pgf@yb=\pgf@y + \northeast + \pgf@ya=\pgf@y + \advance\pgf@yb by-\pgf@ya + \pgf@yb=\ganttvalueof{on right fraction}\pgf@yb + \advance\pgf@ya by\pgf@yb + \pgf@y=\pgf@ya + } + \inheritbackgroundpath[from=rectangle] +} + +% \end{macrocode} +% Code for node shape |ganttgroup|. Anchors derive from node shape |ganttbar|. The two additional anchors |left peak| and |right peak| are defined. +% \begin{macrocode} +\pgfdeclareshape{ganttgroup}{ + \inheritsavedanchors[from=rectangle] + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{south east} + \inheritanchorborder[from=rectangle] + \inheritanchor[from=ganttbar]{on top} + \inheritanchor[from=ganttbar]{on bottom} + \inheritanchor[from=ganttbar]{on left} + \inheritanchor[from=ganttbar]{on right} + \anchor{left peak}{ + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgfmathsetlength\pgf@x{ + \pgf@x + \ganttvalueof{group left peak tip position} + * \ganttvalueof{group left peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@y{ + \pgf@y - \ganttvalueof{group left peak height} + * \ganttvalueof{y unit chart} + } + } + \anchor{right peak}{ + \pgf@process{ + \pgfpointadd{ + \northeast + }{ + \pgfpointscale{-1}{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + } + \pgf@xa=\pgf@x + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgfmathsetlength\pgf@x{ + \pgf@xa - \ganttvalueof{group right peak tip position} + * \ganttvalueof{group right peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@y{ + \pgf@y - \ganttvalueof{group right peak height} + * \ganttvalueof{y unit chart} + } + } + \backgroundpath{ + \pgf@process{ + \pgfpointadd{ + \northeast + }{ + \pgfpointscale{-1}{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + } + \pgf@xb=\pgf@x + \pgf@ya=\pgf@y + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgf@xa=\pgf@x + \pgf@yb=\pgf@y + \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xb - \ganttvalueof{group right peak tip position} + * \ganttvalueof{group right peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@yc{ + \pgf@yb - \ganttvalueof{group right peak height} + * \ganttvalueof{y unit chart} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}} + \pgfmathsetlength\pgf@xc{ + \pgf@xb - \ganttvalueof{group right peak width} + * \ganttvalueof{x unit} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xa + \ganttvalueof{group left peak width} + * \ganttvalueof{x unit} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xa + \ganttvalueof{group left peak tip position} + * \ganttvalueof{group left peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@yc{ + \pgf@yb - \ganttvalueof{group left peak height} + * \ganttvalueof{y unit chart} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}} + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} + \pgfpathclose + } +} + +% \end{macrocode} +% Code for node shape |ganttmilestone|. Anchors and background path derive from node shape |diamond|. The four additional anchors |on top|, |on bottom|, |on left| and |on right| are defined. +% \begin{macrocode} +\pgfdeclareshape{ganttmilestone}{ + \inheritsavedanchors[from=diamond] + \inheritanchor[from=diamond]{text} + \inheritanchor[from=diamond]{center} + \inheritanchor[from=diamond]{mid} + \inheritanchor[from=diamond]{base} + \inheritanchor[from=diamond]{north} + \inheritanchor[from=diamond]{south} + \inheritanchor[from=diamond]{west} + \inheritanchor[from=diamond]{north west} + \inheritanchor[from=diamond]{south west} + \inheritanchor[from=diamond]{east} + \inheritanchor[from=diamond]{north east} + \inheritanchor[from=diamond]{south east} + \inheritanchorborder[from=diamond] + \inheritbackgroundpath[from=diamond] + \anchor{on top}{ + \pgf@process{\outernortheast} + \pgf@xa=2\pgf@x + \pgf@x=-\pgf@x + \advance\pgf@x by\ganttvalueof{on top fraction}\pgf@xa + \pgf@ya=2\pgf@y + \pgf@y=0pt + \pgfmathparse{ + \ganttvalueof{on top fraction} < 0.5 + ? \ganttvalueof{on top fraction} + : 1 - \ganttvalueof{on top fraction} + } + \advance\pgf@y by\pgfmathresult\pgf@ya + } + \anchor{on bottom}{ + \pgf@process{\outernortheast} + \pgf@xa=2\pgf@x + \pgf@x=-\pgf@x + \advance\pgf@x by\ganttvalueof{on bottom fraction}\pgf@xa + \pgf@ya=-2\pgf@y + \pgf@y=0pt + \pgfmathparse{ + \ganttvalueof{on bottom fraction} < 0.5 + ? \ganttvalueof{on bottom fraction} + : 1 - \ganttvalueof{on bottom fraction} + } + \advance\pgf@y by\pgfmathresult\pgf@ya + } + \anchor{on right}{ + \pgf@process{\outernortheast} + \pgf@ya=-2\pgf@y + \advance\pgf@y by\ganttvalueof{on right fraction}\pgf@ya + \pgf@xa=2\pgf@x + \pgf@x=0pt + \pgfmathparse{ + \ganttvalueof{on right fraction} < 0.5 + ? \ganttvalueof{on right fraction} + : 1 - \ganttvalueof{on right fraction} + } + \advance\pgf@x by\pgfmathresult\pgf@xa + } + \anchor{on left}{ + \pgf@process{\outernortheast} + \pgf@ya=-2\pgf@y + \advance\pgf@y by\ganttvalueof{on left fraction}\pgf@ya + \pgf@xa=-2\pgf@x + \pgf@x=0pt + \pgfmathparse{ + \ganttvalueof{on left fraction} < 0.5 + ? \ganttvalueof{on left fraction} + : 1 - \ganttvalueof{on left fraction} + } + \advance\pgf@x by\pgfmathresult\pgf@xa + } +} + +% \end{macrocode} +% % % \subsection{Links} % \label{ssc:ImplLinks} -% +% +% \begin{option}{link} +% \begin{option}{link type} +% \begin{option}{link label} +% \begin{option}{link label font} +% \begin{option}{link label node} +% Keys for configuring links. +% \begin{macrocode} +\@gtt@stylekeydef{link}{-latex, rounded corners=1pt} +\@gtt@keydef{link type}{auto} +\@gtt@keydef{link label}{} +\@gtt@keydef{link label font}{\scriptsize\itshape} +\@gtt@stylekeydef{link label node}{% + anchor=west, font=\ganttvalueof{link label font}% +} +% \end{macrocode} +% \end{option} +% \end{option} +% \end{option} +% \end{option} +% \end{option} % \begin{macro}{\newganttlinktype} -% |\newganttlinktype| stores the contents of its second argument in an internal macro of the form |\@gtt@linktype@|\meta{type}, which is later called by |\gtt@drawlink|. +% |\newganttlinktype|\marg{type}\marg{code} stores \meta{code} in an internal macro\\|\@gtt@linktype@|\meta{type}, which is later called by |\gtt@drawlink|. % \begin{macrocode} \newcommand\newganttlinktype[2]{% \expandafter\def\csname @gtt@linktype@#1\endcsname{#2}% } % \end{macrocode} -% \end{macro}\begin{macro}{\newganttlinktypealias} -% |\newganttlinktypealias| copies both the link code and label of an existing link type (second argument) into the internal macros associated with a new link type (first argument). +% \end{macro} +% \begin{macro}{\setganttlinklabel} +% |\setganttlinklabel|\marg{type}\marg{label} stores a given \meta{label} in an internal macro |\@gtt@linktype@|\meta{type}|@label|, which is later used by |\gtt@drawlink|. +% \begin{macrocode} +\newcommand\setganttlinklabel[2]{% + \expandafter\def\csname @gtt@linktype@#1@label\endcsname{#2}% +} + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\newganttlinktypealias} +% |\newganttlinktypealias|\marg{new link type}\marg{existing link type} copies both the link code and label of an \meta{existing link type} into the internal macros associated with a \meta{new link type}. % \begin{macrocode} \newcommand\newganttlinktypealias[2]{% \expandafter\def\csname @gtt@linktype@#1\endcsname{% - \@nameuse{@gtt@linktype@#2}% + \csname @gtt@linktype@#2\endcsname% }% \expandafter\def\csname @gtt@linktype@#1@label\endcsname{% - \@nameuse{@gtt@linktype@#2@label}% + \csname @gtt@linktype@#2@label\endcsname% }% } % \end{macrocode} -% \end{macro}\begin{macro}{\setganttlinklabel} -% |\setganttlinklabel| stores a given label (second argument) in an internal macro of the form |\@gtt@linktype@|\meta{type}|@label|, which is later used by |\gtt@drawlink|.\changes{v3.0}{2012/01/25}{\cs{setganttlinklabel} specifies the label for all links of a certain type. The \texttt{link label} key locally overrides any label set by this command.} +% \end{macro} +% \begin{option}{link mid} +% \begin{option}{link bulge} +% \begin{option}{link tolerance} +% We will define three link subtypes for the type |auto|, which require the following keys: % \begin{macrocode} -\newcommand\setganttlinklabel[2]{% - \expandafter\def\csname @gtt@linktype@#1@label\endcsname{#2}% -} - +\@gtt@keydef{link mid}{.5} +\@gtt@keydef{link bulge}{.4} +\@gtt@keydef{link tolerance}{.6} % \end{macrocode} -% \end{macro} -% We define three link types for the automatic mode (|link type=auto|; in former versions of \pack{pgfgantt}, these links were called arrow-like). Firstly, |r| (short for ``right'') draws a straight arrow. Note that |r| and |default| are alias types. +% \end{option} +% \end{option} +% \end{option} +% (1) |r| (short for ``right'') draws a straight arrow. Note that |r| and |default| are alias types. % \begin{macrocode} \newganttlinktype{r}{% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \newganttlinktypealias{default}{r} % \end{macrocode} -% Secondly, |rdr| (``right-down-right'') is an unlabeled three-part arrow. The value of |link mid| sets the position of the middle segment. +% (2) |rdr| (``right-down-right'') is an unlabeled three-part arrow. The value of \opt{link mid} sets the position of the middle segment. % \begin{macrocode} \newganttlinktype{rdr}{% \draw [/pgfgantt/link] @@ -3075,7 +4797,7 @@ } % \end{macrocode} -% Thirdly, |rdldr| (``right-down-left-down-right'') is an unlabeled five-part arrow, which considers the values of |link bulge| and |link mid|. +% (3) |rdldr| (``right-down-left-down-right'') is an unlabeled five-part arrow, which considers the values of \opt{link bulge} and \opt{link mid}. % \begin{macrocode} \newganttlinktype{rdldr}{% \draw [/pgfgantt/link] @@ -3098,15 +4820,40 @@ } % \end{macrocode} -% The |dr| type was explained in section~\ref{ssc:links}. +% Now we may define linke type |auto|: The first and last coordinate of the link should touch the preceding or following element at the center of its right or left border, respectively. We check if the connected elements lie in the same row or not (i. e., their $y$-coordinates differ at most 1~pt). In the latter case, |\pgfmathparse| yields 0. +% \begin{macrocode} +\newganttlinktype{auto}{% + \pgfmathparse{abs(\yUpper - \yLower) <= 1}% + \ifcase\pgfmathresult% +% \end{macrocode} +% Once again, two possibilities arise: Either the elements to be connected are at least separated by \opt{link tolerance} time slots, in which case we draw a three-part arrow (i. e., link type |rdr|). Alternatively, the elements lie in adjacent time slots or even overlap, in which case we draw a five-part arrow (i. e., link type |rdldr|). +% \begin{macrocode} + \pgfmathparse{ + (\xRight - \xLeft) + >= \ganttvalueof{link tolerance} * \ganttvalueof{x unit} + }% + \ifcase\pgfmathresult% + \gtt@drawlink{rdldr}% + \else% + \gtt@drawlink{rdr}% + \fi% +% \end{macrocode} +% For elements that lie in the same row, we draw a simple arrow (i. e., link type |r|). +% \begin{macrocode} + \else% + \gtt@drawlink{r}% + \fi% +} +% \end{macrocode} +% The |dr| type is explained in section~\ref{ssc:Links}. % \begin{macrocode} \newganttlinktype{dr}{% - \ganttsetstartanchor{on bottom=.6}% - \ganttsetendanchor{on left}% + \ganttsetstartanchor{south}% + \ganttsetendanchor{west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xLeft, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel} -- + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel} -- (\xRight, \yLower);% } @@ -3114,12 +4861,12 @@ % Here is the definition of the four straight link types and their labels. % \begin{macrocode} \newganttlinktype{s-s}{% - \ganttsetstartanchor{on bottom=0}% - \ganttsetendanchor{on top=0}% + \ganttsetstartanchor{south west}% + \ganttsetendanchor{north west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{s-s}{start-to-start} @@ -3129,415 +4876,162 @@ \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{s-f}{start-to-finish} \newganttlinktype{f-s}{% - \ganttsetstartanchor{on bottom=1}% - \ganttsetendanchor{on top=0}% + \ganttsetstartanchor{south east}% + \ganttsetendanchor{north west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{f-s}{finish-to-start} \newganttlinktype{f-f}{% - \ganttsetstartanchor{on bottom=1}% - \ganttsetendanchor{on top=1}% + \ganttsetstartanchor{south east}% + \ganttsetendanchor{north east}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{f-f}{finish-to-finish} % \end{macrocode} -% \begin{intmacro}{\gtt@drawlink}\begin{intmacro}{\@gtt@currlinktype} -% |\gtt@drawlink| first checks if the link type given as first argument is defined, falling back to the default type if it is unknown. |\@gtt@currlinktype| stores the link type for future reference. +% \begin{intmacro}{\gtt@drawlink} +% \begin{intmacro}{\@gtt@currlinktype} +% |\gtt@drawlink|\marg{link type} first checks if the \meta{link type} is defined, falling back to type |default| if it is unknown. |\@gtt@currlinktype| stores the link type for future reference. % \begin{macrocode} \newcommand\gtt@drawlink[1]{% \@ifundefined{@gtt@linktype@#1}{% - \PackageWarning{pgfgantt}{Link type `#1' unknown, using `default'.}% + \@gtt@PackageWarning{Link type `#1' unknown, using `default'.}% \def\@gtt@currlinktype{default}% }{% \def\@gtt@currlinktype{#1}% }% % \end{macrocode} -% \end{intmacro}\begin{intmacro}{\@gtt@currlabel}\begin{macro}{\ganttlinklabel} -% If the |link label| key contains any value, it locally overrides the label set by |\setganttlinklabel|. |\ganttlinklabel| is defined accordingly, taking into account the |link label font|. +% \end{intmacro} +% \begin{intmacro}{\@gtt@currlabel} +% \begin{macro}{\ganttlinklabel} +% If the \opt{link label} key contains any value, it locally overrides the label set by |\setganttlinklabel|. |\ganttlinklabel| is defined accordingly. % \begin{macrocode} \edef\@gtt@currlabel{\ganttvalueof{link label}}% \ifx\@gtt@currlabel\@empty% \def\ganttlinklabel{% - \ganttvalueof{link label font}{% - \csname @gtt@linktype@\@gtt@currlinktype @label\endcsname% - }% + \csname @gtt@linktype@\@gtt@currlinktype @label\endcsname% }% \else% - \def\ganttlinklabel{% - \ganttvalueof{link label font}{% - \@gtt@currlabel% - }% + \edef\ganttlinklabel{% + \ganttvalueof{link label}% }% \fi% % \end{macrocode} -% \end{macro}\end{intmacro} +% \end{macro} +% \end{intmacro} % Finally, we call the internal macro that stores the code for the desired link type. % \begin{macrocode} - \@nameuse{@gtt@linktype@\@gtt@currlinktype}% + \csname @gtt@linktype@\@gtt@currlinktype\endcsname% } % \end{macrocode} -% \end{intmacro}\begin{intmacro}{\@gtt@linkanchordef}\begin{intmacro}{\@gtt@linkanchor}\begin{intmacro}{\@gtt@linkanchorfraction} -% The internal macro |\@gtt@linkanchordef{|\meta{anchor}|}| defines valid \meta{anchor}s for |\ganttsetstartanchor| and |\ganttsetendanchor| (see below). For each \meta{anchor}, a key |/pgfgantt/link anchor/|\meta{anchor} is created, which stores its own name in |\@gtt@linkanchor| and its value in |\@gtt@linkanchorfraction|. +% \end{intmacro} +% \begin{intmacro}{\@gtt@link@anchor} +% We need the following keys for setting the start and end anchor of a link: Whenever a key |/pgfgantt/link anchor/|\meta{anchor} is undefined, \pack{pgfgantt} stores \meta{anchor} in |\@gtt@link@anchor|. +% \begin{macrocode} +\ganttset{% + link anchor/.unknown/.code={% + \edef\@gtt@link@anchor{\pgfkeyscurrentname}% + },% +} +% \end{macrocode} +% \end{intmacro} +% \begin{intmacro}{\@gtt@linkanchordef} +% |\@gtt@linkanchordef|\marg{anchor} deals with the anchors |on top| etc.: It creates a code key |/pgfgantt/link anchor/|\meta{anchor}, which stores its own name in |\@gtt@link@anchor| and sets the appropriate \opt{\dots fraction} key. % \begin{macrocode} \def\@gtt@linkanchordef#1{% \ganttset{% link anchor/#1/.code={% - \def\@gtt@linkanchor{#1}% - \def\@gtt@linkanchorfraction{##1}% + \edef\@gtt@link@anchor{#1}% + \ganttset{#1 fraction=##1}% },% link anchor/#1/.default=.5% - } + }% } -\@gtt@linkanchordef{on left} -\@gtt@linkanchordef{on right} \@gtt@linkanchordef{on top} \@gtt@linkanchordef{on bottom} -\@gtt@linkanchordef{lower left} -\@gtt@linkanchordef{left} -\@gtt@linkanchordef{upper left} -\@gtt@linkanchordef{lower right} -\@gtt@linkanchordef{right} -\@gtt@linkanchordef{upper right} +\@gtt@linkanchordef{on left} +\@gtt@linkanchordef{on right} % \end{macrocode} -% \end{intmacro}\end{intmacro}\end{intmacro}\begin{intmacro}{\@gtt@setstartanchor}\begin{macro}{\xLeft}\begin{macro}{\yUpper} -% |\@gtt@setstartanchor| recalls the coordinates of the anchor |\@gtt@linkanchor| from chart element |\@gtt@startelement|. It stores the coordinates in the auxiliary macros |\xLeft| and |\yUpper|. +% \end{intmacro} +% \begin{intmacro}{\@gtt@setstartanchor} +% \begin{macro}{\xLeft} +% \begin{macro}{\yUpper} +% |\@gtt@setstartanchor|\marg{anchor} recalls the coordinates of the anchor stored in |\@gtt@link@anchor| from chart element |\@gtt@link@startelement|. It stores these coordinates in the auxiliary macros |\xLeft| and |\yUpper|. % \begin{macrocode} \newcommand\@gtt@setstartanchor[1]{% \pgfqkeys{/pgfgantt/link anchor}{#1}% - \pgfpointanchor{\@gtt@startelement}{\@gtt@linkanchor}% + \pgfpointanchor{\@gtt@link@startelement}{\@gtt@link@anchor}% \edef\xLeft{\the\pgf@x}% \edef\yUpper{\the\pgf@y}% } % \end{macrocode} -% \end{macro}\end{macro}\end{intmacro}\begin{intmacro}{\@gtt@setendanchor}\begin{macro}{\xRight}\begin{macro}{\yLower} -% |\@gtt@setendanchor| is similar to the command above. However, it stores the anchor coordinates in the auxiliary macros |\xRight| and |\yLower|. +% \end{macro} +% \end{macro} +% \end{intmacro} +% \begin{intmacro}{\@gtt@setendanchor} +% \begin{macro}{\xRight} +% \begin{macro}{\yLower} +% |\@gtt@setendanchor|\marg{anchor} is similar to the command above. However, it stores the anchor coordinates in the auxiliary macros |\xRight| and |\yLower|. % \begin{macrocode} \newcommand\@gtt@setendanchor[1]{% \pgfqkeys{/pgfgantt/link anchor}{#1}% - \pgfpointanchor{\@gtt@endelement}{\@gtt@linkanchor}% + \pgfpointanchor{\@gtt@link@endelement}{\@gtt@link@anchor}% \edef\xRight{\the\pgf@x}% \edef\yLower{\the\pgf@y}% } % \end{macrocode} -% \end{macro}\end{macro}\end{intmacro}\begin{macro}{\ganttlink}\changes{v2.0}{2011/10/10}{The syntax of \cs{ganttlink} was completely changed. The command now takes one optional and \textit{two} mandatory arguments. The latter specify the name of the chart elements to be linked. Consequently, the keys \texttt{b-b}, \texttt{b-m}, \texttt{m-b} and \texttt{m-m} were removed. The keys \texttt{s-s}, \texttt{s-f}, \texttt{f-s} and \texttt{f-f} are now values for the \texttt{link type} key.}\begin{intmacro}{\@gtt@startelement}\begin{intmacro}{\@gtt@endelement} -% |\ganttlink| first stores the names of the connected elements in |\@gtt@startelement| and |\@gtt@endelement|. +% \end{macro} +% \end{macro} +% \end{intmacro} +% \begin{macro}{\ganttlink} +% \begin{intmacro}{\@gtt@link@startelement} +% \begin{intmacro}{\@gtt@link@endelement} +% |\ganttlink|\oarg{options}\marg{E1}\marg{E2} executes the \meta{options} and stores the names of the connected elements \meta{E1} and \meta{E2} in |\@gtt@link@startelement| and |\@gtt@link@endelement|. % \begin{macrocode} \newcommand\ganttlink[3][]{% \begingroup% \ganttset{#1}% - \def\@gtt@startelement{#2}% - \def\@gtt@endelement{#3}% + \def\@gtt@link@startelement{#2}% + \def\@gtt@link@endelement{#3}% % \end{macrocode} -% \end{intmacro}\end{intmacro}\begin{macro}{\ganttsetstartanchor}\begin{macro}{\ganttsetendanchor} +% \end{intmacro} +% \end{intmacro} +% \begin{macro}{\ganttsetstartanchor} +% \begin{macro}{\ganttsetendanchor} % |\ganttsetstartanchor| and |\ganttsetendanchor| are only valid in the second argument of |\newganttlinktype|. Since you may wish to omit one of those commands, we set default anchors for the link. % \begin{macrocode} \let\ganttsetstartanchor\@gtt@setstartanchor% \let\ganttsetendanchor\@gtt@setendanchor% - \ganttsetstartanchor{right}% - \ganttsetendanchor{left}% -% \end{macrocode} -% \end{macro}\end{macro} -% \textit{Automatic links:} The first and last coordinate of the link should touch the preceding or following element at the center of its right or left border, respectively. We check if the connected elements lie in the same row or not (i.\,e., their $y$-coordinates differ at most 1~pt). In the latter case, |\pgfmathparse| yields |0|. -% \begin{macrocode} - \def\@tempa{auto}% - \edef\@tempb{\ganttvalueof{link type}}% - \ifx\@tempa\@tempb% - \pgfmathparse{abs(\yUpper - \yLower) <= 1}% - \ifcase\pgfmathresult% -% \end{macrocode} -% Once again, two possibilities arise: Either the elements to be connected are at least separated by |link tolerance| time slots, in which case we draw a three-part arrow (i.\,e., link type |rdr|). Alternatively, the elements lie in adjacent time slots or even overlap, in which case we draw a five-part arrow (i.\,e., link type |rdldr|). -% \begin{macrocode} - \pgfmathparse{ - (\xRight - \xLeft) - >= \ganttvalueof{link tolerance} * \ganttvalueof{x unit} - }% - \ifcase\pgfmathresult% - \gtt@drawlink{rdldr}% - \else% - \gtt@drawlink{rdr}% - \fi% -% \end{macrocode} -% For elements that lie in the same row, we draw a simple arrow (i.\,e., link type |r|). -% \begin{macrocode} - \else% - \gtt@drawlink{r}% - \fi% -% \end{macrocode} -% \textit{Straight and custom links:} We simply call |\gtt@drawlink| with the value of |link type|. -% \begin{macrocode} - \else% - \gtt@drawlink{\ganttvalueof{link type}}% - \fi% - \endgroup% -} - + \ganttsetstartanchor{east}% + \ganttsetendanchor{west}% % \end{macrocode} % \end{macro} -% -% -% \subsection{Groups} -% -% \begin{macro}{\ganttgroup} -% Groups and bars are quite similar. First, we define the usual coordinate macros and add a |chart element| node. -% \begin{macrocode} -\newcommand\ganttgroup[4][]{% - \begingroup% - \ganttset{#1}% - \pgfmathsetmacro\x@left{% - (#3 + \ganttvalueof{time slot modifier}% - + \ganttvalueof{group left shift})% - * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\x@right{% - (#4 + \ganttvalueof{group right shift}) * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - - \ganttvalueof{group top shift}) * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@lower{% - \y@upper - \ganttvalueof{group height} * \ganttvalueof{y unit chart}% - }% - \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; -% \end{macrocode} -% |\gtt@pl@draw| saves the commands that will produce the progress label. This macro does nothing unless (a) the |progress| key differs from none and (b) |progress label text| differs from |\relax|. Otherwise, it creates a vertically centered node to the right of the group. -% \begin{macrocode} - \def\@tempa{none}% - \ifx\gtt@progress\@tempa% - \def\gtt@progress{100}% - \let\gtt@pl@draw\relax% - \else - \expandafter\ifx\gtt@progresslabeltext\relax\relax% - \let\gtt@pl@draw\relax% - \else% - \def\gtt@pl@draw{% - \node at ($(\x@right pt, \y@upper pt)!.5! - (\x@right pt, \y@lower pt)$) - [/pgfgantt/progress label anchor] {% - \ganttvalueof{progress label font}{% - \gtt@progresslabeltext{\gtt@progress}% - }% - };% - }% - \fi% - \fi% -% \end{macrocode} -% \begin{intmacro}{\@maxpeak} -% In order to draw the left (complete) and right (incomplete) part of a progress group, we clip the corresponding polygons depending on the value of |progress|. Note that we turn off the border of these polygons and draw it with an additional, third command. The clipped area must include the highest peak, so we determine its height and store it in |\@maxpeak|. -% \begin{macrocode} - \pgfmathsetmacro\@maxpeak{% - \gtt@grouprightpeaky > \gtt@groupleftpeaky ?% - \gtt@grouprightpeaky * \ganttvalueof{y unit chart} :% - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}% - }% - \begin{scope}% - \clip (\x@left pt, \y@upper pt) rectangle - ($(\x@left pt, \y@lower pt - \@maxpeak pt)!% - \gtt@progress/100!% - (\x@right pt, \y@lower pt - \@maxpeak pt)$);% - \path [/pgfgantt/group, draw=none] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky - * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \end{scope}% - \begin{scope}% - \clip ($(\x@left pt, \y@upper pt)!% - \gtt@progress/100!% - (\x@right pt, \y@upper pt)$) - rectangle (\x@right pt, \y@lower pt - \@maxpeak pt); - \path [/pgfgantt/group incomplete] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky - * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \end{scope}% - \path [/pgfgantt/group, fill=none] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \gtt@pl@draw% -% \end{macrocode} -% If the first mandatory argument of |\ganttgroup| is not empty, we print a label. Its anchor is either at the |group label shape anchor| of the previously defined |chart element| node (|inline=true|) or at the left canvas border halfway between the upper and lower $y$-coordinate of the group (|inline=false|). -% \begin{macrocode} - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{group label shape anchor}) - [/pgfgantt/group label inline anchor] - {\ganttvalueof{group label font}{\gtt@grouplabeltext{#2}}};% - \else% - \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$) - [/pgfgantt/group label anchor] - {\ganttvalueof{group label font}{\gtt@grouplabeltext{#2}}};% - \fi% - \fi% -% \end{macrocode} -% Since the first group clearly appears after the last line containing a title element, we set the boolean |\ifgtt@intitle| to false. -% \begin{macrocode} - \xdef\gtt@lastelement{\gtt@currentelement}% - \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% - \global\gtt@intitlefalse% - \endgroup% -} - -% \end{macrocode} -% \end{intmacro} % \end{macro} -% \begin{macro}{\ganttlinkedgroup} -% The shortcut version |\ganttlinkedgroup| calls both |\ganttgroup| and |\ganttlink|. +% We call |\gtt@drawlink| with the value of \opt{link type}. % \begin{macrocode} -\newcommand\ganttlinkedgroup[4][]{% - \begingroup% - \ganttset{#1}% - \ganttgroup{#2}{#3}{#4}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% + \gtt@drawlink{\ganttvalueof{link type}}% \endgroup% } % \end{macrocode} % \end{macro} % -% -% \subsection{Milestones} -% -% \begin{macro}{\ganttmilestone}\begin{intmacro}{\x@mid}\begin{intmacro}{\y@mid} -% |\ganttmilestone| calculates some coordinates and adds a |chart element| node. We also need the coordinates of the center, which are saved in |\x@mid| and |\y@mid|. -% \begin{macrocode} -\newcommand\ganttmilestone[3][]{% - \begingroup% - \ganttset{#1}% - \pgfmathsetmacro\x@mid{% - (#3 + \ganttvalueof{milestone xshift}) * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\x@left{% - \x@mid - \ganttvalueof{milestone width} / 2 * \ganttvalueof{x unit}% - } - \pgfmathsetmacro\x@right{% - \x@mid + \ganttvalueof{milestone width} / 2 * \ganttvalueof{x unit}% - } - \pgfmathsetmacro\y@mid{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline}% - - \ganttvalueof{milestone yshift}) * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@upper{% - \y@mid + \ganttvalueof{milestone height} / 2 - * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@lower{% - \y@mid - \ganttvalueof{milestone height} / 2 - * \ganttvalueof{y unit chart}% - }% - \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; -% \end{macrocode} -% \end{intmacro}\end{intmacro} -% Drawing the milestone itself is quite simple, since the |progress| key is irrelevant. -% \begin{macrocode} - \path [/pgfgantt/milestone] - (\x@left pt, \y@mid pt) -- - (\x@mid pt, \y@lower pt) -- - (\x@right pt, \y@mid pt) -- - (\x@mid pt, \y@upper pt) -- - cycle;% -% \end{macrocode} -% If the first mandatory argument of |\ganttmilestone| is not empty, we print a label. Its anchor is either at the |milestone label shape anchor| of the previously defined |chart element| node (|inline=true|) or at the left canvas border at the height of the milestone's center. -% \begin{macrocode} - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{milestone label shape anchor}) - [/pgfgantt/milestone label inline anchor] - {\ganttvalueof{milestone label font}{% - \gtt@milestonelabeltext{#2}% - }};% - \else% - \node at (0pt, \y@mid pt) - [/pgfgantt/milestone label anchor] - {\ganttvalueof{milestone label font}{% - \gtt@milestonelabeltext{#2}% - }};% - \fi% - \fi% -% \end{macrocode} -% Since the first milestone clearly appears after the last line containing a title element, we set the boolean |\ifgtt@intitle| to false. -% \begin{macrocode} - \xdef\gtt@lastelement{\gtt@currentelement}% - \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% - \global\gtt@intitlefalse% - \endgroup% -} - -% \end{macrocode} -% \end{macro} -% \begin{macro}{\ganttlinkedmilestone} -% The shortcut version |\ganttlinkedmilestone| calls both |\ganttmilestone| and |\ganttlink|. -% \begin{macrocode} -\newcommand\ganttlinkedmilestone[3][]{% - \begingroup% - \ganttset{#1}% - \ganttmilestone{#2}{#3}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% - \endgroup% -} -% \end{macrocode} -% \end{macro} % \iffalse %</pgfgantt> % \fi diff --git a/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.ins b/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.ins index 011c77da079..71977ad0e93 100644 --- a/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.ins +++ b/Master/texmf-dist/source/latex/pgfgantt/pgfgantt.ins @@ -1,6 +1,6 @@ %% pgfgantt.ins %% -%% Copyright (C) 2012 by Wolfgang Skala +%% Copyright (C) 2013 by Wolfgang Skala %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -24,7 +24,7 @@ \preamble -Copyright (C) 2012 by Wolfgang Skala +Copyright (C) 2013 by Wolfgang Skala This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -52,7 +52,7 @@ version 2005/12/01 or later. \Msg{* pdflatex pgfgantt.dtx} \Msg{* makeindex -s gind.ist -o pgfgantt.ind pgfgantt.idx} \Msg{* makeindex -s gglo.ist -o pgfgantt.gls pgfgantt.glo} -\Msg{* pdflatex pgfgantt.dtx} +\Msg{* pdflatex pgfgantt.dtx (2x)} \Msg{*} \Msg{* Happy TeXing!} \Msg{*} diff --git a/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty b/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty index 1eefffd2d48..d87a9a2f7b1 100644 --- a/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty +++ b/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty @@ -6,7 +6,7 @@ %% %% pgfgantt.dtx (with options: `pgfgantt') %% -%% Copyright (C) 2012 by Wolfgang Skala +%% Copyright (C) 2013 by Wolfgang Skala %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -16,25 +16,16 @@ %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% -\ProvidesPackage{pgfgantt}[2012/01/25 v3.0 Draw Gantt diagrams with TikZ] +\ProvidesPackage{pgfgantt}[2013/06/01 v4.0 Draw Gantt diagrams with TikZ] \NeedsTeXFormat{LaTeX2e}[1999/12/01] - - \RequirePackage{tikz} - \usetikzlibrary{arrows,backgrounds,calc,patterns,positioning} - -\newcounter{gtt@width} -\newcounter{gtt@currentline} -\newcounter{gtt@lasttitleline} -\newcounter{gtt@lasttitleslot} -\newcounter{gtt@elementid} -\newcounter{gtt@currgrid} -\def\gtt@lastelement{} -\def\gtt@currentelement{} -\newif\ifgtt@intitle +\usetikzlibrary{% + arrows, backgrounds, calc,% + patterns, positioning, shapes.geometric% +} +\RequirePackage{pgfcalendar} \def\ganttset#1{\pgfqkeys{/pgfgantt}{#1}} - \def\@gtt@keydef#1#2{% \pgfkeyssetvalue{/pgfgantt/#1}{#2}% } @@ -44,6 +35,17 @@ \def\@gtt@stylekeydef#1#2{% \pgfkeys{/pgfgantt/#1/.style={#2}}% } +\def\@gtt@PackageError#1{% + \PackageError{pgfgantt}{#1}{}% +} +\def\@gtt@PackageWarning#1{% + \PackageWarning{pgfgantt}{#1}% +} + +\newcount\gtt@currentline +\newcount\gtt@lasttitleline +\newcount\gtt@currgrid +\newcount\gtt@chartwidth \@gtt@stylekeydef{hgrid style}{dotted} \newif\ifgtt@hgrid \ganttset{% @@ -65,6 +67,34 @@ hgrid/.default=dotted } +\def\gtt@hgrid@do#1,{% + \ifx\relax#1\else + \ifnum\gtt@currgrid<\gtt@currentline\else% + \gtt@hgrid@analyze#1\relax% + \expandafter\expandafter\expandafter\gtt@hgrid@do% + \expandafter\fi% + \fi% +} + +\def\gtt@hgrid@analyze{% + \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% +} + +\def\gtt@hgrid@draw#1#2\relax{% + \foreach \i in {1,...,#1} {% + \pgfmathsetmacro\y@upper{% + \gtt@lasttitleline * \ganttvalueof{y unit title} +% + (\gtt@currgrid - \gtt@lasttitleline)% + * \ganttvalueof{y unit chart}% + }% + \draw [#2] + (0pt, \y@upper pt) -- + (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);% + \global\advance\gtt@currgrid by-1\relax% + \ifnum\gtt@currgrid<\gtt@currentline\breakforeach\fi% + }% +} + \newif\ifgtt@vgrid \ganttset{% vgrid/.code={% @@ -85,319 +115,363 @@ vgrid/.default=dotted } - -\@gtt@keydef{x unit}{.5cm} -\@gtt@keydef{y unit title}{1cm} -\@gtt@keydef{y unit chart}{1cm} - -\@gtt@stylekeydef{canvas}{fill=white} -\@gtt@keydef{today}{none} -\@gtt@stylekeydef{today rule}{dashed, line width=1pt} -\@gtt@keydef{today label}{TODAY} - -\@gtt@stylekeydef{title}{fill=white} -\@gtt@keydef{title label font}{\small} -\@gtt@stylekeydef{title label anchor}{anchor=mid} -\ganttset{% - title list options/.code={% - \def\gtt@titlelistoptions{[#1]}% - },% - title list options={var=\x, evaluate=\x}% +\def\gtt@vgrid@do#1,{% + \ifx\relax#1\else% + \ifnum\gtt@currgrid>\gtt@chartwidth\else% + \gtt@vgrid@analyze#1\relax% + \expandafter\expandafter\expandafter\gtt@vgrid@do% + \expandafter\fi% + \fi% } -\@gtt@keydef{title left shift}{0} -\@gtt@keydef{title right shift}{0} -\@gtt@keydef{title top shift}{0} -\@gtt@keydef{title height}{.6} -\newif\ifgtt@includetitle -\ganttset{% - include title in canvas/.is if=gtt@includetitle,% - include title in canvas +\def\gtt@vgrid@analyze{% + \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% } -\@gtt@keydef{name}{} -\@gtt@keydef{time slot modifier}{-1} -\newif\ifgtt@inline -\ganttset{% - inline/.is if=gtt@inline,% - inline=false% +\def\gtt@vgrid@draw#1#2\relax{% + \foreach \i in {1,...,#1} {% + \draw [#2] + (\gtt@currgrid * \ganttvalueof{x unit}, \y@upper pt) --% + (\gtt@currgrid * \ganttvalueof{x unit}, \y@lower pt);% + \global\advance\gtt@currgrid by1\relax% + \ifnum\gtt@currgrid>\gtt@chartwidth\breakforeach\fi% + }% } -\@gtt@stylekeydef{bar}{fill=white} -\ganttset{% - bar label text/.code={% - \def\gtt@barlabeltext##1{#1}% - },% - bar label text={\strut#1}% -} -\@gtt@keydef{bar label font}{\normalsize} -\@gtt@stylekeydef{bar label anchor}{anchor=east} -\@gtt@stylekeydef{bar label inline anchor}{anchor=center} -\@gtt@keydef{bar label shape anchor}{center} -\@gtt@keydef{bar left shift}{0} -\@gtt@keydef{bar right shift}{0} -\@gtt@keydef{bar top shift}{.3} -\@gtt@keydef{bar height}{.4} - -\@gtt@stylekeydef{group}{fill=black} -\ganttset{% - group label text/.code={% - \def\gtt@grouplabeltext##1{#1}% - },% - group label text={\strut#1}% -} -\@gtt@keydef{group label font}{\normalsize\bfseries} -\@gtt@stylekeydef{group label anchor}{anchor=east} -\@gtt@stylekeydef{group label inline anchor}{anchor=south} -\@gtt@keydef{group label shape anchor}{center} -\@gtt@keydef{group left shift}{-.1} -\@gtt@keydef{group right shift}{.1} -\@gtt@keydef{group top shift}{.4} -\@gtt@keydef{group height}{.2} -\ganttset{% - group left peak/.code n args={3}{% - \def\@tempa{#1}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeakmidx{#1}\fi% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeakinnerx{#2}\fi% - \def\@tempa{#3}% - \ifx\@tempa\@empty\else\def\gtt@groupleftpeaky{#3}\fi% - },% - group right peak/.code n args={3}{% - \def\@tempa{#1}% - \def\@tempb{-}% - \ifx\@tempa\@empty\else% - \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakmidx{#1}\fi% - \fi% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakinnerx{#2}\fi% - \fi% - \def\@tempa{#3}% - \ifx\@tempa\@empty\else\def\gtt@grouprightpeaky{#3}\fi% - },% - group peaks/.code n args={3}{% - \ganttset{% - group left peak={#1}{#2}{#3},% - group right peak={-#1}{-#2}{#3}% - }% - },% - group peaks={.2}{.4}{.1} +\def\gtt@smugglecount#1\endgroup{% + \edef\@tempa{\the#1}% + \expandafter\endgroup\expandafter#1\expandafter=\@tempa% } -\ganttset{% - progress/.code={% - \def\gtt@progress{#1}% - },% - progress=none% +\newcommand\gtt@juliantotimeslot[2]{% + \begingroup% + \@tempcnta=#1\relax% + \ifgtt@compresscalendar% + \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}% + \@tempcnta=\@tempa\relax% + \advance\@tempcnta by-\gtt@startyear\relax% + \multiply\@tempcnta by12\relax% + \advance\@tempcnta by\@tempb\relax% + \advance\@tempcnta by-\gtt@startmonth\relax% + \advance\@tempcnta by1\relax% + \else% + \advance\@tempcnta by-\gtt@startjulian\relax% + \advance\@tempcnta by1\relax% + \fi% + #2=\@tempcnta\relax% + \gtt@smugglecount#2% + \endgroup% } -\@gtt@stylekeydef{bar incomplete}{} -\@gtt@stylekeydef{group incomplete}{} -\ganttset{% - incomplete/.style/.code={% - \ganttset{bar incomplete/.style={#1}, group incomplete/.style={#1}}% - },% - incomplete/.style={fill=black!25} + +\newcommand\newgantttimeslotformat[2]{% + \expandafter\def\csname gtt@tsstojulian@#1\endcsname##1##2{% + \begingroup#2\gtt@smugglecount##2\endgroup% + }% } -\ganttset{% - progress label text/.code={% - \def\gtt@progresslabeltext##1{#1}% - },% - progress label text={#1\% complete} + +\newgantttimeslotformat{simple}{% + #2=#1\relax% + \advance#2 by\gtt@tsf@startjulian\relax% + \advance#2 by-1\relax% } -\@gtt@keydef{progress label font}{\scriptsize} -\@gtt@stylekeydef{progress label anchor}{anchor=west} -\@gtt@stylekeydef{milestone}{fill=black} -\ganttset{% - milestone label text/.code={% - \def\gtt@milestonelabeltext##1{#1}% - },% - milestone label text={\strut#1}% +\newgantttimeslotformat{isodate}{% + \pgfcalendardatetojulian{#1}{#2}% } -\@gtt@keydef{milestone label font}{\normalsize\itshape} -\@gtt@stylekeydef{milestone label anchor}{anchor=east} -\@gtt@stylekeydef{milestone label inline anchor}{anchor=south} -\@gtt@keydef{milestone label shape anchor}{center} -\@gtt@keydef{milestone width}{.8} -\@gtt@keydef{milestone height}{.4} -\@gtt@keydef{milestone xshift}{0} -\@gtt@keydef{milestone yshift}{.5} -\@gtt@stylekeydef{link}{-latex, rounded corners=1pt} -\@gtt@keydef{link type}{auto} -\@gtt@keydef{link mid}{.5} -\@gtt@keydef{link bulge}{.4} -\@gtt@keydef{link tolerance}{.6} -\@gtt@keydef{link label}{} -\@gtt@keydef{link label font}{\scriptsize\itshape\normalcolor} -\@gtt@stylekeydef{link label anchor}{anchor=west} +\newgantttimeslotformat{isodate-yearmonth}{% + \pgfcalendardatetojulian{#1-01}{#2}% +} -\def\gtt@vgrid@do#1,{% - \ifx\relax#1\else% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\else% - \gtt@vgrid@analyze#1\relax% - \expandafter\expandafter\expandafter\gtt@vgrid@do% - \expandafter\fi% +\newcommand\gtt@tsf@getdmy[1]{% + \edef\local@firstarg{#1}% + \def\local@decompose##1.##2.##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg..\relax% + \ifx\local@month\@empty% + \def\local@decompose##1/##2/##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg//\relax% + \ifx\local@month\@empty% + \def\local@decompose##1-##2-##3\relax{% + \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}% + }% + \expandafter\local@decompose\local@firstarg--\relax% + \ifx\local@month\@empty% + \@gtt@PackageError{Illegal time slot specifier `#1'.}% + \else% + \def\local@decompose##1--{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% + \fi% + \else% + \def\local@decompose##1//{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% + \fi% + \else% + \def\local@decompose##1..{\def\local@year{##1}}% + \expandafter\local@decompose\local@year% \fi% } -\def\gtt@vgrid@analyze{% - \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% +\newgantttimeslotformat{little-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@year<100\relax% + \edef\local@year{\gtt@tsf@basecentury\local@year}% + \fi% + \pgfcalendardatetojulian{\local@year-\local@month-\local@day}{#2}% } -\def\gtt@vgrid@draw#1#2\relax{% - \foreach \i in {1,...,#1} {% - \draw [#2] - (\value{gtt@currgrid} * \ganttvalueof{x unit}, \y@upper pt) --% - (\value{gtt@currgrid} * \ganttvalueof{x unit}, \y@lower pt);% - \stepcounter{gtt@currgrid}% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi% - }% +\newgantttimeslotformat{big-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@day<100\relax% + \edef\local@day{\gtt@tsf@basecentury\local@day}% + \fi% + \pgfcalendardatetojulian{\local@day-\local@month-\local@year}{#2}% } -\def\gtt@hgrid@do#1,{% - \ifx\relax#1\else - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\else% - \gtt@hgrid@analyze#1\relax% - \expandafter\expandafter\expandafter\gtt@hgrid@do% - \expandafter\fi% +\newgantttimeslotformat{middle-endian}{% + \gtt@tsf@getdmy{#1}% + \ifnum\local@year<100\relax% + \edef\local@year{\gtt@tsf@basecentury\local@year}% \fi% + \pgfcalendardatetojulian{\local@year-\local@day-\local@month}{#2}% } -\def\gtt@hgrid@analyze{% - \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% +\ganttset{% + time slot format/.code={% + \@ifundefined{gtt@tsstojulian@#1}{% + \@gtt@PackageError{% + Time slot format `#1' undefined.% + }% + }{}% + \expandafter\let\expandafter\gtt@tsstojulian% + \csname gtt@tsstojulian@#1\endcsname% + },% + time slot format=simple,% + time slot format/base century/.code={% + \begingroup% + \@tempcnta=#1\relax% + \divide\@tempcnta by100\relax% + \xdef\gtt@tsf@basecentury{\the\@tempcnta}% + \endgroup% + },% + time slot format/base century=2000,% + time slot format/start date/.code={% + \begingroup% + \pgfcalendardatetojulian{#1}{\@tempcnta}% + \xdef\gtt@tsf@startjulian{\the\@tempcnta}% + \endgroup% + },% + time slot format/start date=2000-01-01% } -\def\gtt@hgrid@draw#1#2\relax{% - \foreach \i in {1,...,#1} {% - \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} +% - (\value{gtt@currgrid} - \value{gtt@lasttitleline})% - * \ganttvalueof{y unit chart}% - }% - \draw [#2] - (0pt, \y@upper pt) -- - (\value{gtt@width} * \ganttvalueof{x unit}, \y@upper pt);% - \addtocounter{gtt@currgrid}{-1}% - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi% - }% +\@gtt@keydef{x unit}{.5cm} +\@gtt@keydef{y unit title}{1cm} +\@gtt@keydef{y unit chart}{1cm} +\@gtt@stylekeydef{canvas}{shape=rectangle, draw, fill=white} +\@gtt@keydef{today}{none} +\@gtt@keydef{today offset}{1} +\@gtt@stylekeydef{today rule}{dashed, line width=1pt} +\@gtt@keydef{today label}{TODAY} +\@gtt@keydef{today label font}{\normalfont} +\@gtt@stylekeydef{today label node}{% + anchor=north, font=\ganttvalueof{today label font}% +} +\newif\ifgtt@newlineshortcut +\ganttset{% + newline shortcut/.is if=gtt@newlineshortcut,% + newline shortcut=true% } \newif\ifgtt@tikzpicture - -\newenvironment{ganttchart}[2][]{% +\newif\ifgtt@intitle +\newcount\gtt@lasttitleslot +\newcount\gtt@elementid +\newcount\gtt@today@slot +\newcount\gtt@startjulian +\newcount\gtt@endjulian +\newenvironment{ganttchart}[3][]{% + \ganttset{#1}% + \gtt@tsstojulian{#2}{\gtt@startjulian}% + \global\gtt@startjulian=\gtt@startjulian\relax% + \gtt@tsstojulian{#3}{\gtt@endjulian}% + \global\gtt@endjulian=\gtt@endjulian\relax% + \pgfcalendarjuliantodate{\gtt@startjulian}% + {\gtt@startyear}{\gtt@startmonth}{\@tempa}% + \xdef\gtt@startyear{\gtt@startyear}% + \xdef\gtt@startmonth{\gtt@startmonth}% + \gtt@juliantotimeslot{\gtt@endjulian}{\gtt@chartwidth} + \global\gtt@chartwidth=\gtt@chartwidth\relax% + \def\@tempa{none}% + \edef\@tempb{\ganttvalueof{today}}% + \ifx\@tempa\@tempb\else% + \gtt@tsstojulian{\ganttvalueof{today}}{\gtt@today@slot} + \gtt@juliantotimeslot{\gtt@today@slot}{\gtt@today@slot}% + \fi% + \global\gtt@elementid=0\relax% + \global\gtt@currentline=0\relax% + \global\gtt@lasttitleline=0\relax% + \global\gtt@lasttitleslot=0\relax% \@ifundefined{useasboundingbox}% {\gtt@tikzpicturefalse\begin{tikzpicture}}% {\gtt@tikzpicturetrue}% - \ganttset{#1}% - \setcounter{gtt@width}{#2}% - \setcounter{gtt@currentline}{0}% - \setcounter{gtt@lasttitleline}{0}% - \setcounter{gtt@elementid}{0}% - \setcounter{gtt@currgrid}{1}% \gtt@intitletrue% - \let\\\ganttnewline% -}{% + \ifgtt@newlineshortcut% + \let\\\ganttnewline% + \fi% + \let\ganttalignnewline\tikz@align@newline% +}{ \begin{scope}[on background layer]% \ifgtt@includetitle% \def\y@upper{0}% \else% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% + \gtt@lasttitleline * \ganttvalueof{y unit title}% }% \fi% \pgfmathsetmacro\y@lower{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + + (\gtt@currentline - \gtt@lasttitleline - 1)% * \ganttvalueof{y unit chart}% }% - \draw [/pgfgantt/canvas] - (0pt, \y@upper pt) rectangle - (\value{gtt@width} * \ganttvalueof{x unit}, \y@lower pt);% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% + }% + \pgfmathsetmacro\y@size{% + abs(\y@lower - \y@upper)% + }% + \pgfmathsetmacro\x@size{% + \gtt@chartwidth * \ganttvalueof{x unit}% + }% + \node [/pgfgantt/canvas, minimum width=\x@size pt, + minimum height=\y@size pt] + at (\x@size pt / 2, \y@mid pt) {};% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% + \gtt@lasttitleline * \ganttvalueof{y unit title}% }% \ifgtt@vgrid - \addtocounter{gtt@width}{-1}% - \foreach \x in {1,...,\value{gtt@width}} {% + \gtt@currgrid=1\relax% + \global\advance\gtt@chartwidth by-1\relax% + \foreach \x in {1,...,\gtt@chartwidth} {% \expandafter\gtt@vgrid@do\gtt@vgridstyle,\relax,% - \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi% + \ifnum\gtt@currgrid>\gtt@chartwidth\relax\breakforeach\fi% }% - \stepcounter{gtt@width}% + \global\advance\gtt@chartwidth by1\relax% \fi% \ifgtt@hgrid% - \ifgtt@includetitle% - \setcounter{gtt@currgrid}{\value{gtt@lasttitleline}}% - \else% - \pgfmathsetcounter{gtt@currgrid}{\value{gtt@lasttitleline}-1}% + \gtt@currgrid=\gtt@lasttitleline\relax% + \ifgtt@includetitle\else% + \advance\gtt@currgrid by-1\relax \fi% - \edef\hgrid@upper{\thegtt@currgrid}% - \foreach \t in {\hgrid@upper,...,\value{gtt@currentline}} {% + \edef\@tempa{\the\gtt@currgrid}% + \foreach \t in {\@tempa,...,\gtt@currentline} {% \expandafter\gtt@hgrid@do\gtt@hgridstyle,\relax,% - \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi% + \ifnum\gtt@currgrid<\gtt@currentline\relax\breakforeach\fi% }% \fi% \def\@tempa{none}% \edef\@tempb{\ganttvalueof{today}}% \ifx\@tempa\@tempb\else% + \pgfmathsetmacro\x@mid{% + (\gtt@today@slot - 1 + \ganttvalueof{today offset})% + * \ganttvalueof{x unit}% + }% \draw [/pgfgantt/today rule] - (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@upper pt) -- - (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@lower pt);% - \node at (\ganttvalueof{today} * \ganttvalueof{x unit}, \y@lower pt) - [anchor=north] {\ganttvalueof{today label}};% + (\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt) + node [/pgfgantt/today label node] {\ganttvalueof{today label}};% \fi% \end{scope}% \ifgtt@tikzpicture\else\end{tikzpicture}\fi% } \newcommand\ganttnewline[1][]{% - \def\@tempa{#1}% - \def\@tempb{grid}% - \ifx\@tempa\@empty\else - \ifx\@tempa\@tempb% - \def\@tempa{/pgfgantt/hgrid style}% + \begingroup% + \def\local@drawarg{#1}% + \def\@tempa{grid}% + \ifx\local@drawarg\@empty\else% + \ifx\local@drawarg\@tempa% + \def\local@drawarg{/pgfgantt/hgrid style}% \fi% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + + (\gtt@currentline - \gtt@lasttitleline - 1)% * \ganttvalueof{y unit chart}% } - \expandafter\draw\expandafter[\@tempa] + \expandafter\draw\expandafter[\local@drawarg] (0pt, \y@upper pt) -- - (\value{gtt@width} * \ganttvalueof{x unit}, \y@upper pt);% + (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);% \fi% - \addtocounter{gtt@currentline}{-1}% - \ifgtt@intitle\addtocounter{gtt@lasttitleline}{-1}\fi% - \setcounter{gtt@lasttitleslot}{0}% + \global\advance\gtt@currentline by-1\relax% + \ifgtt@intitle\global\advance\gtt@lasttitleline by-1\relax\fi% + \global\gtt@lasttitleslot=0\relax% + \endgroup% +} + +\@gtt@stylekeydef{title}{shape=rectangle, inner sep=0pt, draw, fill=white} +\@gtt@keydef{title label font}{\small} +\@gtt@stylekeydef{title label node}{% + anchor=center, font=\ganttvalueof{title label font}% +} +\ganttset{% + title list options/.code={% + \def\gtt@titlelistoptions{[#1]}% + },% + title list options={var=\x, evaluate=\x}% +} +\@gtt@keydef{title left shift}{0} +\@gtt@keydef{title right shift}{0} +\@gtt@keydef{title top shift}{0} +\@gtt@keydef{title height}{.6} +\newif\ifgtt@includetitle +\ganttset{% + include title in canvas/.is if=gtt@includetitle,% + include title in canvas +} +\@gtt@keydef{calendar week text}{Week~\currentweek} +\newif\ifgtt@compresscalendar +\ganttset{% + compress calendar/.is if=gtt@compresscalendar,% + compress calendar=false% } \newcommand\gantttitle[3][]{% \begingroup% \ganttset{#1}% \pgfmathsetmacro\x@left{% - (\value{gtt@lasttitleslot} + \ganttvalueof{title left shift})% + (\gtt@lasttitleslot + \ganttvalueof{title left shift})% * \ganttvalueof{x unit}% }% \pgfmathsetmacro\x@right{% - (\value{gtt@lasttitleslot} + #3 + \ganttvalueof{title right shift})% + (\gtt@lasttitleslot + #3 + \ganttvalueof{title right shift})% * \ganttvalueof{x unit}% }% + \pgfmathsetmacro\x@mid{% + (\x@left + \x@right) / 2% + }% + \pgfmathsetmacro\x@size{% + \x@right - \x@left% + }% \pgfmathsetmacro\y@upper{% - (\value{gtt@currentline} - \ganttvalueof{title top shift})% + (\gtt@currentline - \ganttvalueof{title top shift})% * \ganttvalueof{y unit title}% }% \pgfmathsetmacro\y@lower{% - (\value{gtt@currentline} - \ganttvalueof{title top shift}% + (\gtt@currentline - \ganttvalueof{title top shift}% - \ganttvalueof{title height}) * \ganttvalueof{y unit title}% }% - \draw [/pgfgantt/title] - (\x@left pt, \y@upper pt) rectangle - (\x@right pt, \y@lower pt);% - \ganttvalueof{title label font}% - \node at ($(\x@left pt,\y@upper pt)!.5!(\x@right pt,\y@lower pt)$) - [/pgfgantt/title label anchor] {#2};% - \addtocounter{gtt@lasttitleslot}{#3}% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% + }% + \pgfmathsetmacro\y@size{% + \y@upper - \y@lower% + }% + \path (\x@mid pt, \y@mid pt) + node [/pgfgantt/title, minimum width=\x@size pt, + minimum height=\y@size pt] {} + node [/pgfgantt/title label node] {#2};% + \global\advance\gtt@lasttitleslot by#3\relax% \endgroup% } @@ -408,192 +482,816 @@ \endgroup% } -\pgfdeclareshape{chart element}{% - \savedanchor\lowerleft{% - \pgfpoint{\x@left pt}{\y@lower pt}% - }% - \savedanchor\upperleft{% - \pgfpoint{\x@left pt}{\y@upper pt}% - }% - \savedanchor\lowerright{% - \pgfpoint{\x@right pt}{\y@lower pt}% - }% - \savedanchor\upperright{% - \pgfpoint{\x@right pt}{\y@upper pt}% - }% - \savedanchor\centerpoint{% - \pgfpoint{\x@right pt / 2 + \x@left pt / 2}% - {\y@upper pt / 2 + \y@lower pt / 2}% - }% - \anchor{on bottom}{% - \lowerleft% - \pgf@xa\pgf@x% - \lowerright% - \pgf@xb\pgf@x% - \advance\pgf@xb-\pgf@xa% - \advance\pgf@xa\@gtt@linkanchorfraction\pgf@xb% - \pgf@x\pgf@xa% - }% - \anchor{on left}{% - \upperleft% - \pgf@ya\pgf@y% - \lowerleft% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya\@gtt@linkanchorfraction\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{on top}{% - \upperleft% - \pgf@xa\pgf@x% - \upperright% - \pgf@xb\pgf@x% - \advance\pgf@xb-\pgf@xa% - \advance\pgf@xa\@gtt@linkanchorfraction\pgf@xb% - \pgf@x\pgf@xa% - }% - \anchor{on right}{% - \upperright% - \pgf@ya\pgf@y% - \lowerright% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya\@gtt@linkanchorfraction\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{center}{\centerpoint}% - \anchor{lower left}{\lowerleft}% - \anchor{left}{% - \upperleft% - \pgf@ya\pgf@y% - \lowerleft% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya.5\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{upper left}{\upperleft}% - \anchor{lower right}{\lowerright}% - \anchor{right}{% - \upperright% - \pgf@ya\pgf@y% - \lowerright% - \pgf@yb\pgf@y% - \advance\pgf@yb-\pgf@ya% - \advance\pgf@ya.5\pgf@yb% - \pgf@y\pgf@ya% - }% - \anchor{upper right}{\upperright}% -} - -\newcommand\ganttbar[4][]{% +\newif\ifgtt@titlecalendarstar +\newcommand\gantttitlecalendar{% + \@ifstar% + {\gtt@titlecalendarstartrue\@gantttitlecalendar}% + {\gtt@titlecalendarstarfalse\@gantttitlecalendar}% +} + +\newcommand\@gantttitlecalendar[1][]{ + \begingroup% + \ganttset{#1}% + \ifgtt@titlecalendarstar% + \expandafter\@@gantttitlecalendar% + \else% + \expandafter\@@@gantttitlecalendar\expandafter% + {\expandafter\gtt@startjulian\expandafter}\expandafter% + {\expandafter\gtt@endjulian\expandafter}% + \fi% +} + +\newcommand\@@gantttitlecalendar[2]{ + \gtt@tsstojulian{#1}{\@tempcnta}% + \gtt@tsstojulian{#2}{\@tempcntb}% + \@@@gantttitlecalendar{\@tempcnta}{\@tempcntb}% +} + +\newcommand\@@@gantttitlecalendar[3]{% + \pgfcalendarjuliantodate{#1}{\@tempa}{\@tempb}{\@tempc}% + \edef\gtt@calendar@startdate{\@tempa-\@tempb-\@tempc}% + \pgfcalendarjuliantodate{#2}{\@tempa}{\@tempb}{\@tempc}% + \edef\gtt@calendar@enddate{\@tempa-\@tempb-\@tempc}% + \gtt@calendar@eolfalse% + \pgfqkeys{/pgfgantt/calendar}{#3}% + \endgroup% +} +\newif\ifgtt@calendar@eol +\newcount\gtt@calendar@slots +\newcount\gtt@calendar@weeknumber +\newcount\gtt@calendar@startofweek +\ganttset{% + calendar/year/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \ifgtt@compresscalendar% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{equals=12-31}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \gtt@calendar@slots=1\relax% + }{% + \ifdate{end of month=1}{% + \advance\gtt@calendar@slots by1\relax% + }{}% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifdate{end of month=1}{% + \advance\gtt@calendar@slots by-1\relax% + }{}% + \ifdate{equals=12-31}{}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + }% + }{}% + }% + \else% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{equals=12-31}{% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \gtt@calendar@slots=1\relax% + }{% + \advance\gtt@calendar@slots by1\relax% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% + \fi% + }{}% + }% + \fi% + \endgroup% + \gtt@calendar@eoltrue% + },% + calendar/month/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{end of month=1}{% + \gantttitle{% + \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% + }{% + \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + }% + \gtt@calendar@slots=1\relax% + }{% + \advance\gtt@calendar@slots by1\relax% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gantttitle{% + \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% + }{% + \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + }% + \fi% + }{}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% + calendar/week/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \gtt@calendar@weeknumber=#1\relax% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{Sunday}{% + \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax% + \advance\gtt@calendar@startofweek by1\relax% + \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax% + \pgfcalendarjuliantodate{\gtt@calendar@startofweek}% + {\startyear}{\startmonth}{\startday}% + \def\currentweek{\the\gtt@calendar@weeknumber}% + \gantttitle{% + \ganttvalueof{calendar week text}% + }{% + \the\gtt@calendar@slots% + }% + \gtt@calendar@slots=1\relax% + \advance\gtt@calendar@weeknumber by1\relax% + }{% + \advance\gtt@calendar@slots by1% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \advance\gtt@calendar@slots by-1\relax% + \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax% + \advance\gtt@calendar@startofweek by1\relax% + \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax% + \pgfcalendarjuliantodate{\gtt@calendar@startofweek}% + {\startyear}{\startmonth}{\startday}% + \def\currentweek{\the\gtt@calendar@weeknumber}% + \gantttitle{% + \ganttvalueof{calendar week text}% + }{% + \the\gtt@calendar@slots% + }% + \fi% + }{}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% + calendar/week/.default=1,% + calendar/weekday/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \gantttitle{% + \csname pgfcalendarweekday#1\endcsname{\pgfcalendarcurrentweekday}% + }{1}% + }% + \endgroup% + \gtt@calendar@eoltrue% + },% + calendar/day/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \gantttitle{\pgfcalendarcurrentday}{1}% + }% + \endgroup% + \gtt@calendar@eoltrue% + }% +} + +\ganttset{% + progress/.code={% + \def\gtt@progress{#1}% + },% + progress=none,% + progress label text/.code={% + \def\gtt@progresslabeltext##1{#1}% + },% + progress label text={% + \pgfmathprintnumber[precision=0, verbatim]{#1}\% complete% + }% +} +\@gtt@keydef{name}{} +\newif\ifgtt@ce@startatleftborder +\ganttset{% + chart element start border/.is choice,% + chart element start border/left/.code=\gtt@ce@startatleftbordertrue,%, + chart element start border/right/.code=\gtt@ce@startatleftborderfalse,% + chart element start border=left% +} +\newif\ifgtt@inline +\ganttset{% + inline/.is if=gtt@inline,% + inline=false% +} + +\def\gtt@lastelement{} +\def\gtt@currentelement{} +\newif\ifgtt@draw@complete +\newif\ifgtt@draw@incomplete +\newif\ifgtt@draw@clip +\newcount\gtt@left@slot +\newcount\gtt@right@slot + +\newcommand\gtt@chartelement[5][]{% \begingroup% \ganttset{#1}% + \gtt@tsstojulian{#3}{\gtt@left@slot}% + \gtt@juliantotimeslot{\gtt@left@slot}{\gtt@left@slot}% + \gtt@tsstojulian{#4}{\gtt@right@slot}% + \gtt@juliantotimeslot{\gtt@right@slot}{\gtt@right@slot}% + \def\local@timeslotmodifier{-1}% + \ifgtt@ce@startatleftborder\else% + \ifnum\gtt@left@slot=\gtt@right@slot\relax\else% + \def\local@timeslotmodifier{0}% + \fi% + \fi% \pgfmathsetmacro\x@left{% - (#3 + \ganttvalueof{time slot modifier}% - + \ganttvalueof{bar left shift})% + (\gtt@left@slot + \local@timeslotmodifier% + + \ganttvalueof{#5 left shift})% * \ganttvalueof{x unit}% }% \pgfmathsetmacro\x@right{% - (#4 + \ganttvalueof{bar right shift}) * \ganttvalueof{x unit}% + (\gtt@right@slot + \ganttvalueof{#5 right shift})% + * \ganttvalueof{x unit}% + }% + \pgfmathsetmacro\x@mid{% + (\x@left + \x@right) / 2% + }% + \pgfmathsetmacro\x@size{% + \x@right - \x@left% }% \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - - \ganttvalueof{bar top shift}) * \ganttvalueof{y unit chart}% + \gtt@lasttitleline * \ganttvalueof{y unit title} + + (\gtt@currentline - \gtt@lasttitleline + - \ganttvalueof{#5 top shift}) * \ganttvalueof{y unit chart}% }% \pgfmathsetmacro\y@lower{% - \y@upper - \ganttvalueof{bar height} * \ganttvalueof{y unit chart}% + \y@upper - \ganttvalueof{#5 height} * \ganttvalueof{y unit chart}% + }% + \pgfmathsetmacro\y@mid{% + (\y@upper + \y@lower) / 2% + }% + \pgfmathsetmacro\y@size{% + \y@upper - \y@lower% }% \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; - \def\@tempa{none}% - \ifx\gtt@progress\@tempa% - \def\gtt@progress{100}% - \let\gtt@pl@draw\relax% - \else - \expandafter\ifx\gtt@progresslabeltext\relax\relax% - \let\gtt@pl@draw\relax% - \else% - \def\gtt@pl@draw{% - \node at ($(\x@right pt, \y@upper pt)!.5! - (\x@right pt, \y@lower pt)$) - [/pgfgantt/progress label anchor] {% - \ganttvalueof{progress label font}{% - \gtt@progresslabeltext{\gtt@progress}% - }% - };% - }% + \ifx\gtt@name\@empty\edef\gtt@name{elem\the\gtt@elementid}\fi% + \def\local@none{none}% + \ifx\gtt@progress\local@none% + \def\gtt@progress{999}% + \else% + \def\@tempa{today}% + \ifx\gtt@progress\@tempa% + \edef\@tempa{\ganttvalueof{today}}% + \ifx\@tempa\local@none% + \@gtt@PackageWarning{% + Value of today is `none'. Ignoring `progress=today'% + }% + \def\gtt@progress{999}% + \else\ifnum\gtt@today@slot>\gtt@right@slot\relax% + \def\gtt@progress{100}% + \else\ifnum\gtt@today@slot<\gtt@left@slot\relax% + \def\gtt@progress{0}% + \else% + \pgfmathsetmacro\gtt@progress{% + (\gtt@today@slot - \gtt@left@slot - \local@timeslotmodifier)% + / (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)% + * 100% + }% + \fi\fi\fi% + \fi% + \fi% + \gtt@draw@completetrue% + \gtt@draw@incompletetrue% + \gtt@draw@cliptrue% + \ifdim\gtt@progress pt<0.001pt\relax% + \gtt@draw@completefalse% + \gtt@draw@clipfalse% + \else\ifdim\gtt@progress pt>99.999pt\relax% + \gtt@draw@incompletefalse% + \gtt@draw@clipfalse% + \fi\fi% + \ifgtt@draw@clip% + \pgfmathsetmacro\x@clip@size{% + (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)% + * \gtt@progress / 100% + } + \pgfmathsetmacro\x@clip{% + (\gtt@left@slot + \local@timeslotmodifier + \x@clip@size% + + \ganttvalueof{today offset} - 1) * \ganttvalueof{x unit}% + }% + \fi% + \begin{pgfinterruptboundingbox}% + \begin{scope}% + \ifgtt@draw@clip% + \clip (\x@left pt - 10cm, \y@upper pt + 10cm) rectangle + (\x@clip pt, \y@lower pt - 10cm);% + \fi% + \ifgtt@draw@complete% + \node [/pgfgantt/#5, minimum width=\x@size pt, + minimum height=\y@size pt] + (\gtt@name) at (\x@mid pt, \y@mid pt) {};% + \fi% + \end{scope}% + \begin{scope}% + \ifgtt@draw@clip% + \clip (\x@clip pt, \y@upper pt + 10cm) rectangle + (\x@right pt + 10cm, \y@lower pt - 10cm);% + \fi% + \ifgtt@draw@incomplete% + \node [/pgfgantt/#5 incomplete, minimum width=\x@size pt, + minimum height=\y@size pt] + (\gtt@name) at (\x@mid pt, \y@mid pt) {};% + \fi% + \end{scope}% + \end{pgfinterruptboundingbox}% + \ifdim\gtt@progress pt=999pt\relax\else% + \expandafter\ifx\gtt@progresslabeltext\relax\relax\else% + \node at (\gtt@name.\ganttvalueof{#5 progress label anchor}) + [/pgfgantt/#5 progress label node] + {\gtt@progresslabeltext{\gtt@progress}};% \fi% \fi% - \begin{scope}% - \clip (\x@left pt, \y@upper pt) rectangle - ($(\x@left pt, \y@lower pt)!\gtt@progress/100! - (\x@right pt, \y@lower pt)$);% - \draw [/pgfgantt/bar, draw=none] (\x@left pt, \y@upper pt) - rectangle (\x@right pt, \y@lower pt);% - \end{scope}% - \begin{scope}% - \clip ($(\x@left pt, \y@upper pt)!\gtt@progress/100! - (\x@right pt, \y@upper pt)$) - rectangle (\x@right pt, \y@lower pt);% - \draw [/pgfgantt/bar incomplete, draw=none] - (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);% - \end{scope}% - \draw [/pgfgantt/bar, fill=none] - (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);% - \gtt@pl@draw% \def\@tempa{#2}% \ifx\@tempa\@empty\else% \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{bar label shape anchor}) - [/pgfgantt/bar label inline anchor] - {\ganttvalueof{bar label font}{\gtt@barlabeltext{#2}}};% + \node at (\gtt@name.\ganttvalueof{#5 inline label anchor}) + [/pgfgantt/#5 inline label node] + {\csname gtt@#5labeltext\endcsname{#2}};% \else% - \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$) - [/pgfgantt/bar label anchor] - {\ganttvalueof{bar label font}{\gtt@barlabeltext{#2}}};% + \node at (0, \y@mid pt) + [/pgfgantt/#5 label node] + {\csname gtt@#5labeltext\endcsname{#2}};% \fi% \fi% \xdef\gtt@lastelement{\gtt@currentelement}% \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% + \global\advance\gtt@elementid by1\relax% \global\gtt@intitlefalse% \endgroup% } -\newcommand\ganttlinkedbar[4][]{% - \begingroup% - \ganttset{#1}% - \ganttbar{#2}{#3}{#4}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% - \endgroup% +\def\newganttchartelement{% + \@ifstar\@newganttchartelement@one\@newganttchartelement@two% +} + +\newcommand\@newganttchartelement@one[1]{% + \expandafter\newcommand\csname gantt#1\endcsname[3][]{% + \gtt@chartelement[##1]{##2}{##3}{##3}{#1}% + }% + \expandafter\newcommand\csname ganttlinked#1\endcsname[3][]{% + \begingroup% + \ganttset{##1}% + \gtt@chartelement{##2}{##3}{##3}{#1}% + \ganttlink{\gtt@lastelement}{\gtt@currentelement}% + \endgroup% + }% + \@newganttchartelement@definekeys{#1}% +} + +\newcommand\@newganttchartelement@two[1]{% + \expandafter\newcommand\csname gantt#1\endcsname[4][]{% + \gtt@chartelement[##1]{##2}{##3}{##4}{#1}% + }% + \expandafter\newcommand\csname ganttlinked#1\endcsname[4][]{% + \begingroup% + \ganttset{##1}% + \gtt@chartelement{##2}{##3}{##4}{#1}% + \ganttlink{\gtt@lastelement}{\gtt@currentelement}% + \endgroup% + }% + \@newganttchartelement@definekeys{#1}% +} + +\newcommand\@newganttchartelement@definekeys[2]{% + \@gtt@stylekeydef{#1}{shape=rectangle, inner sep=0pt, draw, fill=white}% + \@gtt@stylekeydef{#1 incomplete}{/pgfgantt/#1, fill=black!25}% + \@gtt@keydef{#1 label font}{\normalsize}% + \@gtt@stylekeydef{#1 label node}{% + anchor=east, font=\ganttvalueof{#1 label font}% + }% + \@gtt@keydef{#1 inline label anchor}{center}% + \@gtt@stylekeydef{#1 inline label node}{% + anchor=center, font=\ganttvalueof{#1 label font}% + }% + \@gtt@keydef{#1 progress label anchor}{east}% + \@gtt@keydef{#1 progress label font}{\scriptsize}% + \@gtt@stylekeydef{#1 progress label node}{% + anchor=west, font=\ganttvalueof{#1 progress label font}% + }% + \@gtt@keydef{#1 left shift}{0}% + \@gtt@keydef{#1 right shift}{0}% + \@gtt@keydef{#1 top shift}{.3}% + \@gtt@keydef{#1 height}{.4}% + \ganttset{% + #1 label text/.code={% + \expandafter\def\csname gtt@#1labeltext\endcsname####1{##1}% + },% + #1 label text=\strut##1,% + #2% + }% } +\newganttchartelement{bar}{% + bar/.style={shape=ganttbar, inner sep=0pt, draw, fill=white},% + bar incomplete/.style={/pgfgantt/bar, fill=black!25},% + bar label text=\strut#1,% + bar label font=\normalsize,% + bar label node/.style={% + anchor=east, font=\ganttvalueof{bar label font}% + },% + bar inline label anchor=center,% + bar inline label node/.style={% + anchor=center, font=\ganttvalueof{bar label font}% + },% + bar progress label anchor=east,% + bar progress label font=\scriptsize,% + bar progress label node/.style={% + anchor=west, font=\ganttvalueof{bar progress label font}% + },% + bar left shift=0,% + bar right shift=0,% + bar top shift=.3,% + bar height=.4% +} + +\newganttchartelement{group}{% + group/.style={shape=ganttgroup, inner sep=0pt, fill=black},% + group incomplete/.style={/pgfgantt/group, fill=black!25},% + group label text=\strut#1,% + group label font=\bfseries,% + group label node/.style={% + anchor=east, font=\ganttvalueof{group label font}% + },% + group inline label anchor=center,% + group inline label node/.style={% + anchor=south, font=\ganttvalueof{group label font}% + },% + group progress label anchor=east,% + group progress label font=\scriptsize,% + group progress label node/.style={% + anchor=west, font=\ganttvalueof{group progress label font}% + },% + group left shift=-.1,% + group right shift=.1,% + group top shift=.4,% + group height=.2% +} +\@gtt@keydef{group right peak tip position}{.5} +\@gtt@keydef{group right peak width}{.4} +\@gtt@keydef{group right peak height}{.1} +\@gtt@keydef{group left peak tip position}{.5} +\@gtt@keydef{group left peak width}{.4} +\@gtt@keydef{group left peak height}{.1} +\ganttset{% + group peaks tip position/.code={% + \ganttset{% + group left peak tip position=#1,% + group right peak tip position=#1% + }% + },% + group peaks width/.code={% + \ganttset{% + group left peak width=#1,% + group right peak width=#1% + }% + },% + group peaks height/.code={% + \ganttset{% + group left peak height=#1,% + group right peak height=#1% + }% + }% +} + +\newganttchartelement*{milestone}{% + milestone/.style={% + shape=ganttmilestone, inner sep=0pt, draw, fill=black% + },% + milestone incomplete/.style={/pgfgantt/milestone, fill=black!25},% + milestone label text=\strut#1,% + milestone label font=\itshape,% + milestone label node/.style={% + anchor=east, font=\ganttvalueof{milestone label font}% + },% + milestone inline label anchor=center,% + milestone inline label node/.style={% + anchor=south, font=\ganttvalueof{milestone label font}% + },% + milestone progress label anchor=center,% + milestone progress label font=\scriptsize,% + milestone progress label node/.style={% + anchor=west, font=\ganttvalueof{milestone progress label font}% + },% + milestone left shift=.6,% + milestone right shift=.4,% + milestone top shift=.3,% + milestone height=.4% +} + +\@gtt@keydef{on top fraction}{.5} +\@gtt@keydef{on bottom fraction}{.5} +\@gtt@keydef{on left fraction}{.5} +\@gtt@keydef{on right fraction}{.5} + +\pgfdeclareshape{ganttbar}{ + \inheritsavedanchors[from=rectangle] + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{south east} + \inheritanchorborder[from=rectangle] + \anchor{on top}{ + \southwest + \pgf@xa=\pgf@x + \northeast + \pgf@xb=\pgf@x + \advance\pgf@xb by-\pgf@xa + \pgf@xb=\ganttvalueof{on top fraction}\pgf@xb + \advance\pgf@xa by\pgf@xb + \pgf@x=\pgf@xa + } + \anchor{on bottom}{ + \northeast + \pgf@xb=\pgf@x + \southwest + \pgf@xa=\pgf@x + \advance\pgf@xb by-\pgf@xa + \pgf@xb=\ganttvalueof{on bottom fraction}\pgf@xb + \advance\pgf@xa by\pgf@xb + \pgf@x=\pgf@xa + } + \anchor{on left}{ + \northeast + \pgf@ya=\pgf@y + \southwest + \pgf@yb=\pgf@y + \advance\pgf@yb by-\pgf@ya + \pgf@yb=\ganttvalueof{on left fraction}\pgf@yb + \advance\pgf@ya by\pgf@yb + \pgf@y=\pgf@ya + } + \anchor{on right}{ + \southwest + \pgf@yb=\pgf@y + \northeast + \pgf@ya=\pgf@y + \advance\pgf@yb by-\pgf@ya + \pgf@yb=\ganttvalueof{on right fraction}\pgf@yb + \advance\pgf@ya by\pgf@yb + \pgf@y=\pgf@ya + } + \inheritbackgroundpath[from=rectangle] +} + +\pgfdeclareshape{ganttgroup}{ + \inheritsavedanchors[from=rectangle] + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{south east} + \inheritanchorborder[from=rectangle] + \inheritanchor[from=ganttbar]{on top} + \inheritanchor[from=ganttbar]{on bottom} + \inheritanchor[from=ganttbar]{on left} + \inheritanchor[from=ganttbar]{on right} + \anchor{left peak}{ + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgfmathsetlength\pgf@x{ + \pgf@x + \ganttvalueof{group left peak tip position} + * \ganttvalueof{group left peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@y{ + \pgf@y - \ganttvalueof{group left peak height} + * \ganttvalueof{y unit chart} + } + } + \anchor{right peak}{ + \pgf@process{ + \pgfpointadd{ + \northeast + }{ + \pgfpointscale{-1}{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + } + \pgf@xa=\pgf@x + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgfmathsetlength\pgf@x{ + \pgf@xa - \ganttvalueof{group right peak tip position} + * \ganttvalueof{group right peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@y{ + \pgf@y - \ganttvalueof{group right peak height} + * \ganttvalueof{y unit chart} + } + } + \backgroundpath{ + \pgf@process{ + \pgfpointadd{ + \northeast + }{ + \pgfpointscale{-1}{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + } + \pgf@xb=\pgf@x + \pgf@ya=\pgf@y + \pgf@process{ + \pgfpointadd{ + \southwest + }{ + \pgfpoint% + {\pgfkeysvalueof{/pgf/outer xsep}}% + {\pgfkeysvalueof{/pgf/outer ysep}} + } + } + \pgf@xa=\pgf@x + \pgf@yb=\pgf@y + \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xb - \ganttvalueof{group right peak tip position} + * \ganttvalueof{group right peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@yc{ + \pgf@yb - \ganttvalueof{group right peak height} + * \ganttvalueof{y unit chart} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}} + \pgfmathsetlength\pgf@xc{ + \pgf@xb - \ganttvalueof{group right peak width} + * \ganttvalueof{x unit} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xa + \ganttvalueof{group left peak width} + * \ganttvalueof{x unit} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}} + \pgfmathsetlength\pgf@xc{ + \pgf@xa + \ganttvalueof{group left peak tip position} + * \ganttvalueof{group left peak width} * \ganttvalueof{x unit} + } + \pgfmathsetlength\pgf@yc{ + \pgf@yb - \ganttvalueof{group left peak height} + * \ganttvalueof{y unit chart} + } + \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}} + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} + \pgfpathclose + } +} + +\pgfdeclareshape{ganttmilestone}{ + \inheritsavedanchors[from=diamond] + \inheritanchor[from=diamond]{text} + \inheritanchor[from=diamond]{center} + \inheritanchor[from=diamond]{mid} + \inheritanchor[from=diamond]{base} + \inheritanchor[from=diamond]{north} + \inheritanchor[from=diamond]{south} + \inheritanchor[from=diamond]{west} + \inheritanchor[from=diamond]{north west} + \inheritanchor[from=diamond]{south west} + \inheritanchor[from=diamond]{east} + \inheritanchor[from=diamond]{north east} + \inheritanchor[from=diamond]{south east} + \inheritanchorborder[from=diamond] + \inheritbackgroundpath[from=diamond] + \anchor{on top}{ + \pgf@process{\outernortheast} + \pgf@xa=2\pgf@x + \pgf@x=-\pgf@x + \advance\pgf@x by\ganttvalueof{on top fraction}\pgf@xa + \pgf@ya=2\pgf@y + \pgf@y=0pt + \pgfmathparse{ + \ganttvalueof{on top fraction} < 0.5 + ? \ganttvalueof{on top fraction} + : 1 - \ganttvalueof{on top fraction} + } + \advance\pgf@y by\pgfmathresult\pgf@ya + } + \anchor{on bottom}{ + \pgf@process{\outernortheast} + \pgf@xa=2\pgf@x + \pgf@x=-\pgf@x + \advance\pgf@x by\ganttvalueof{on bottom fraction}\pgf@xa + \pgf@ya=-2\pgf@y + \pgf@y=0pt + \pgfmathparse{ + \ganttvalueof{on bottom fraction} < 0.5 + ? \ganttvalueof{on bottom fraction} + : 1 - \ganttvalueof{on bottom fraction} + } + \advance\pgf@y by\pgfmathresult\pgf@ya + } + \anchor{on right}{ + \pgf@process{\outernortheast} + \pgf@ya=-2\pgf@y + \advance\pgf@y by\ganttvalueof{on right fraction}\pgf@ya + \pgf@xa=2\pgf@x + \pgf@x=0pt + \pgfmathparse{ + \ganttvalueof{on right fraction} < 0.5 + ? \ganttvalueof{on right fraction} + : 1 - \ganttvalueof{on right fraction} + } + \advance\pgf@x by\pgfmathresult\pgf@xa + } + \anchor{on left}{ + \pgf@process{\outernortheast} + \pgf@ya=-2\pgf@y + \advance\pgf@y by\ganttvalueof{on left fraction}\pgf@ya + \pgf@xa=-2\pgf@x + \pgf@x=0pt + \pgfmathparse{ + \ganttvalueof{on left fraction} < 0.5 + ? \ganttvalueof{on left fraction} + : 1 - \ganttvalueof{on left fraction} + } + \advance\pgf@x by\pgfmathresult\pgf@xa + } +} + +\@gtt@stylekeydef{link}{-latex, rounded corners=1pt} +\@gtt@keydef{link type}{auto} +\@gtt@keydef{link label}{} +\@gtt@keydef{link label font}{\scriptsize\itshape} +\@gtt@stylekeydef{link label node}{% + anchor=west, font=\ganttvalueof{link label font}% +} \newcommand\newganttlinktype[2]{% \expandafter\def\csname @gtt@linktype@#1\endcsname{#2}% } +\newcommand\setganttlinklabel[2]{% + \expandafter\def\csname @gtt@linktype@#1@label\endcsname{#2}% +} + \newcommand\newganttlinktypealias[2]{% \expandafter\def\csname @gtt@linktype@#1\endcsname{% - \@nameuse{@gtt@linktype@#2}% + \csname @gtt@linktype@#2\endcsname% }% \expandafter\def\csname @gtt@linktype@#1@label\endcsname{% - \@nameuse{@gtt@linktype@#2@label}% + \csname @gtt@linktype@#2@label\endcsname% }% } -\newcommand\setganttlinklabel[2]{% - \expandafter\def\csname @gtt@linktype@#1@label\endcsname{#2}% -} - +\@gtt@keydef{link mid}{.5} +\@gtt@keydef{link bulge}{.4} +\@gtt@keydef{link tolerance}{.6} \newganttlinktype{r}{% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \newganttlinktypealias{default}{r} @@ -627,23 +1325,39 @@ (\xRight, \yLower);% } +\newganttlinktype{auto}{% + \pgfmathparse{abs(\yUpper - \yLower) <= 1}% + \ifcase\pgfmathresult% + \pgfmathparse{ + (\xRight - \xLeft) + >= \ganttvalueof{link tolerance} * \ganttvalueof{x unit} + }% + \ifcase\pgfmathresult% + \gtt@drawlink{rdldr}% + \else% + \gtt@drawlink{rdr}% + \fi% + \else% + \gtt@drawlink{r}% + \fi% +} \newganttlinktype{dr}{% - \ganttsetstartanchor{on bottom=.6}% - \ganttsetendanchor{on left}% + \ganttsetstartanchor{south}% + \ganttsetendanchor{west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xLeft, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel} -- + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel} -- (\xRight, \yLower);% } \newganttlinktype{s-s}{% - \ganttsetstartanchor{on bottom=0}% - \ganttsetendanchor{on top=0}% + \ganttsetstartanchor{south west}% + \ganttsetendanchor{north west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{s-s}{start-to-start} @@ -653,33 +1367,33 @@ \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{s-f}{start-to-finish} \newganttlinktype{f-s}{% - \ganttsetstartanchor{on bottom=1}% - \ganttsetendanchor{on top=0}% + \ganttsetstartanchor{south east}% + \ganttsetendanchor{north west}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{f-s}{finish-to-start} \newganttlinktype{f-f}{% - \ganttsetstartanchor{on bottom=1}% - \ganttsetendanchor{on top=1}% + \ganttsetstartanchor{south east}% + \ganttsetendanchor{north east}% \draw [/pgfgantt/link] (\xLeft, \yUpper) -- (\xRight, \yLower) - node [pos=.5, /pgfgantt/link label anchor] {\ganttlinklabel}; + node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel}; } \setganttlinklabel{f-f}{finish-to-finish} \newcommand\gtt@drawlink[1]{% \@ifundefined{@gtt@linktype@#1}{% - \PackageWarning{pgfgantt}{Link type `#1' unknown, using `default'.}% + \@gtt@PackageWarning{Link type `#1' unknown, using `default'.}% \def\@gtt@currlinktype{default}% }{% \def\@gtt@currlinktype{#1}% @@ -687,50 +1401,45 @@ \edef\@gtt@currlabel{\ganttvalueof{link label}}% \ifx\@gtt@currlabel\@empty% \def\ganttlinklabel{% - \ganttvalueof{link label font}{% - \csname @gtt@linktype@\@gtt@currlinktype @label\endcsname% - }% + \csname @gtt@linktype@\@gtt@currlinktype @label\endcsname% }% \else% - \def\ganttlinklabel{% - \ganttvalueof{link label font}{% - \@gtt@currlabel% - }% + \edef\ganttlinklabel{% + \ganttvalueof{link label}% }% \fi% - \@nameuse{@gtt@linktype@\@gtt@currlinktype}% + \csname @gtt@linktype@\@gtt@currlinktype\endcsname% } +\ganttset{% + link anchor/.unknown/.code={% + \edef\@gtt@link@anchor{\pgfkeyscurrentname}% + },% +} \def\@gtt@linkanchordef#1{% \ganttset{% link anchor/#1/.code={% - \def\@gtt@linkanchor{#1}% - \def\@gtt@linkanchorfraction{##1}% + \edef\@gtt@link@anchor{#1}% + \ganttset{#1 fraction=##1}% },% link anchor/#1/.default=.5% - } + }% } -\@gtt@linkanchordef{on left} -\@gtt@linkanchordef{on right} \@gtt@linkanchordef{on top} \@gtt@linkanchordef{on bottom} -\@gtt@linkanchordef{lower left} -\@gtt@linkanchordef{left} -\@gtt@linkanchordef{upper left} -\@gtt@linkanchordef{lower right} -\@gtt@linkanchordef{right} -\@gtt@linkanchordef{upper right} +\@gtt@linkanchordef{on left} +\@gtt@linkanchordef{on right} \newcommand\@gtt@setstartanchor[1]{% \pgfqkeys{/pgfgantt/link anchor}{#1}% - \pgfpointanchor{\@gtt@startelement}{\@gtt@linkanchor}% + \pgfpointanchor{\@gtt@link@startelement}{\@gtt@link@anchor}% \edef\xLeft{\the\pgf@x}% \edef\yUpper{\the\pgf@y}% } \newcommand\@gtt@setendanchor[1]{% \pgfqkeys{/pgfgantt/link anchor}{#1}% - \pgfpointanchor{\@gtt@endelement}{\@gtt@linkanchor}% + \pgfpointanchor{\@gtt@link@endelement}{\@gtt@link@anchor}% \edef\xRight{\the\pgf@x}% \edef\yLower{\the\pgf@y}% } @@ -738,231 +1447,16 @@ \newcommand\ganttlink[3][]{% \begingroup% \ganttset{#1}% - \def\@gtt@startelement{#2}% - \def\@gtt@endelement{#3}% + \def\@gtt@link@startelement{#2}% + \def\@gtt@link@endelement{#3}% \let\ganttsetstartanchor\@gtt@setstartanchor% \let\ganttsetendanchor\@gtt@setendanchor% - \ganttsetstartanchor{right}% - \ganttsetendanchor{left}% - \def\@tempa{auto}% - \edef\@tempb{\ganttvalueof{link type}}% - \ifx\@tempa\@tempb% - \pgfmathparse{abs(\yUpper - \yLower) <= 1}% - \ifcase\pgfmathresult% - \pgfmathparse{ - (\xRight - \xLeft) - >= \ganttvalueof{link tolerance} * \ganttvalueof{x unit} - }% - \ifcase\pgfmathresult% - \gtt@drawlink{rdldr}% - \else% - \gtt@drawlink{rdr}% - \fi% - \else% - \gtt@drawlink{r}% - \fi% - \else% - \gtt@drawlink{\ganttvalueof{link type}}% - \fi% - \endgroup% -} - -\newcommand\ganttgroup[4][]{% - \begingroup% - \ganttset{#1}% - \pgfmathsetmacro\x@left{% - (#3 + \ganttvalueof{time slot modifier}% - + \ganttvalueof{group left shift})% - * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\x@right{% - (#4 + \ganttvalueof{group right shift}) * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\y@upper{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title} - + (\value{gtt@currentline} - \value{gtt@lasttitleline} - - \ganttvalueof{group top shift}) * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@lower{% - \y@upper - \ganttvalueof{group height} * \ganttvalueof{y unit chart}% - }% - \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; - \def\@tempa{none}% - \ifx\gtt@progress\@tempa% - \def\gtt@progress{100}% - \let\gtt@pl@draw\relax% - \else - \expandafter\ifx\gtt@progresslabeltext\relax\relax% - \let\gtt@pl@draw\relax% - \else% - \def\gtt@pl@draw{% - \node at ($(\x@right pt, \y@upper pt)!.5! - (\x@right pt, \y@lower pt)$) - [/pgfgantt/progress label anchor] {% - \ganttvalueof{progress label font}{% - \gtt@progresslabeltext{\gtt@progress}% - }% - };% - }% - \fi% - \fi% - \pgfmathsetmacro\@maxpeak{% - \gtt@grouprightpeaky > \gtt@groupleftpeaky ?% - \gtt@grouprightpeaky * \ganttvalueof{y unit chart} :% - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}% - }% - \begin{scope}% - \clip (\x@left pt, \y@upper pt) rectangle - ($(\x@left pt, \y@lower pt - \@maxpeak pt)!% - \gtt@progress/100!% - (\x@right pt, \y@lower pt - \@maxpeak pt)$);% - \path [/pgfgantt/group, draw=none] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky - * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \end{scope}% - \begin{scope}% - \clip ($(\x@left pt, \y@upper pt)!% - \gtt@progress/100!% - (\x@right pt, \y@upper pt)$) - rectangle (\x@right pt, \y@lower pt - \@maxpeak pt); - \path [/pgfgantt/group incomplete] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky - * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \end{scope}% - \path [/pgfgantt/group, fill=none] - (\x@left pt, \y@upper pt) -- - (\x@right pt, \y@upper pt) -- - (\x@right pt, \y@lower pt) -- - (\x@right pt + \gtt@grouprightpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@grouprightpeaky * \ganttvalueof{y unit chart}) -- - (\x@right pt + \gtt@grouprightpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakinnerx * \ganttvalueof{x unit}, - \y@lower pt) -- - (\x@left pt + \gtt@groupleftpeakmidx * \ganttvalueof{x unit}, - \y@lower pt - \gtt@groupleftpeaky * \ganttvalueof{y unit chart}) -- - (\x@left pt, \y@lower pt) -- - cycle;% - \gtt@pl@draw% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{group label shape anchor}) - [/pgfgantt/group label inline anchor] - {\ganttvalueof{group label font}{\gtt@grouplabeltext{#2}}};% - \else% - \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$) - [/pgfgantt/group label anchor] - {\ganttvalueof{group label font}{\gtt@grouplabeltext{#2}}};% - \fi% - \fi% - \xdef\gtt@lastelement{\gtt@currentelement}% - \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% - \global\gtt@intitlefalse% + \ganttsetstartanchor{east}% + \ganttsetendanchor{west}% + \gtt@drawlink{\ganttvalueof{link type}}% \endgroup% } -\newcommand\ganttlinkedgroup[4][]{% - \begingroup% - \ganttset{#1}% - \ganttgroup{#2}{#3}{#4}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% - \endgroup% -} - -\newcommand\ganttmilestone[3][]{% - \begingroup% - \ganttset{#1}% - \pgfmathsetmacro\x@mid{% - (#3 + \ganttvalueof{milestone xshift}) * \ganttvalueof{x unit}% - }% - \pgfmathsetmacro\x@left{% - \x@mid - \ganttvalueof{milestone width} / 2 * \ganttvalueof{x unit}% - } - \pgfmathsetmacro\x@right{% - \x@mid + \ganttvalueof{milestone width} / 2 * \ganttvalueof{x unit}% - } - \pgfmathsetmacro\y@mid{% - \value{gtt@lasttitleline} * \ganttvalueof{y unit title}% - + (\value{gtt@currentline} - \value{gtt@lasttitleline}% - - \ganttvalueof{milestone yshift}) * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@upper{% - \y@mid + \ganttvalueof{milestone height} / 2 - * \ganttvalueof{y unit chart}% - }% - \pgfmathsetmacro\y@lower{% - \y@mid - \ganttvalueof{milestone height} / 2 - * \ganttvalueof{y unit chart}% - }% - \edef\gtt@name{\ganttvalueof{name}}% - \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi% - \node [shape=chart element] (\gtt@name) - at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {}; - \path [/pgfgantt/milestone] - (\x@left pt, \y@mid pt) -- - (\x@mid pt, \y@lower pt) -- - (\x@right pt, \y@mid pt) -- - (\x@mid pt, \y@upper pt) -- - cycle;% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else% - \ifgtt@inline% - \node at (\gtt@name.\ganttvalueof{milestone label shape anchor}) - [/pgfgantt/milestone label inline anchor] - {\ganttvalueof{milestone label font}{% - \gtt@milestonelabeltext{#2}% - }};% - \else% - \node at (0pt, \y@mid pt) - [/pgfgantt/milestone label anchor] - {\ganttvalueof{milestone label font}{% - \gtt@milestonelabeltext{#2}% - }};% - \fi% - \fi% - \xdef\gtt@lastelement{\gtt@currentelement}% - \xdef\gtt@currentelement{\gtt@name}% - \stepcounter{gtt@elementid}% - \global\gtt@intitlefalse% - \endgroup% -} - -\newcommand\ganttlinkedmilestone[3][]{% - \begingroup% - \ganttset{#1}% - \ganttmilestone{#2}{#3}% - \ganttlink{\gtt@lastelement}{\gtt@currentelement}% - \endgroup% -} \endinput %% %% End of file `pgfgantt.sty'. |