I am referring to the answer of Alain Matthes to a question asked some time ago.
What I have is a gantt chart which shows the steps in a project. I am pretty much finished with it and I really like the chart design but I have one big issue: I need to add a legend to this chart.
What I found in the question mentioned above is the \node command.
So I tried this for hours now but I can't seem to get the solution Alain Matthes suggested working. Please read his answer before continuing. I want to have about 5 boxes inside the chart in the upper right. But all I get is 5 boxes that are slightly above and right from the previous box. What I tried was something like this:
\documentclass[12pt]{article}
\usepackage{pgfgantt}
\begin{document}
\begin{center}
\begin{figure}[H]
\noindent\resizebox{480pt}{!}{
\begin{tikzpicture}
\begin{ganttchart}
[
vgrid,
vgrid style/.style=dotted,
hgrid,
hgrid style/.style=dotted,
y unit title=0.5cm,
y unit chart=0.8cm,
title/.append style={shape=rectangle, fill=black!20},
title height=1,
bar/.append style={fill=blue!80},
bar height=.5,
bar label font=\normalsize\color{black!80},
group top shift=.6,
group height=.3,
group peaks height=.2,
]
{1}{35}
\gantttitle{Some Title}{35}\\\\
\gantttitlelist{1,...,35}{1}\\\\
\gantttitle{Plan}{7}\gantttitle{Execute}{11}\gantttitle{Stabilize}{4}\gantttitle{Finish}{13}\\
\ganttgroup{Plan}{1}{6}\\
\ganttbar[name=kickoff1]{Kick-Off Meeting}{1}{1}\\
%This looks like the result I want but in the wrong place:
\node[fill=blue,draw] at ([yshift=-20pt]current bounding box.south){Person A};
\node[fill=yellow,draw] at ([yshift=-20pt]current bounding box.south){Person B};
\node[fill=green,draw] at ([yshift=-20pt]current bounding box.south){Person C};
\node[fill=red,draw] at ([yshift=-20pt]current bounding box.south){Person D};
\node[fill=purple,draw] at ([yshift=-20pt]current bounding box.south){Person E};
%This is where I want it to be but arranged as above:
\node[fill=blue,draw] at ([yshift=-20pt]current bounding box.north east){Person A};
\node[fill=yellow,draw] at ([yshift=-20pt]current bounding box.north east){Person B};
\node[fill=green,draw] at ([yshift=-20pt]current bounding box.north east){Person C};
\node[fill=red,draw] at ([yshift=-20pt]current bounding box.north east){Person D};
\node[fill=purple,draw] at ([yshift=-20pt]current bounding box.north east){Person E};
\end{ganttchart}
\end{tikzpicture}
}
\end{figure}
\end{center}
\end{document}
I assume this is a really silly mistake but even after reading the official documentation of pgfgantt, I cant happen to understand how to place this boxes properly. Any help is highly appreciated as I am about to bite chunks out of my desk..
Thanks in advance!
The following code is based on answer from cfr and solves the problem described above perfectly:
\documentclass[12pt]{article}
\usepackage{pgfgantt}
\begin{document}
\begin{center}
\begin{figure}[H]
\noindent\resizebox{480pt}{!}{
\begin{tikzpicture}
\begin{ganttchart}
[
vgrid,
vgrid style/.style=dotted,
hgrid,
hgrid style/.style=dotted,
y unit title=0.5cm,
y unit chart=0.8cm,
title/.append style={shape=rectangle, fill=black!20},
title height=1,
bar/.append style={fill=blue!80},
bar height=.5,
bar label font=\normalsize\color{black!80},
group top shift=.6,
group height=.3,
group peaks height=.2,
]
{1}{35}
\gantttitle{Some Title}{35}\\\\
\gantttitlelist{1,...,35}{1}\\\\
\gantttitle{Plan}{7}\gantttitle{Execute}{11}\gantttitle{Stabilize}{4}\gantttitle{Finish}{13}\\
\ganttgroup{Plan}{1}{6}\\
\ganttbar{Kick-Off Meeting}{1}{1}\\
\ganttset{bar/.append style={fill=yellow!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=green!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=red!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=purple!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=blue!80}}
\ganttlinkedbar{Current state}{2}{2}\\
\ganttlinkedbar{Define goals}{3}{4}\\
\ganttlinkedbar{Choose solution}{5}{6}\\
%This is the solution that works:
\node (a) [fill=blue,draw,anchor=east] at ([xshift=-40pt]current bounding box.8){Person A};
\node (b) [fill=yellow,draw,anchor=west] at ([yshift=-20pt]a.south west){Person B};
\node (c) [fill=green,draw,anchor=west] at ([yshift=-20pt]b.south west){Person C};
\node (d) [fill=red,draw,anchor=west] at ([yshift=-20pt]c.south west){Person D};
\node[fill=purple,draw,anchor=west] at ([yshift=-20pt]d.south west){Person E};
\end{ganttchart}
\end{tikzpicture}
}
\end{figure}
\end{center}
\end{document}
