Debian Codegraph @

texmf-dist/tex/latex/pgfgantt/pgfgantt.sty

raw
1 %%
2 %% This is file `pgfgantt.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% pgfgantt.dtx (with options: `pgfgantt')
8 %%
9 %% Copyright (C) 2024 by Wolfgang Esser-Skala
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3c
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% http://www.latex-project.org/lppl.txt
16 %% and version 1.3c or later is part of all distributions of LaTeX
17 %% version 2008/05/04 or later.
18 %%
19 \ProvidesPackage{pgfgantt}[2024/06/19 v5.0a Draw Gantt diagrams with TikZ]
20 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
21 \RequirePackage{tikz}
22 \usetikzlibrary{%
23 arrows, backgrounds, calc,%
24 patterns, positioning, shapes.geometric%
25 }
26 \RequirePackage{pgfcalendar}
27
28 \def\@gtt@ifstar#1{\kernel@ifnextchar*{\@firstoftwo{#1}}}
29 \def\ganttset#1{\pgfqkeys{/pgfgantt}{#1}}
30 \def\@gtt@keydef#1#2{%
31 \pgfkeyssetvalue{/pgfgantt/#1}{#2}%
32 }
33 \def\ganttvalueof#1{%
34 \pgfkeysvalueof{/pgfgantt/#1}%
35 }
36 \def\@gtt@stylekeydef#1#2{%
37 \pgfkeys{/pgfgantt/#1/.style={#2}}%
38 }
39 \def\@gtt@PackageError#1{%
40 \PackageError{pgfgantt}{#1}{}%
41 }
42 \def\@gtt@PackageWarning#1{%
43 \PackageWarning{pgfgantt}{#1}%
44 }
45
46 \newcount\gtt@currentline
47 \newcount\gtt@lasttitleline
48 \newcount\gtt@currgrid
49 \newcount\gtt@chartwidth
50 \@gtt@stylekeydef{hgrid style}{dotted}
51 \newif\ifgtt@hgrid
52 \ganttset{%
53 hgrid/.code={%
54 \def\@tempa{#1}%
55 \def\@tempb{false}%
56 \ifx\@tempa\@tempb%
57 \gtt@hgridfalse%
58 \else%
59 \gtt@hgridtrue%
60 \def\@tempb{true}%
61 \ifx\@tempa\@tempb%
62 \def\gtt@hgridstyle{dotted}%
63 \else%
64 \def\gtt@hgridstyle{#1}%
65 \fi%
66 \fi%
67 },%
68 hgrid/.default=dotted
69 }
70
71 \def\gtt@hgrid@do#1,{%
72 \ifx\relax#1\else
73 \ifnum\gtt@currgrid<\gtt@currentline\else%
74 \gtt@hgrid@analyze#1\relax%
75 \expandafter\expandafter\expandafter\gtt@hgrid@do%
76 \expandafter\fi%
77 \fi%
78 }
79
80 \def\gtt@hgrid@analyze{%
81 \@gtt@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}%
82 }
83
84 \def\gtt@hgrid@draw#1#2\relax{%
85 \foreach \i in {1,...,#1} {%
86 \pgfmathsetmacro\y@upper{%
87 \gtt@lasttitleline * \ganttvalueof{y unit title} +%
88 (\gtt@currgrid - \gtt@lasttitleline)%
89 * \ganttvalueof{y unit chart}%
90 }%
91 \draw [#2]
92 (0pt, \y@upper pt) --
93 (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);%
94 \global\advance\gtt@currgrid by-1\relax%
95 \ifnum\gtt@currgrid<\gtt@currentline\breakforeach\fi%
96 }%
97 }
98
99 \newif\ifgtt@vgrid
100 \ganttset{%
101 vgrid/.code={%
102 \def\@tempa{#1}%
103 \def\@tempb{false}%
104 \ifx\@tempa\@tempb%
105 \gtt@vgridfalse%
106 \else%
107 \gtt@vgridtrue%
108 \def\@tempb{true}%
109 \ifx\@tempa\@tempb%
110 \def\gtt@vgridstyle{dotted}%
111 \else%
112 \def\gtt@vgridstyle{#1}%
113 \fi%
114 \fi%
115 },%
116 vgrid/.default=dotted
117 }
118
119 \def\gtt@vgrid@do#1,{%
120 \ifx\relax#1\else%
121 \ifnum\gtt@currgrid>\gtt@chartwidth\else%
122 \gtt@vgrid@analyze#1\relax%
123 \expandafter\expandafter\expandafter\gtt@vgrid@do%
124 \expandafter\fi%
125 \fi%
126 }
127
128 \def\gtt@vgrid@analyze{%
129 \@gtt@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}%
130 }
131
132 \def\gtt@vgrid@draw#1#2\relax{%
133 \foreach \i in {1,...,#1} {%
134 \draw [#2]
135 (\gtt@currgrid * \ganttvalueof{x unit}, \y@upper pt) --%
136 (\gtt@currgrid * \ganttvalueof{x unit}, \y@lower pt);%
137 \global\advance\gtt@currgrid by1\relax%
138 \ifnum\gtt@currgrid>\gtt@chartwidth\breakforeach\fi%
139 }%
140 }
141
142 \def\gtt@smugglecount#1\endgroup{%
143 \edef\@tempa{\the#1}%
144 \expandafter\endgroup\expandafter#1\expandafter=\@tempa%
145 }
146
147 \newcommand\gtt@juliantotimeslot[2]{%
148 \begingroup%
149 \@tempcnta=#1\relax%
150 \ifgtt@timeslotunit@day%
151 \advance\@tempcnta by-\gtt@startjulian\relax%
152 \advance\@tempcnta by1\relax%
153 \fi%
154 \ifgtt@timeslotunit@month%
155 \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}%
156 \@tempcnta=\@tempa\relax%
157 \advance\@tempcnta by-\gtt@startyear\relax%
158 \multiply\@tempcnta by12\relax%
159 \advance\@tempcnta by\@tempb\relax%
160 \advance\@tempcnta by-\gtt@startmonth\relax%
161 \advance\@tempcnta by1\relax%
162 \fi%
163 \ifgtt@timeslotunit@year%
164 \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}%
165 \@tempcnta=\@tempa\relax%
166 \advance\@tempcnta by-\gtt@startyear\relax%
167 \advance\@tempcnta by1\relax%
168 \fi%
169 #2=\@tempcnta\relax%
170 \gtt@smugglecount#2%
171 \endgroup%
172 }
173
174 \newcommand\newgantttimeslotformat[2]{%
175 \expandafter\def\csname gtt@tsstojulian@#1\endcsname##1##2{%
176 \begingroup#2\gtt@smugglecount##2\endgroup%
177 }%
178 }
179
180 \newgantttimeslotformat{simple}{%
181 #2=#1\relax%
182 \advance#2 by\gtt@tsf@startjulian\relax%
183 \advance#2 by-1\relax%
184 }
185
186 \newgantttimeslotformat{isodate}{%
187 \pgfcalendardatetojulian{#1}{#2}%
188 }
189
190 \newgantttimeslotformat{isodate-yearmonth}{%
191 \pgfcalendardatetojulian{#1-01}{#2}%
192 }
193
194 \newgantttimeslotformat{isodate-year}{%
195 \pgfcalendardatetojulian{#1-01-01}{#2}%
196 }
197
198 \newcommand\gtt@tsf@getdmy[1]{%
199 \edef\local@firstarg{#1}%
200 \def\local@decompose##1.##2.##3\relax{%
201 \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}%
202 }%
203 \expandafter\local@decompose\local@firstarg..\relax%
204 \ifx\local@month\@empty%
205 \def\local@decompose##1/##2/##3\relax{%
206 \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}%
207 }%
208 \expandafter\local@decompose\local@firstarg//\relax%
209 \ifx\local@month\@empty%
210 \def\local@decompose##1-##2-##3\relax{%
211 \def\local@day{##1}\def\local@month{##2}\def\local@year{##3}%
212 }%
213 \expandafter\local@decompose\local@firstarg--\relax%
214 \ifx\local@month\@empty%
215 \@gtt@PackageError{Illegal time slot specifier `#1'.}%
216 \else%
217 \def\local@decompose##1--{\def\local@year{##1}}%
218 \expandafter\local@decompose\local@year%
219 \fi%
220 \else%
221 \def\local@decompose##1//{\def\local@year{##1}}%
222 \expandafter\local@decompose\local@year%
223 \fi%
224 \else%
225 \def\local@decompose##1..{\def\local@year{##1}}%
226 \expandafter\local@decompose\local@year%
227 \fi%
228 }
229
230 \newgantttimeslotformat{little-endian}{%
231 \gtt@tsf@getdmy{#1}%
232 \ifnum\local@year<100\relax%
233 \edef\local@year{\gtt@tsf@basecentury\local@year}%
234 \fi%
235 \pgfcalendardatetojulian{\local@year-\local@month-\local@day}{#2}%
236 }
237
238 \newgantttimeslotformat{big-endian}{%
239 \gtt@tsf@getdmy{#1}%
240 \ifnum\local@day<100\relax%
241 \edef\local@day{\gtt@tsf@basecentury\local@day}%
242 \fi%
243 \pgfcalendardatetojulian{\local@day-\local@month-\local@year}{#2}%
244 }
245
246 \newgantttimeslotformat{middle-endian}{%
247 \gtt@tsf@getdmy{#1}%
248 \ifnum\local@year<100\relax%
249 \edef\local@year{\gtt@tsf@basecentury\local@year}%
250 \fi%
251 \pgfcalendardatetojulian{\local@year-\local@day-\local@month}{#2}%
252 }
253
254 \ganttset{%
255 time slot format/.code={%
256 \@ifundefined{gtt@tsstojulian@#1}{%
257 \@gtt@PackageError{%
258 Time slot format `#1' undefined.%
259 }%
260 }{}%
261 \expandafter\let\expandafter\gtt@tsstojulian%
262 \csname gtt@tsstojulian@#1\endcsname%
263 },%
264 time slot format=simple,%
265 time slot format/base century/.code={%
266 \begingroup%
267 \@tempcnta=#1\relax%
268 \divide\@tempcnta by100\relax%
269 \xdef\gtt@tsf@basecentury{\the\@tempcnta}%
270 \endgroup%
271 },%
272 time slot format/base century=2000,%
273 time slot format/start date/.code={%
274 \begingroup%
275 \pgfcalendardatetojulian{#1}{\@tempcnta}%
276 \xdef\gtt@tsf@startjulian{\the\@tempcnta}%
277 \endgroup%
278 },%
279 time slot format/start date=2000-01-01%
280 }
281
282 \@gtt@keydef{x unit}{.5cm}
283 \@gtt@keydef{y unit title}{1cm}
284 \@gtt@keydef{y unit chart}{1cm}
285 \@gtt@stylekeydef{canvas}{shape=rectangle, draw, fill=white}
286 \@gtt@keydef{expand chart}{none}
287 \@gtt@keydef{today}{none}
288 \@gtt@keydef{today offset}{1}
289 \@gtt@stylekeydef{today rule}{dashed, line width=1pt}
290 \@gtt@keydef{today label}{TODAY}
291 \@gtt@keydef{today label font}{\normalfont}
292 \@gtt@stylekeydef{today label node}{%
293 anchor=north, font=\ganttvalueof{today label font}%
294 }
295 \newif\ifgtt@newlineshortcut
296 \ganttset{%
297 newline shortcut/.is if=gtt@newlineshortcut,%
298 newline shortcut=true%
299 }
300
301 \newif\ifgtt@tikzpicture
302 \newif\ifgtt@intitle
303 \newcount\gtt@lasttitleslot
304 \newcount\gtt@elementid
305 \newcount\gtt@today@slot
306 \newcount\gtt@startjulian
307 \newcount\gtt@endjulian
308 \newcount\gtt@chartid
309 \def\gtt@chartextrasize#1#2{%
310 \global\@namedef{@gtt@chart@#1@extrasize}{#2}%
311 }
312 \newenvironment{ganttchart}[3][]{%
313 \ganttset{#1}%
314 \gtt@tsstojulian{#2}{\gtt@startjulian}%
315 \global\gtt@startjulian=\gtt@startjulian\relax%
316 \gtt@tsstojulian{#3}{\gtt@endjulian}%
317 \global\gtt@endjulian=\gtt@endjulian\relax%
318 \pgfcalendarjuliantodate{\gtt@startjulian}%
319 {\gtt@startyear}{\gtt@startmonth}{\@tempa}%
320 \xdef\gtt@startyear{\gtt@startyear}%
321 \xdef\gtt@startmonth{\gtt@startmonth}%
322 \gtt@juliantotimeslot{\gtt@endjulian}{\gtt@chartwidth}
323 \global\gtt@chartwidth=\gtt@chartwidth\relax%
324 \def\@tempa{none}%
325 \edef\@tempb{\ganttvalueof{today}}%
326 \ifx\@tempa\@tempb\else%
327 \gtt@tsstojulian{\ganttvalueof{today}}{\gtt@today@slot}
328 \gtt@juliantotimeslot{\gtt@today@slot}{\gtt@today@slot}%
329 \fi%
330 \global\gtt@elementid=0\relax%
331 \global\gtt@currentline=0\relax%
332 \global\gtt@lasttitleline=0\relax%
333 \global\gtt@lasttitleslot=0\relax%
334 \def\@tempa{none}%
335 \edef\@tempb{\ganttvalueof{expand chart}}%
336 \ifx\@tempa\@tempb\else%
337 \@ifundefined{@gtt@chart@\the\gtt@chartid @extrasize}{%
338 \@gtt@PackageWarning{Gantt chart expansion may have changed.
339 Rerun to get expansion right}%
340 }{%
341 \pgfmathparse{(\ganttvalueof{expand chart}%
342 - \@nameuse{@gtt@chart@\the\gtt@chartid @extrasize})%
343 / \gtt@chartwidth}%
344 \edef\gtt@expanded@xunit{\pgfmathresult pt}%
345 \ganttset{x unit=\gtt@expanded@xunit}%
346 }%
347 \fi%
348 \@ifundefined{useasboundingbox}%
349 {\gtt@tikzpicturefalse\begin{tikzpicture}}%
350 {\gtt@tikzpicturetrue}%
351 \gtt@intitletrue%
352 \ifgtt@newlineshortcut%
353 \let\\\ganttnewline%
354 \fi%
355 \let\ganttalignnewline\tikz@align@newline%
356 }{
357 \begin{scope}[on background layer]%
358 \ifgtt@includetitle%
359 \def\y@upper{0}%
360 \else%
361 \pgfmathsetmacro\y@upper{%
362 \gtt@lasttitleline * \ganttvalueof{y unit title}%
363 }%
364 \fi%
365 \pgfmathsetmacro\y@lower{%
366 \gtt@lasttitleline * \ganttvalueof{y unit title}%
367 + (\gtt@currentline - \gtt@lasttitleline - 1)%
368 * \ganttvalueof{y unit chart}%
369 }%
370 \pgfmathsetmacro\y@mid{%
371 (\y@upper + \y@lower) / 2%
372 }%
373 \pgfmathsetmacro\y@size{%
374 abs(\y@lower - \y@upper)%
375 }%
376 \pgfmathsetmacro\x@size{%
377 \gtt@chartwidth * \ganttvalueof{x unit}%
378 }%
379 \node [/pgfgantt/canvas, minimum width=\x@size pt,
380 minimum height=\y@size pt]
381 at (\x@size pt / 2, \y@mid pt) {};%
382 \pgfmathsetmacro\y@upper{%
383 \gtt@lasttitleline * \ganttvalueof{y unit title}%
384 }%
385 \ifgtt@vgrid
386 \gtt@currgrid=1\relax%
387 \global\advance\gtt@chartwidth by-1\relax%
388 \foreach \x in {1,...,\gtt@chartwidth} {%
389 \expandafter\gtt@vgrid@do\gtt@vgridstyle,\relax,%
390 \ifnum\gtt@currgrid>\gtt@chartwidth\relax\breakforeach\fi%
391 }%
392 \global\advance\gtt@chartwidth by1\relax%
393 \fi%
394 \ifgtt@hgrid%
395 \gtt@currgrid=\gtt@lasttitleline\relax%
396 \ifgtt@includetitle\else%
397 \advance\gtt@currgrid by-1\relax
398 \fi%
399 \edef\@tempa{\the\gtt@currgrid}%
400 \foreach \t in {\@tempa,...,\gtt@currentline} {%
401 \expandafter\gtt@hgrid@do\gtt@hgridstyle,\relax,%
402 \ifnum\gtt@currgrid<\gtt@currentline\relax\breakforeach\fi%
403 }%
404 \fi%
405 \def\@tempa{none}%
406 \edef\@tempb{\ganttvalueof{today}}%
407 \ifx\@tempa\@tempb\else%
408 \pgfmathsetmacro\x@mid{%
409 (\gtt@today@slot - 1 + \ganttvalueof{today offset})%
410 * \ganttvalueof{x unit}%
411 }%
412 \draw [/pgfgantt/today rule]
413 (\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt)
414 node [/pgfgantt/today label node] {\ganttvalueof{today label}};%
415 \fi%
416 \end{scope}%
417 \pgfextractx{\@tempdima}{%
418 \pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}%
419 {\pgfpointanchor{current bounding box}{north east}}%
420 }%
421 \pgfmathparse{\@tempdima -\ganttvalueof{x unit} * \gtt@chartwidth}%
422 \protected@write\@auxout{}{%
423 \string\gtt@chartextrasize{\the\gtt@chartid}{\pgfmathresult pt}}%
424 \global\advance\gtt@chartid by1\relax%
425 \ifgtt@tikzpicture\else\end{tikzpicture}\fi%
426 }
427
428 \newcommand\ganttnewline[1][]{%
429 \begingroup%
430 \def\local@drawarg{#1}%
431 \def\@tempa{grid}%
432 \ifx\local@drawarg\@empty\else%
433 \ifx\local@drawarg\@tempa%
434 \def\local@drawarg{/pgfgantt/hgrid style}%
435 \fi%
436 \pgfmathsetmacro\y@upper{%
437 \gtt@lasttitleline * \ganttvalueof{y unit title}%
438 + (\gtt@currentline - \gtt@lasttitleline - 1)%
439 * \ganttvalueof{y unit chart}%
440 }
441 \expandafter\draw\expandafter[\local@drawarg]
442 (0pt, \y@upper pt) --
443 (\gtt@chartwidth * \ganttvalueof{x unit}, \y@upper pt);%
444 \fi%
445 \global\advance\gtt@currentline by-1\relax%
446 \ifgtt@intitle\global\advance\gtt@lasttitleline by-1\relax\fi%
447 \global\gtt@lasttitleslot=0\relax%
448 \endgroup%
449 }
450
451 \@gtt@keydef{vrule offset}{1}
452 \@gtt@stylekeydef{vrule}{dashed, line width=1pt}
453 \@gtt@keydef{vrule label font}{\normalfont}
454 \@gtt@stylekeydef{vrule label node}{%
455 anchor=north, font=\ganttvalueof{vrule label font}%
456 }
457
458 \newcount\gtt@vrule@slot
459
460 \newcommand\ganttvrule[3][]{%
461 \begingroup
462 \ganttset{#1}
463 \gtt@tsstojulian{#3}{\gtt@vrule@slot}%
464 \gtt@juliantotimeslot{\gtt@vrule@slot}{\gtt@vrule@slot}%
465 \pgfmathsetmacro\y@upper{%
466 \gtt@lasttitleline * \ganttvalueof{y unit title}%
467 }%
468 \pgfmathsetmacro\y@lower{%
469 \gtt@lasttitleline * \ganttvalueof{y unit title}%
470 + (\gtt@currentline - \gtt@lasttitleline - 1)%
471 * \ganttvalueof{y unit chart}%
472 }%
473 \pgfmathsetmacro\x@mid{%
474 (\gtt@vrule@slot - 1 + \ganttvalueof{vrule offset})%
475 * \ganttvalueof{x unit}%
476 }%
477 \draw [/pgfgantt/vrule]
478 (\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt)
479 node [/pgfgantt/vrule label node] {#2};%
480 \endgroup
481 }
482
483 \@gtt@stylekeydef{title}{shape=rectangle, inner sep=0pt, draw, fill=white}
484 \@gtt@keydef{title label font}{\small}
485 \@gtt@stylekeydef{title label node}{%
486 anchor=center, font=\ganttvalueof{title label font}%
487 }
488 \ganttset{%
489 title label text/.code={%
490 \def\gtt@titlelabeltext##1{#1}%
491 },%
492 title label text=\strut#1,%
493 title list options/.code={%
494 \def\gtt@titlelistoptions{[#1]}%
495 },%
496 title list options={var=\x, evaluate=\x}%
497 }
498 \@gtt@keydef{title left shift}{0}
499 \@gtt@keydef{title right shift}{0}
500 \@gtt@keydef{title top shift}{0}
501 \@gtt@keydef{title height}{.6}
502 \newif\ifgtt@includetitle
503 \ganttset{%
504 include title in canvas/.is if=gtt@includetitle,%
505 include title in canvas
506 }
507 \@gtt@keydef{calendar week text}{Week~\currentweek}
508 \newif\ifgtt@timeslotunit@day
509 \newif\ifgtt@timeslotunit@month
510 \newif\ifgtt@timeslotunit@year
511 \ganttset{%
512 time slot unit/.is choice,
513 time slot unit/day/.code={%
514 \gtt@timeslotunit@daytrue%
515 \gtt@timeslotunit@monthfalse%
516 \gtt@timeslotunit@yearfalse%
517 },%
518 time slot unit/month/.code={%
519 \gtt@timeslotunit@dayfalse%
520 \gtt@timeslotunit@monthtrue%
521 \gtt@timeslotunit@yearfalse%
522 },%
523 time slot unit/year/.code={%
524 \gtt@timeslotunit@dayfalse%
525 \gtt@timeslotunit@monthfalse%
526 \gtt@timeslotunit@yeartrue%
527 },%
528 time slot unit=day
529 }
530
531 \newcommand\gantttitle[3][]{%
532 \begingroup%
533 \ganttset{#1}%
534 \pgfmathsetmacro\x@left{%
535 (\gtt@lasttitleslot + \ganttvalueof{title left shift})%
536 * \ganttvalueof{x unit}%
537 }%
538 \pgfmathsetmacro\x@right{%
539 (\gtt@lasttitleslot + #3 + \ganttvalueof{title right shift})%
540 * \ganttvalueof{x unit}%
541 }%
542 \pgfmathsetmacro\x@mid{%
543 (\x@left + \x@right) / 2%
544 }%
545 \pgfmathsetmacro\x@size{%
546 \x@right - \x@left%
547 }%
548 \pgfmathsetmacro\y@upper{%
549 (\gtt@currentline - \ganttvalueof{title top shift})%
550 * \ganttvalueof{y unit title}%
551 }%
552 \pgfmathsetmacro\y@lower{%
553 (\gtt@currentline - \ganttvalueof{title top shift}%
554 - \ganttvalueof{title height}) * \ganttvalueof{y unit title}%
555 }%
556 \pgfmathsetmacro\y@mid{%
557 (\y@upper + \y@lower) / 2%
558 }%
559 \pgfmathsetmacro\y@size{%
560 \y@upper - \y@lower%
561 }%
562 \path (\x@mid pt, \y@mid pt)
563 node [/pgfgantt/title, minimum width=\x@size pt,
564 minimum height=\y@size pt] {}
565 node [/pgfgantt/title label node] {\gtt@titlelabeltext{#2}};%
566 \global\advance\gtt@lasttitleslot by#3\relax%
567 \endgroup%
568 }
569
570 \newcommand\gantttitlelist[3][]{%
571 \begingroup%
572 \ganttset{#1}%
573 \expandafter\foreach\gtt@titlelistoptions in {#2} {\gantttitle{\x}{#3}}%
574 \endgroup%
575 }
576
577 \newif\ifgtt@titlecalendarstar
578 \newcommand\gantttitlecalendar{%
579 \@gtt@ifstar%
580 {\gtt@titlecalendarstartrue\@gantttitlecalendar}%
581 {\gtt@titlecalendarstarfalse\@gantttitlecalendar}%
582 }
583
584 \newcommand\@gantttitlecalendar[1][]{
585 \begingroup%
586 \ganttset{#1}%
587 \ifgtt@titlecalendarstar%
588 \expandafter\@@gantttitlecalendar%
589 \else%
590 \expandafter\@@@gantttitlecalendar\expandafter%
591 {\expandafter\gtt@startjulian\expandafter}\expandafter%
592 {\expandafter\gtt@endjulian\expandafter}%
593 \fi%
594 }
595
596 \newcommand\@@gantttitlecalendar[2]{
597 \gtt@tsstojulian{#1}{\@tempcnta}%
598 \gtt@tsstojulian{#2}{\@tempcntb}%
599 \@@@gantttitlecalendar{\@tempcnta}{\@tempcntb}%
600 }
601
602 \newcommand\@@@gantttitlecalendar[3]{%
603 \pgfcalendarjuliantodate{#1}{\@tempa}{\@tempb}{\@tempc}%
604 \edef\gtt@calendar@startdate{\@tempa-\@tempb-\@tempc}%
605 \pgfcalendarjuliantodate{#2}{\@tempa}{\@tempb}{\@tempc}%
606 \edef\gtt@calendar@enddate{\@tempa-\@tempb-\@tempc}%
607 \gtt@calendar@eolfalse%
608 \pgfqkeys{/pgfgantt/calendar}{#3}%
609 \endgroup%
610 }
611 \newif\ifgtt@calendar@eol
612 \newcount\gtt@calendar@slots
613 \newcount\gtt@calendar@weeknumber
614 \newcount\gtt@calendar@startofweek
615 \def\@gtt@getfourthdigit#1#2#3#4{#4}
616 \def\@gtt@getdecade#1#2#3#4{#1#2#3}
617 \pgfkeys{%
618 /pgf/calendar/end of decade/.code={
619 \begingroup
620 \pgfcalendardatetojulian{#1}{\@tempcnta}
621 \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}
622 \edef\endofdecade{\expandafter\@gtt@getfourthdigit\@tempa}
623 \edef\querydecade{\expandafter\@gtt@getfourthdigit\pgfcalendarifdateyear}
624 \ifnum\endofdecade=\querydecade\relax%
625 \ifnum\pgfcalendarifdatemonth=\@tempb\relax%
626 \ifnum\pgfcalendarifdateday=\@tempc\relax%
627 \global\pgfcalendarmatchestrue%
628 \fi%
629 \fi%
630 \fi%
631 \endgroup
632 }%
633 }
634
635 \ganttset{%
636 calendar/decade/.code={%
637 \ifgtt@calendar@eol\ganttnewline\fi%
638 \begingroup%
639 \gtt@calendar@slots=1\relax%
640 \ifgtt@timeslotunit@year%
641 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
642 \ifdate{end of decade=2009-12-31}{%
643 \gantttitle{%
644 \expandafter\@gtt@getdecade\pgfcalendarcurrentyear%
645 0s%
646 }{\the\gtt@calendar@slots}%
647 \gtt@calendar@slots=0\relax%
648 }{
649 \ifdate{equals=01-01}{%
650 \ifnum\pgfcalendarcurrentjulian>\pgfcalendarbeginjulian\relax%
651 \advance\gtt@calendar@slots by1\relax%
652 \fi
653 }{}%
654 }%
655 \ifdate{equals=\pgfcalendarendiso}{%
656 \ifnum\gtt@calendar@slots=0\relax\else%
657 \gantttitle{%
658 \expandafter\@gtt@getdecade\pgfcalendarcurrentyear%
659 0s%
660 }{\the\gtt@calendar@slots}%
661 \fi%
662 }{}%
663 }%
664 \fi%
665 \endgroup%
666 \gtt@calendar@eoltrue%
667 },%
668 calendar/year/.code={%
669 \ifgtt@calendar@eol\ganttnewline\fi%
670 \begingroup%
671 \gtt@calendar@slots=1\relax%
672 \ifgtt@timeslotunit@year%
673 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
674 \ifdate{equals=12-31}{%
675 \gantttitle{\pgfcalendarcurrentyear}{1}%
676 \gtt@calendar@slots=1\relax%
677 }{
678 \advance\gtt@calendar@slots by1\relax%
679 }%
680 \ifdate{equals=\pgfcalendarendiso}{%
681 \ifnum\gtt@calendar@slots=1\relax\else%
682 \gantttitle{\pgfcalendarcurrentyear}{1}%
683 \fi%
684 }{}%
685 }%
686 \fi%
687 \ifgtt@timeslotunit@month%
688 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
689 \ifdate{equals=12-31}{%
690 \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}%
691 \gtt@calendar@slots=1\relax%
692 }{%
693 \ifdate{end of month=1}{%
694 \advance\gtt@calendar@slots by1\relax%
695 }{}%
696 }%
697 \ifdate{equals=\pgfcalendarendiso}{%
698 \ifdate{end of month=1}{%
699 \advance\gtt@calendar@slots by-1\relax%
700 }{}%
701 \ifdate{equals=12-31}{}{%
702 \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}%
703 }%
704 }{}%
705 }%
706 \fi%
707 \ifgtt@timeslotunit@day%
708 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
709 \ifdate{equals=12-31}{%
710 \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}%
711 \gtt@calendar@slots=1\relax%
712 }{%
713 \advance\gtt@calendar@slots by1\relax%
714 }%
715 \ifdate{equals=\pgfcalendarendiso}{%
716 \ifnum\gtt@calendar@slots=1\relax\else%
717 \advance\gtt@calendar@slots by-1\relax%
718 \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}%
719 \fi%
720 }{}%
721 }%
722 \fi%
723 \endgroup%
724 \gtt@calendar@eoltrue%
725 },%
726 calendar/month/.code={%
727 \ifgtt@calendar@eol\ganttnewline\fi%
728 \begingroup%
729 \gtt@calendar@slots=1\relax%
730 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
731 \ifdate{end of month=1}{%
732 \gantttitle{%
733 \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}%
734 }{%
735 \ifgtt@timeslotunit@month1\fi%
736 \ifgtt@timeslotunit@day\the\gtt@calendar@slots\fi%
737 }%
738 \gtt@calendar@slots=1\relax%
739 }{%
740 \advance\gtt@calendar@slots by1\relax%
741 }%
742 \ifdate{equals=\pgfcalendarendiso}{%
743 \ifnum\gtt@calendar@slots=1\relax\else%
744 \advance\gtt@calendar@slots by-1\relax%
745 \gantttitle{%
746 \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}%
747 }{%
748 \ifgtt@timeslotunit@month1\fi%
749 \ifgtt@timeslotunit@day\the\gtt@calendar@slots\fi%
750 }%
751 \fi%
752 }{}%
753 }%
754 \endgroup%
755 \gtt@calendar@eoltrue%
756 },%
757 calendar/week/.code={%
758 \ifgtt@calendar@eol\ganttnewline\fi%
759 \begingroup%
760 \gtt@calendar@slots=1\relax%
761 \gtt@calendar@weeknumber=#1\relax%
762 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
763 \ifdate{Sunday}{%
764 \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax%
765 \advance\gtt@calendar@startofweek by1\relax%
766 \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax%
767 \pgfcalendarjuliantodate{\gtt@calendar@startofweek}%
768 {\startyear}{\startmonth}{\startday}%
769 \def\currentweek{\the\gtt@calendar@weeknumber}%
770 \gantttitle{%
771 \ganttvalueof{calendar week text}%
772 }{%
773 \the\gtt@calendar@slots%
774 }%
775 \gtt@calendar@slots=1\relax%
776 \advance\gtt@calendar@weeknumber by1\relax%
777 }{%
778 \advance\gtt@calendar@slots by1%
779 }%
780 \ifdate{equals=\pgfcalendarendiso}{%
781 \ifnum\gtt@calendar@slots=1\relax\else%
782 \advance\gtt@calendar@slots by-1\relax%
783 \gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax%
784 \advance\gtt@calendar@startofweek by1\relax%
785 \advance\gtt@calendar@startofweek by-\gtt@calendar@slots\relax%
786 \pgfcalendarjuliantodate{\gtt@calendar@startofweek}%
787 {\startyear}{\startmonth}{\startday}%
788 \def\currentweek{\the\gtt@calendar@weeknumber}%
789 \gantttitle{%
790 \ganttvalueof{calendar week text}%
791 }{%
792 \the\gtt@calendar@slots%
793 }%
794 \fi%
795 }{}%
796 }%
797 \endgroup%
798 \gtt@calendar@eoltrue%
799 },%
800 calendar/week/.default=1,%
801 calendar/weekday/.code={%
802 \ifgtt@calendar@eol\ganttnewline\fi%
803 \begingroup%
804 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
805 \gantttitle{%
806 \csname pgfcalendarweekday#1\endcsname{\pgfcalendarcurrentweekday}%
807 }{1}%
808 }%
809 \endgroup%
810 \gtt@calendar@eoltrue%
811 },%
812 calendar/day/.code={%
813 \ifgtt@calendar@eol\ganttnewline\fi%
814 \begingroup%
815 \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
816 \gantttitle{\pgfcalendarcurrentday}{1}%
817 }%
818 \endgroup%
819 \gtt@calendar@eoltrue%
820 }%
821 }
822
823 \ganttset{%
824 progress/.code={%
825 \def\gtt@progress{#1}%
826 },%
827 progress=none,%
828 progress label text/.code={%
829 \def\gtt@progresslabeltext##1{#1}%
830 },%
831 progress label text={%
832 \pgfmathprintnumber[precision=0, verbatim]{#1}\% complete%
833 }%
834 }
835 \@gtt@keydef{name}{}
836 \newif\ifgtt@ce@startatleftborder
837 \ganttset{%
838 chart element start border/.is choice,%
839 chart element start border/left/.code=\gtt@ce@startatleftbordertrue,%,
840 chart element start border/right/.code=\gtt@ce@startatleftborderfalse,%
841 chart element start border=left%
842 }
843 \newif\ifgtt@inline
844 \ganttset{%
845 inline/.is if=gtt@inline,%
846 inline=false%
847 }
848
849 \def\gtt@lastelement{}
850 \def\gtt@currentelement{}
851 \newif\ifgtt@draw@complete
852 \newif\ifgtt@draw@incomplete
853 \newif\ifgtt@draw@clip
854 \newcount\gtt@left@slot
855 \newcount\gtt@right@slot
856
857 \newcommand\gtt@chartelement[5][]{%
858 \begingroup%
859 \ganttset{#1}%
860 \gtt@tsstojulian{#3}{\gtt@left@slot}%
861 \gtt@juliantotimeslot{\gtt@left@slot}{\gtt@left@slot}%
862 \gtt@tsstojulian{#4}{\gtt@right@slot}%
863 \gtt@juliantotimeslot{\gtt@right@slot}{\gtt@right@slot}%
864 \def\local@timeslotmodifier{-1}%
865 \ifgtt@ce@startatleftborder\else%
866 \ifnum\gtt@left@slot=\gtt@right@slot\relax\else%
867 \def\local@timeslotmodifier{0}%
868 \fi%
869 \fi%
870 \pgfmathsetmacro\x@left{%
871 (\gtt@left@slot + \local@timeslotmodifier%
872 + \ganttvalueof{#5 left shift})%
873 * \ganttvalueof{x unit}%
874 }%
875 \pgfmathsetmacro\x@right{%
876 (\gtt@right@slot + \ganttvalueof{#5 right shift})%
877 * \ganttvalueof{x unit}%
878 }%
879 \pgfmathsetmacro\x@mid{%
880 (\x@left + \x@right) / 2%
881 }%
882 \pgfmathsetmacro\x@size{%
883 \x@right - \x@left%
884 }%
885 \pgfmathsetmacro\y@upper{%
886 \gtt@lasttitleline * \ganttvalueof{y unit title}
887 + (\gtt@currentline - \gtt@lasttitleline
888 - \ganttvalueof{#5 top shift}) * \ganttvalueof{y unit chart}%
889 }%
890 \pgfmathsetmacro\y@lower{%
891 \y@upper - \ganttvalueof{#5 height} * \ganttvalueof{y unit chart}%
892 }%
893 \pgfmathsetmacro\y@mid{%
894 (\y@upper + \y@lower) / 2%
895 }%
896 \pgfmathsetmacro\y@size{%
897 \y@upper - \y@lower%
898 }%
899 \edef\gtt@name{\ganttvalueof{name}}%
900 \ifx\gtt@name\@empty\edef\gtt@name{elem\the\gtt@elementid}\fi%
901 \def\local@none{none}%
902 \ifx\gtt@progress\local@none%
903 \def\gtt@progress{999}%
904 \else%
905 \def\@tempa{today}%
906 \ifx\gtt@progress\@tempa%
907 \edef\@tempa{\ganttvalueof{today}}%
908 \ifx\@tempa\local@none%
909 \@gtt@PackageWarning{%
910 Value of today is `none'. Ignoring `progress=today'%
911 }%
912 \def\gtt@progress{999}%
913 \else\ifnum\gtt@today@slot>\gtt@right@slot\relax%
914 \def\gtt@progress{100}%
915 \else\ifnum\gtt@today@slot<\gtt@left@slot\relax%
916 \def\gtt@progress{0}%
917 \else%
918 \pgfmathsetmacro\gtt@progress{%
919 (\gtt@today@slot - \gtt@left@slot - \local@timeslotmodifier)%
920 / (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)%
921 * 100%
922 }%
923 \fi\fi\fi%
924 \fi%
925 \fi%
926 \gtt@draw@completetrue%
927 \gtt@draw@incompletetrue%
928 \gtt@draw@cliptrue%
929 \ifdim\gtt@progress pt<0.001pt\relax%
930 \gtt@draw@completefalse%
931 \gtt@draw@clipfalse%
932 \else\ifdim\gtt@progress pt>99.999pt\relax%
933 \gtt@draw@incompletefalse%
934 \gtt@draw@clipfalse%
935 \fi\fi%
936 \ifgtt@draw@clip%
937 \pgfmathsetmacro\x@clip@size{%
938 (\gtt@right@slot - \gtt@left@slot - \local@timeslotmodifier)%
939 * \gtt@progress / 100%
940 }
941 \pgfmathsetmacro\x@clip{%
942 (\gtt@left@slot + \local@timeslotmodifier + \x@clip@size%
943 + \ganttvalueof{today offset} - 1) * \ganttvalueof{x unit}%
944 }%
945 \fi%
946 \begin{pgfinterruptboundingbox}%
947 \begin{scope}%
948 \ifgtt@draw@clip%
949 \clip (\x@left pt - 10cm, \y@upper pt + 10cm) rectangle
950 (\x@clip pt, \y@lower pt - 10cm);%
951 \fi%
952 \ifgtt@draw@complete%
953 \node [/pgfgantt/#5, minimum width=\x@size pt,
954 minimum height=\y@size pt]
955 (\gtt@name) at (\x@mid pt, \y@mid pt) {};%
956 \fi%
957 \end{scope}%
958 \begin{scope}%
959 \ifgtt@draw@clip%
960 \clip (\x@clip pt, \y@upper pt + 10cm) rectangle
961 (\x@right pt + 10cm, \y@lower pt - 10cm);%
962 \fi%
963 \ifgtt@draw@incomplete%
964 \node [/pgfgantt/#5 incomplete, minimum width=\x@size pt,
965 minimum height=\y@size pt]
966 (\gtt@name) at (\x@mid pt, \y@mid pt) {};%
967 \fi%
968 \end{scope}%
969 \end{pgfinterruptboundingbox}%
970 \ifdim\gtt@progress pt=999pt\relax\else%
971 \expandafter\ifx\gtt@progresslabeltext\relax\relax\else%
972 \node at (\gtt@name.\ganttvalueof{#5 progress label anchor})
973 [/pgfgantt/#5 progress label node]
974 {\gtt@progresslabeltext{\gtt@progress}};%
975 \fi%
976 \fi%
977 \def\@tempa{#2}%
978 \ifx\@tempa\@empty\else%
979 \ifgtt@inline%
980 \node at (\gtt@name.\ganttvalueof{#5 inline label anchor})
981 [/pgfgantt/#5 inline label node]
982 {\csname gtt@#5labeltext\endcsname{#2}};%
983 \else%
984 \node at (0, \y@mid pt)
985 [/pgfgantt/#5 label node]
986 {\csname gtt@#5labeltext\endcsname{#2}};%
987 \fi%
988 \fi%
989 \xdef\gtt@lastelement{\gtt@currentelement}%
990 \xdef\gtt@currentelement{\gtt@name}%
991 \global\advance\gtt@elementid by1\relax%
992 \global\gtt@intitlefalse%
993 \endgroup%
994 }
995
996 \def\newganttchartelement{%
997 \@gtt@ifstar\@newganttchartelement@one\@newganttchartelement@two%
998 }
999
1000 \newcommand\@newganttchartelement@one[1]{%
1001 \expandafter\newcommand\csname gantt#1\endcsname[3][]{%
1002 \gtt@chartelement[##1]{##2}{##3}{##3}{#1}%
1003 }%
1004 \expandafter\newcommand\csname ganttlinked#1\endcsname[3][]{%
1005 \begingroup%
1006 \ganttset{##1}%
1007 \gtt@chartelement{##2}{##3}{##3}{#1}%
1008 \ganttlink{\gtt@lastelement}{\gtt@currentelement}%
1009 \endgroup%
1010 }%
1011 \@newganttchartelement@definekeys{#1}%
1012 }
1013
1014 \newcommand\@newganttchartelement@two[1]{%
1015 \expandafter\newcommand\csname gantt#1\endcsname[4][]{%
1016 \gtt@chartelement[##1]{##2}{##3}{##4}{#1}%
1017 }%
1018 \expandafter\newcommand\csname ganttlinked#1\endcsname[4][]{%
1019 \begingroup%
1020 \ganttset{##1}%
1021 \gtt@chartelement{##2}{##3}{##4}{#1}%
1022 \ganttlink{\gtt@lastelement}{\gtt@currentelement}%
1023 \endgroup%
1024 }%
1025 \@newganttchartelement@definekeys{#1}%
1026 }
1027
1028 \newcommand\@newganttchartelement@definekeys[2]{%
1029 \@gtt@stylekeydef{#1}{shape=rectangle, inner sep=0pt, draw, fill=white}%
1030 \@gtt@stylekeydef{#1 incomplete}{/pgfgantt/#1, fill=black!25}%
1031 \@gtt@keydef{#1 label font}{\normalsize}%
1032 \@gtt@stylekeydef{#1 label node}{%
1033 anchor=east, font=\ganttvalueof{#1 label font}%
1034 }%
1035 \@gtt@keydef{#1 inline label anchor}{center}%
1036 \@gtt@stylekeydef{#1 inline label node}{%
1037 anchor=center, font=\ganttvalueof{#1 label font}%
1038 }%
1039 \@gtt@keydef{#1 progress label anchor}{east}%
1040 \@gtt@keydef{#1 progress label font}{\scriptsize}%
1041 \@gtt@stylekeydef{#1 progress label node}{%
1042 anchor=west, font=\ganttvalueof{#1 progress label font}%
1043 }%
1044 \@gtt@keydef{#1 left shift}{0}%
1045 \@gtt@keydef{#1 right shift}{0}%
1046 \@gtt@keydef{#1 top shift}{.3}%
1047 \@gtt@keydef{#1 height}{.4}%
1048 \ganttset{%
1049 #1 label text/.code={%
1050 \expandafter\def\csname gtt@#1labeltext\endcsname####1{##1}%
1051 },%
1052 #1 label text=\strut##1,%
1053 #2%
1054 }%
1055 }
1056
1057 \newganttchartelement{bar}{%
1058 bar/.style={shape=ganttbar, inner sep=0pt, draw, fill=white},%
1059 bar incomplete/.style={/pgfgantt/bar, fill=black!25},%
1060 bar label text=\strut#1,%
1061 bar label font=\normalsize,%
1062 bar label node/.style={%
1063 anchor=east, font=\ganttvalueof{bar label font}%
1064 },%
1065 bar inline label anchor=center,%
1066 bar inline label node/.style={%
1067 anchor=center, font=\ganttvalueof{bar label font}%
1068 },%
1069 bar progress label anchor=east,%
1070 bar progress label font=\scriptsize,%
1071 bar progress label node/.style={%
1072 anchor=west, font=\ganttvalueof{bar progress label font}%
1073 },%
1074 bar left shift=0,%
1075 bar right shift=0,%
1076 bar top shift=.3,%
1077 bar height=.4%
1078 }
1079
1080 \newganttchartelement{group}{%
1081 group/.style={shape=ganttgroup, inner sep=0pt, fill=black},%
1082 group incomplete/.style={/pgfgantt/group, fill=black!25},%
1083 group label text=\strut#1,%
1084 group label font=\bfseries,%
1085 group label node/.style={%
1086 anchor=east, font=\ganttvalueof{group label font}%
1087 },%
1088 group inline label anchor=center,%
1089 group inline label node/.style={%
1090 anchor=south, font=\ganttvalueof{group label font}%
1091 },%
1092 group progress label anchor=east,%
1093 group progress label font=\scriptsize,%
1094 group progress label node/.style={%
1095 anchor=west, font=\ganttvalueof{group progress label font}%
1096 },%
1097 group left shift=-.1,%
1098 group right shift=.1,%
1099 group top shift=.4,%
1100 group height=.2%
1101 }
1102 \@gtt@keydef{group right peak tip position}{.5}
1103 \@gtt@keydef{group right peak width}{.4}
1104 \@gtt@keydef{group right peak height}{.1}
1105 \@gtt@keydef{group left peak tip position}{.5}
1106 \@gtt@keydef{group left peak width}{.4}
1107 \@gtt@keydef{group left peak height}{.1}
1108 \ganttset{%
1109 group peaks tip position/.code={%
1110 \ganttset{%
1111 group left peak tip position=#1,%
1112 group right peak tip position=#1%
1113 }%
1114 },%
1115 group peaks width/.code={%
1116 \ganttset{%
1117 group left peak width=#1,%
1118 group right peak width=#1%
1119 }%
1120 },%
1121 group peaks height/.code={%
1122 \ganttset{%
1123 group left peak height=#1,%
1124 group right peak height=#1%
1125 }%
1126 }%
1127 }
1128
1129 \newganttchartelement*{milestone}{%
1130 milestone/.style={%
1131 shape=ganttmilestone, inner sep=0pt, draw, fill=black%
1132 },%
1133 milestone incomplete/.style={/pgfgantt/milestone, fill=black!25},%
1134 milestone label text=\strut#1,%
1135 milestone label font=\itshape,%
1136 milestone label node/.style={%
1137 anchor=east, font=\ganttvalueof{milestone label font}%
1138 },%
1139 milestone inline label anchor=center,%
1140 milestone inline label node/.style={%
1141 anchor=south, font=\ganttvalueof{milestone label font}%
1142 },%
1143 milestone progress label anchor=center,%
1144 milestone progress label font=\scriptsize,%
1145 milestone progress label node/.style={%
1146 anchor=west, font=\ganttvalueof{milestone progress label font}%
1147 },%
1148 milestone left shift=.6,%
1149 milestone right shift=.4,%
1150 milestone top shift=.3,%
1151 milestone height=.4%
1152 }
1153
1154 \@gtt@keydef{on top fraction}{.5}
1155 \@gtt@keydef{on bottom fraction}{.5}
1156 \@gtt@keydef{on left fraction}{.5}
1157 \@gtt@keydef{on right fraction}{.5}
1158
1159 \pgfdeclareshape{ganttbar}{
1160 \inheritsavedanchors[from=rectangle]
1161 \inheritanchor[from=rectangle]{center}
1162 \inheritanchor[from=rectangle]{mid}
1163 \inheritanchor[from=rectangle]{base}
1164 \inheritanchor[from=rectangle]{north}
1165 \inheritanchor[from=rectangle]{south}
1166 \inheritanchor[from=rectangle]{west}
1167 \inheritanchor[from=rectangle]{mid west}
1168 \inheritanchor[from=rectangle]{base west}
1169 \inheritanchor[from=rectangle]{north west}
1170 \inheritanchor[from=rectangle]{south west}
1171 \inheritanchor[from=rectangle]{east}
1172 \inheritanchor[from=rectangle]{mid east}
1173 \inheritanchor[from=rectangle]{base east}
1174 \inheritanchor[from=rectangle]{north east}
1175 \inheritanchor[from=rectangle]{south east}
1176 \inheritanchorborder[from=rectangle]
1177 \anchor{on top}{
1178 \southwest
1179 \pgf@xa=\pgf@x
1180 \northeast
1181 \pgf@xb=\pgf@x
1182 \advance\pgf@xb by-\pgf@xa
1183 \pgf@xb=\ganttvalueof{on top fraction}\pgf@xb
1184 \advance\pgf@xa by\pgf@xb
1185 \pgf@x=\pgf@xa
1186 }
1187 \anchor{on bottom}{
1188 \northeast
1189 \pgf@xb=\pgf@x
1190 \southwest
1191 \pgf@xa=\pgf@x
1192 \advance\pgf@xb by-\pgf@xa
1193 \pgf@xb=\ganttvalueof{on bottom fraction}\pgf@xb
1194 \advance\pgf@xa by\pgf@xb
1195 \pgf@x=\pgf@xa
1196 }
1197 \anchor{on left}{
1198 \northeast
1199 \pgf@ya=\pgf@y
1200 \southwest
1201 \pgf@yb=\pgf@y
1202 \advance\pgf@yb by-\pgf@ya
1203 \pgf@yb=\ganttvalueof{on left fraction}\pgf@yb
1204 \advance\pgf@ya by\pgf@yb
1205 \pgf@y=\pgf@ya
1206 }
1207 \anchor{on right}{
1208 \southwest
1209 \pgf@yb=\pgf@y
1210 \northeast
1211 \pgf@ya=\pgf@y
1212 \advance\pgf@yb by-\pgf@ya
1213 \pgf@yb=\ganttvalueof{on right fraction}\pgf@yb
1214 \advance\pgf@ya by\pgf@yb
1215 \pgf@y=\pgf@ya
1216 }
1217 \inheritbackgroundpath[from=rectangle]
1218 }
1219
1220 \pgfdeclareshape{ganttgroup}{
1221 \inheritsavedanchors[from=rectangle]
1222 \inheritanchor[from=rectangle]{center}
1223 \inheritanchor[from=rectangle]{mid}
1224 \inheritanchor[from=rectangle]{base}
1225 \inheritanchor[from=rectangle]{north}
1226 \inheritanchor[from=rectangle]{south}
1227 \inheritanchor[from=rectangle]{west}
1228 \inheritanchor[from=rectangle]{mid west}
1229 \inheritanchor[from=rectangle]{base west}
1230 \inheritanchor[from=rectangle]{north west}
1231 \inheritanchor[from=rectangle]{south west}
1232 \inheritanchor[from=rectangle]{east}
1233 \inheritanchor[from=rectangle]{mid east}
1234 \inheritanchor[from=rectangle]{base east}
1235 \inheritanchor[from=rectangle]{north east}
1236 \inheritanchor[from=rectangle]{south east}
1237 \inheritanchorborder[from=rectangle]
1238 \inheritanchor[from=ganttbar]{on top}
1239 \inheritanchor[from=ganttbar]{on bottom}
1240 \inheritanchor[from=ganttbar]{on left}
1241 \inheritanchor[from=ganttbar]{on right}
1242 \anchor{left peak}{
1243 \pgf@process{
1244 \pgfpointadd{
1245 \southwest
1246 }{
1247 \pgfpoint%
1248 {\pgfkeysvalueof{/pgf/outer xsep}}%
1249 {\pgfkeysvalueof{/pgf/outer ysep}}
1250 }
1251 }
1252 \pgfmathsetlength\pgf@x{
1253 \pgf@x + \ganttvalueof{group left peak tip position}
1254 * \ganttvalueof{group left peak width} * \ganttvalueof{x unit}
1255 }
1256 \pgfmathsetlength\pgf@y{
1257 \pgf@y - \ganttvalueof{group left peak height}
1258 * \ganttvalueof{y unit chart}
1259 }
1260 }
1261 \anchor{right peak}{
1262 \pgf@process{
1263 \pgfpointadd{
1264 \northeast
1265 }{
1266 \pgfpointscale{-1}{
1267 \pgfpoint%
1268 {\pgfkeysvalueof{/pgf/outer xsep}}%
1269 {\pgfkeysvalueof{/pgf/outer ysep}}
1270 }
1271 }
1272 }
1273 \pgf@xa=\pgf@x
1274 \pgf@process{
1275 \pgfpointadd{
1276 \southwest
1277 }{
1278 \pgfpoint%
1279 {\pgfkeysvalueof{/pgf/outer xsep}}%
1280 {\pgfkeysvalueof{/pgf/outer ysep}}
1281 }
1282 }
1283 \pgfmathsetlength\pgf@x{
1284 \pgf@xa - \ganttvalueof{group right peak tip position}
1285 * \ganttvalueof{group right peak width} * \ganttvalueof{x unit}
1286 }
1287 \pgfmathsetlength\pgf@y{
1288 \pgf@y - \ganttvalueof{group right peak height}
1289 * \ganttvalueof{y unit chart}
1290 }
1291 }
1292 \backgroundpath{
1293 \pgf@process{
1294 \pgfpointadd{
1295 \northeast
1296 }{
1297 \pgfpointscale{-1}{
1298 \pgfpoint%
1299 {\pgfkeysvalueof{/pgf/outer xsep}}%
1300 {\pgfkeysvalueof{/pgf/outer ysep}}
1301 }
1302 }
1303 }
1304 \pgf@xb=\pgf@x
1305 \pgf@ya=\pgf@y
1306 \pgf@process{
1307 \pgfpointadd{
1308 \southwest
1309 }{
1310 \pgfpoint%
1311 {\pgfkeysvalueof{/pgf/outer xsep}}%
1312 {\pgfkeysvalueof{/pgf/outer ysep}}
1313 }
1314 }
1315 \pgf@xa=\pgf@x
1316 \pgf@yb=\pgf@y
1317 \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
1318 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
1319 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
1320 \pgfmathsetlength\pgf@xc{
1321 \pgf@xb - \ganttvalueof{group right peak tip position}
1322 * \ganttvalueof{group right peak width} * \ganttvalueof{x unit}
1323 }
1324 \pgfmathsetlength\pgf@yc{
1325 \pgf@yb - \ganttvalueof{group right peak height}
1326 * \ganttvalueof{y unit chart}
1327 }
1328 \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
1329 \pgfmathsetlength\pgf@xc{
1330 \pgf@xb - \ganttvalueof{group right peak width}
1331 * \ganttvalueof{x unit}
1332 }
1333 \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
1334 \pgfmathsetlength\pgf@xc{
1335 \pgf@xa + \ganttvalueof{group left peak width}
1336 * \ganttvalueof{x unit}
1337 }
1338 \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
1339 \pgfmathsetlength\pgf@xc{
1340 \pgf@xa + \ganttvalueof{group left peak tip position}
1341 * \ganttvalueof{group left peak width} * \ganttvalueof{x unit}
1342 }
1343 \pgfmathsetlength\pgf@yc{
1344 \pgf@yb - \ganttvalueof{group left peak height}
1345 * \ganttvalueof{y unit chart}
1346 }
1347 \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
1348 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
1349 \pgfpathclose
1350 }
1351 }
1352
1353 \pgfdeclareshape{ganttmilestone}{
1354 \inheritsavedanchors[from=diamond]
1355 \inheritanchor[from=diamond]{text}
1356 \inheritanchor[from=diamond]{center}
1357 \inheritanchor[from=diamond]{mid}
1358 \inheritanchor[from=diamond]{base}
1359 \inheritanchor[from=diamond]{north}
1360 \inheritanchor[from=diamond]{south}
1361 \inheritanchor[from=diamond]{west}
1362 \inheritanchor[from=diamond]{north west}
1363 \inheritanchor[from=diamond]{south west}
1364 \inheritanchor[from=diamond]{east}
1365 \inheritanchor[from=diamond]{north east}
1366 \inheritanchor[from=diamond]{south east}
1367 \inheritanchorborder[from=diamond]
1368 \inheritbackgroundpath[from=diamond]
1369 \anchor{on top}{
1370 \pgf@process{\outernortheast}
1371 \pgf@xa=2\pgf@x
1372 \pgf@x=-\pgf@x
1373 \advance\pgf@x by\ganttvalueof{on top fraction}\pgf@xa
1374 \pgf@ya=2\pgf@y
1375 \pgf@y=0pt
1376 \pgfmathparse{
1377 \ganttvalueof{on top fraction} < 0.5
1378 ? \ganttvalueof{on top fraction}
1379 : 1 - \ganttvalueof{on top fraction}
1380 }
1381 \advance\pgf@y by\pgfmathresult\pgf@ya
1382 }
1383 \anchor{on bottom}{
1384 \pgf@process{\outernortheast}
1385 \pgf@xa=2\pgf@x
1386 \pgf@x=-\pgf@x
1387 \advance\pgf@x by\ganttvalueof{on bottom fraction}\pgf@xa
1388 \pgf@ya=-2\pgf@y
1389 \pgf@y=0pt
1390 \pgfmathparse{
1391 \ganttvalueof{on bottom fraction} < 0.5
1392 ? \ganttvalueof{on bottom fraction}
1393 : 1 - \ganttvalueof{on bottom fraction}
1394 }
1395 \advance\pgf@y by\pgfmathresult\pgf@ya
1396 }
1397 \anchor{on right}{
1398 \pgf@process{\outernortheast}
1399 \pgf@ya=-2\pgf@y
1400 \advance\pgf@y by\ganttvalueof{on right fraction}\pgf@ya
1401 \pgf@xa=2\pgf@x
1402 \pgf@x=0pt
1403 \pgfmathparse{
1404 \ganttvalueof{on right fraction} < 0.5
1405 ? \ganttvalueof{on right fraction}
1406 : 1 - \ganttvalueof{on right fraction}
1407 }
1408 \advance\pgf@x by\pgfmathresult\pgf@xa
1409 }
1410 \anchor{on left}{
1411 \pgf@process{\outernortheast}
1412 \pgf@ya=-2\pgf@y
1413 \advance\pgf@y by\ganttvalueof{on left fraction}\pgf@ya
1414 \pgf@xa=-2\pgf@x
1415 \pgf@x=0pt
1416 \pgfmathparse{
1417 \ganttvalueof{on left fraction} < 0.5
1418 ? \ganttvalueof{on left fraction}
1419 : 1 - \ganttvalueof{on left fraction}
1420 }
1421 \advance\pgf@x by\pgfmathresult\pgf@xa
1422 }
1423 }
1424
1425 \@gtt@stylekeydef{link}{-latex, rounded corners=1pt}
1426 \@gtt@keydef{link type}{auto}
1427 \@gtt@keydef{link label}{}
1428 \@gtt@keydef{link label font}{\scriptsize\itshape}
1429 \@gtt@stylekeydef{link label node}{%
1430 anchor=west, font=\ganttvalueof{link label font}%
1431 }
1432 \newcommand\newganttlinktype[2]{%
1433 \expandafter\def\csname @gtt@linktype@#1\endcsname{#2}%
1434 }
1435
1436 \newcommand\setganttlinklabel[2]{%
1437 \expandafter\def\csname @gtt@linktype@#1@label\endcsname{#2}%
1438 }
1439
1440 \newcommand\newganttlinktypealias[2]{%
1441 \expandafter\def\csname @gtt@linktype@#1\endcsname{%
1442 \csname @gtt@linktype@#2\endcsname%
1443 }%
1444 \expandafter\def\csname @gtt@linktype@#1@label\endcsname{%
1445 \csname @gtt@linktype@#2@label\endcsname%
1446 }%
1447 }
1448
1449 \@gtt@keydef{link mid}{.5}
1450 \@gtt@keydef{link bulge}{.4}
1451 \@gtt@keydef{link tolerance}{.6}
1452 \newganttlinktype{r}{%
1453 \draw [/pgfgantt/link]
1454 (\xLeft, \yUpper) --
1455 (\xRight, \yLower)
1456 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel};
1457 }
1458 \newganttlinktypealias{default}{r}
1459
1460 \newganttlinktype{rdr}{%
1461 \draw [/pgfgantt/link]
1462 (\xLeft, \yUpper) --
1463 ($(\xLeft, \yUpper)!\ganttvalueof{link mid}!
1464 (\xRight, \yUpper)$) --
1465 ($(\xLeft, \yLower)!\ganttvalueof{link mid}!
1466 (\xRight, \yLower)$) --
1467 (\xRight, \yLower);%
1468 }
1469
1470 \newganttlinktype{rdldr}{%
1471 \draw [/pgfgantt/link]
1472 (\xLeft, \yUpper) --
1473 (\xLeft + \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1474 \yUpper) --
1475 ($(\xLeft + \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1476 \yUpper)!%
1477 \ganttvalueof{link mid}!%
1478 (\xLeft + \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1479 \yLower)$) --
1480 ($(\xRight - \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1481 \yUpper)!%
1482 \ganttvalueof{link mid}!%
1483 (\xRight - \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1484 \yLower)$) --
1485 (\xRight - \ganttvalueof{link bulge} * \ganttvalueof{x unit},
1486 \yLower) --
1487 (\xRight, \yLower);%
1488 }
1489
1490 \newganttlinktype{auto}{%
1491 \pgfmathparse{abs(\yUpper - \yLower) <= 1}%
1492 \ifcase\pgfmathresult%
1493 \pgfmathparse{
1494 (\xRight - \xLeft)
1495 >= \ganttvalueof{link tolerance} * \ganttvalueof{x unit}
1496 }%
1497 \ifcase\pgfmathresult%
1498 \gtt@drawlink{rdldr}%
1499 \else%
1500 \gtt@drawlink{rdr}%
1501 \fi%
1502 \else%
1503 \gtt@drawlink{r}%
1504 \fi%
1505 }
1506 \newganttlinktype{dr}{%
1507 \ganttsetstartanchor{south}%
1508 \ganttsetendanchor{west}%
1509 \draw [/pgfgantt/link]
1510 (\xLeft, \yUpper) --
1511 (\xLeft, \yLower)
1512 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel} --
1513 (\xRight, \yLower);%
1514 }
1515
1516 \newganttlinktype{s-s}{%
1517 \ganttsetstartanchor{south west}%
1518 \ganttsetendanchor{north west}%
1519 \draw [/pgfgantt/link]
1520 (\xLeft, \yUpper) --
1521 (\xRight, \yLower)
1522 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel};
1523 }
1524 \setganttlinklabel{s-s}{start-to-start}
1525
1526 \newganttlinktype{s-f}{%
1527 \ganttsetstartanchor{on bottom=0}%
1528 \ganttsetendanchor{on top=1}%
1529 \draw [/pgfgantt/link]
1530 (\xLeft, \yUpper) --
1531 (\xRight, \yLower)
1532 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel};
1533 }
1534 \setganttlinklabel{s-f}{start-to-finish}
1535
1536 \newganttlinktype{f-s}{%
1537 \ganttsetstartanchor{south east}%
1538 \ganttsetendanchor{north west}%
1539 \draw [/pgfgantt/link]
1540 (\xLeft, \yUpper) --
1541 (\xRight, \yLower)
1542 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel};
1543 }
1544 \setganttlinklabel{f-s}{finish-to-start}
1545
1546 \newganttlinktype{f-f}{%
1547 \ganttsetstartanchor{south east}%
1548 \ganttsetendanchor{north east}%
1549 \draw [/pgfgantt/link]
1550 (\xLeft, \yUpper) --
1551 (\xRight, \yLower)
1552 node [pos=.5, /pgfgantt/link label node] {\ganttlinklabel};
1553 }
1554 \setganttlinklabel{f-f}{finish-to-finish}
1555
1556 \newcommand\gtt@drawlink[1]{%
1557 \@ifundefined{@gtt@linktype@#1}{%
1558 \@gtt@PackageWarning{Link type `#1' unknown, using `default'.}%
1559 \def\@gtt@currlinktype{default}%
1560 }{%
1561 \def\@gtt@currlinktype{#1}%
1562 }%
1563 \edef\@gtt@currlabel{\ganttvalueof{link label}}%
1564 \ifx\@gtt@currlabel\@empty%
1565 \def\ganttlinklabel{%
1566 \csname @gtt@linktype@\@gtt@currlinktype @label\endcsname%
1567 }%
1568 \else%
1569 \edef\ganttlinklabel{%
1570 \ganttvalueof{link label}%
1571 }%
1572 \fi%
1573 \csname @gtt@linktype@\@gtt@currlinktype\endcsname%
1574 }
1575
1576 \ganttset{%
1577 link anchor/.unknown/.code={%
1578 \edef\@gtt@link@anchor{\pgfkeyscurrentname}%
1579 },%
1580 }
1581 \def\@gtt@linkanchordef#1{%
1582 \ganttset{%
1583 link anchor/#1/.code={%
1584 \edef\@gtt@link@anchor{#1}%
1585 \ganttset{#1 fraction=##1}%
1586 },%
1587 link anchor/#1/.default=.5%
1588 }%
1589 }
1590 \@gtt@linkanchordef{on top}
1591 \@gtt@linkanchordef{on bottom}
1592 \@gtt@linkanchordef{on left}
1593 \@gtt@linkanchordef{on right}
1594
1595 \newcommand\@gtt@setstartanchor[1]{%
1596 \pgfqkeys{/pgfgantt/link anchor}{#1}%
1597 \pgfpointanchor{\@gtt@link@startelement}{\@gtt@link@anchor}%
1598 \edef\xLeft{\the\pgf@x}%
1599 \edef\yUpper{\the\pgf@y}%
1600 }
1601
1602 \newcommand\@gtt@setendanchor[1]{%
1603 \pgfqkeys{/pgfgantt/link anchor}{#1}%
1604 \pgfpointanchor{\@gtt@link@endelement}{\@gtt@link@anchor}%
1605 \edef\xRight{\the\pgf@x}%
1606 \edef\yLower{\the\pgf@y}%
1607 }
1608
1609 \newcommand\ganttlink[3][]{%
1610 \begingroup%
1611 \ganttset{#1}%
1612 \def\@gtt@link@startelement{#2}%
1613 \def\@gtt@link@endelement{#3}%
1614 \let\ganttsetstartanchor\@gtt@setstartanchor%
1615 \let\ganttsetendanchor\@gtt@setendanchor%
1616 \ganttsetstartanchor{east}%
1617 \ganttsetendanchor{west}%
1618 \gtt@drawlink{\ganttvalueof{link type}}%
1619 \endgroup%
1620 }
1621
1622 \endinput
1623 %%
1624 %% End of file `pgfgantt.sty'.