forked from cfiandra/timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtikzlibrarytimeline.code.tex
88 lines (78 loc) · 2.54 KB
/
tikzlibrarytimeline.code.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
\usetikzlibrary{backgrounds,calc}
\usepackage{xstring}
\pgfkeys{/tikz/.cd,
timespan/.store in=\timespan,
timespan=Week,
timeline width/.store in=\timelinewidth,
timeline width=20,
timeline height/.store in=\timelineheight,
timeline height=1,
timeline offset/.store in=\timelineoffset,
timeline offset=0.15,
initial week/.store in=\initialweek,
initial week=1,
end week/.store in=\endweek,
end week=2,
time point/.store in=\timepoint,
time point=0.5,
between week/.style args={#1 and #2 in #3}{
initial week=#1,
end week=#2,
time point=#3,
},
involvement degree/.store in=\involvdegree,
involvement degree=2cm,
phase color/.store in=\phasecol,
phase color=red!50!orange,
phase appearance/.style={
circle,
opacity=0.3,
minimum size=\involvdegree,
fill=\phasecol
},
}
\pgfkeys{/tikz/milestone/.cd,
at/.store in=\msstartpoint,
at=phase-1.north,
circle radius/.store in=\milestonecircleradius,
circle radius=0.1cm,
direction/.store in=\msdirection,
direction=90:2cm,
text/.store in=\mstext,
text={},
text options/.code={\tikzset{#1}},
}
\newcommand{\reftimespan}{\MakeLowerCase{\timespan}}
\newcommand{\timeline}[1]{
\draw[fill,opacity=0.8] (0,0) rectangle (\timelinewidth,\timelineheight);
\shade[top color=black, bottom color=white,middle color=black!20]
(0,0) rectangle (\timelinewidth,-\timelineoffset);
\shade[top color=white, bottom color=black,middle color=black!20]
(0,\timelineheight) rectangle (\timelinewidth,\timelineheight+\timelineoffset);
\foreach \smitem [count=\xi] in {1,...,#1} {\global\let\maxsmitem\xi}
\pgfmathsetmacro\position{\timelinewidth/(\maxsmitem+1)}
\node at (0,0.5\timelineheight)(\timespan-0){\phantom{Week 0}};
\foreach \x[count=\xi] in {1,...,#1}{
\node[text=white]at +(\xi*\position,0.5\timelineheight) (\timespan-\xi) {\timespan\ \x};
}
}
\newcounter{involv}
\setcounter{involv}{0}
\newcommand{\phase}[1]{
\stepcounter{involv}
\node[phase appearance,#1]
(phase-\theinvolv)
at ($(\timespan-\initialweek)!\timepoint!(\timespan-\endweek)$){};
}
\newcommand{\initialphase}[1]{
\node[phase appearance,#1,anchor=west,between week=0 and 1 in 0,]
(phase-\theinvolv)
at ($(\timespan-0)!0!(\timespan-1)$){};
\setcounter{involv}{0}
}
\newenvironment{phases}{\begin{pgfonlayer}{background}}{\end{pgfonlayer}}
\newcommand{\addmilestone}[1]{
\pgfkeys{/tikz/milestone/.cd,#1}
\draw[double,fill] (\msstartpoint) circle [radius=\milestonecircleradius];
\draw(\msstartpoint)--++(\msdirection)node[/tikz/milestone/text options]{\mstext};
}