# Task names on the right side of pgfgantt chart, possible?

I would like to do Gantt chart in Latex thus I'm studying http://ftp.math.purdue.edu/mirrors/ctan.org/graphics/pgf/contrib/pgfgantt/pgfgantt.pdf, where I see

Is it possible to have the task names on the right side? Like this:

And to have names aligned to the left side will be nice.

Here is the code to generate the first chart:

\documentclass{article}

\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}{1}{12}

\gantttitle{2011}{12} \\
\gantttitlelist{1,...,12}{1} \\

\ganttgroup{Group 1}{1}{7} \\
\ganttmilestone{Milestone}{7} \ganttnewline

\end{ganttchart}

\end{document}


If I do \begin{ganttchart}[group label node/.append style={anchor=west}]{1}{12} then I get (but I want that text all the way on the right side):

• MWE from the linked pgfgantt doc is there, anything else I can provide? – KcFnMi Jan 24 at 9:00
• This should be enough. I won't be able to help you, but now that the MWE is provided, you should see an answer quite soon. – sztruks Jan 24 at 9:02
• Already helped! – KcFnMi Jan 24 at 9:05
• I tried something, see there, not exacly what I want. – KcFnMi Jan 24 at 9:21

You are on the right track with setting the anchor to west. Additionally, the horizontal (x axis) position of the node needs to be shifted from 0 to [width of the chart]. For this you need to change the code of pgfgantt.sty, which you can do on the fly with the xpatch package.

Borrowing code from the \ganttnewline command (around line 400) the width of the chart is defined as \gtt@chartwidth * \ganttvalueof{x unit}. The label nodes are drawn (around line 960) using the coordinates (0, \y@mid pt). When this line is patched, the position of the labels change.

Note that pgfgantt defines different styles for bar labels, group labels and milestone labels, so all three need to be defined explicitly (I could not find a single setting for all line labels).

MWE:

\documentclass{article}

\usepackage{pgfgantt}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\gtt@chartelement}{\node at (0, \y@mid pt)}{\node at (\gtt@chartwidth * \ganttvalueof{x unit}, \y@mid pt)}{}{}
\makeatother

\begin{document}

\begin{ganttchart}[bar label node/.append style={anchor=west},group label node/.append style={anchor=west},milestone label node/.append style={anchor=west}]{1}{12}

\gantttitle{2011}{12} \\
\gantttitlelist{1,...,12}{1} \\

\ganttgroup{Group 1}{1}{7} \\
\ganttmilestone{Milestone}{7} \ganttnewline

• Would be nice to have an option on pgfgantt to do this in one shot. – KcFnMi Jan 24 at 10:41
• @KcFnMi you could try to send a feature request to the package maintainer Wolfgang Skala, his e-mail address is listed in the pgfgantt manual. – Marijn Jan 24 at 12:43