5

I have two questions with pgfgantt package:

  1. How to adjust automatically the size of the third row? (For example when it's written "Vacances de Paques and for "February")
  2. How to add the date (for example a label) next to the milestone ?

Here is what I've done for now :

\documentclass[border=10pt]{standalone}%{article}
%\usepackage[margin=1cm]{geometry}
\usepackage{pgfgantt}
\usepackage{graphicx}
\usepackage{xcolor}
%\usetikzlibrary{positioning}

\ganttset{group/.append style={orange},
milestone/.append style={red},
progress label node anchor/.append style={text=red}}

\begin{document}

%    \begin{figure}
%    \centering
    \begin{tikzpicture}
        \begin{ganttchart}[%Specs
            y unit title=0.5cm,
            y unit chart=0.7cm,
            vgrid,
            %hgrid,
            title height=1,
            %     title/.style={fill=none},
            title label font=\bfseries\footnotesize,
            bar/.style={fill=blue},
            bar height=0.7,
            %   progress label text={},
            group right shift=0,
            group top shift=0.7,
            group height=.3,
            canvas/.append style={name=mycanvas},
            group peaks width={0.2},
            inline]{1}{13}
            %labels
            \gantttitle{Project spring 6}{13}\\  % title 1
            \gantttitle[]{February}{2}                 % title 2
            \gantttitle[]{March}{4}                 % title 2
            \gantttitle[]{April}{5}                 % title 2
            \gantttitle[]{May}{2}                 % title 2

            \\
            \gantttitle{P1}{1}                      % title 3
            \gantttitle{P2}{1}
            \gantttitle{P3}{1}
            \gantttitle{P4}{1}
            \gantttitle{P5}{1}
            \gantttitle{P6}{1}
            \gantttitle{P7}{1} 
            \gantttitle{P8}{1}
            \gantttitle{P9}{1}
            \gantttitle{Vacances de Pâques}{1}
            \gantttitle{P10}{1}
            \gantttitle{P11}{1}
            \gantttitle{P12}{1}\\

            %Cahier de charge
            \ganttgroup[inline=false]{Requierements specification}{1}{2}\\
            \ganttbar[progress=0,inline=false]{Writing requierements specification}{1}{2}\\
            \ganttbar[progress=0,inline=false]{Writing planning}{1}{2}\\
            \ganttmilestone[inline=false]{Rendu documents}{2} \\ 

            % Analyse
            \ganttgroup[inline=false]{Analyse}{2}{4}\\ 
            \ganttbar[progress=10,inline=false]{Analyse}{2}{4}\\
            \ganttmilestone[inline=false]{Rendu analyse}{4} \\
            %Specification
            \ganttgroup[inline=false]{Specification}{4}{5}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{4}{5}\\
            \ganttmilestone[inline=false]{Rendu specification}{5} \\

            \ganttgroup[inline=false]{Réalisation}{5}{10}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{5}{10}\\
            \ganttmilestone[inline=false]{Rendu réalisation}{10} \\

            \ganttgroup[inline=false]{Validation}{10}{12}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{10}{12}\\
            \ganttmilestone[inline=false]{Rendu specification}{12} \\

            \ganttgroup[inline=false]{Documentation}{1}{12}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{1}{12}\\
            \ganttmilestone[inline=false]{Rendu rapport}{12} \\
            %\ganttbar[progress=50,inline=false, bar progress label node/.append style={below left= 10pt and 7pt}]{Task B}{13}{24} \\ \\
        \end{ganttchart}
        \node [left] at ([yshift=-1.3cm]mycanvas.north west) {Weeks};
    \end{tikzpicture}
\end{document}

And here is the output : Output

1 Answer 1

6
+50

A real hack job, but it might be a start. Someone more versed in tikz than I could do better with milestone/.append style

\documentclass[border=10pt]{standalone}%{article}
%\usepackage[margin=1cm]{geometry}
\usepackage{pgfgantt}
\usepackage{graphicx,stackengine}
\usepackage{xcolor}
%\usetikzlibrary{positioning}

\ganttset{group/.append style={orange},
milestone/.append style={red},
progress label node anchor/.append style={text=red}}

\begin{document}

%    \begin{figure}
%    \centering
    \begin{tikzpicture}
        \begin{ganttchart}[%Specs
            milestone/.append style={label=
               \smash{\raisebox{-10.5pt}{%
               \kern30pt\scriptsize\milestonelabel}}%
               \gdef\milestonelabel{}},
            y unit title=0.5cm,
            y unit chart=0.7cm,
            vgrid,
            %hgrid,
            title height=1,
            %     title/.style={fill=none},
            title label font=\bfseries\footnotesize,
            bar/.style={fill=blue},
            bar height=0.7,
            %   progress label text={},
            group right shift=0,
            group top shift=0.7,
            group height=.3,
            canvas/.append style={name=mycanvas},
            group peaks width={0.2},
            inline]{1}{13}
            %labels
            \gantttitle{Project spring 6}{13}\\  % title 1
            \gantttitle[]{\scalebox{.6}{February}}{2}                 % title 2
            \gantttitle[]{March}{4}                 % title 2
            \gantttitle[]{April}{5}                 % title 2
            \gantttitle[]{May}{2}                 % title 2

            \\
            \gantttitle{P1}{1}                      % title 3
            \gantttitle{P2}{1}
            \gantttitle{P3}{1}
            \gantttitle{P4}{1}
            \gantttitle{P5}{1}
            \gantttitle{P6}{1}
            \gantttitle{P7}{1} 
            \gantttitle{P8}{1}
            \gantttitle{P9}{1}
            \gantttitle{\smash{\stackunder[8pt]{$\downarrow$}{%
                            Vacances de Pâques}}}{1}
            \gantttitle{P10}{1}
            \gantttitle{P11}{1}
            \gantttitle{P12}{1}\\

            %Cahier de charge
            \ganttgroup[inline=false]{Requierements specification}{1}{2}\\
            \ganttbar[progress=0,inline=false]{Writing requierements specification}{1}{2}\\
            \ganttbar[progress=0,inline=false]{Writing planning}{1}{2}\\
            \def\milestonelabel{28.2}
            \ganttmilestone[inline=false]{Rendu documents}{2} \\ 

            % Analyse
            \ganttgroup[inline=false]{Analyse}{2}{4}\\ 
            \ganttbar[progress=10,inline=false]{Analyse}{2}{4}\\
            \def\milestonelabel{15.3}
            \ganttmilestone[inline=false]{Rendu analyse}{4} \\
            %Specification
            \ganttgroup[inline=false]{Specification}{4}{5}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{4}{5}\\
            \def\milestonelabel{22.3}
            \ganttmilestone[inline=false]{Rendu specification}{5} \\

            \ganttgroup[inline=false]{Réalisation}{5}{10}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{5}{10}\\
            \def\milestonelabel{21.4}
            \ganttmilestone[inline=false]{Rendu réalisation}{10} \\

            \ganttgroup[inline=false]{Validation}{10}{12}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{10}{12}\\
            \def\milestonelabel{15.5}
            \ganttmilestone[inline=false]{Rendu specification}{12} \\

            \ganttgroup[inline=false]{Documentation}{1}{12}\\ 
            \ganttbar[progress=0,inline=false]{Specification}{1}{12}\\
            \ganttmilestone[inline=false]{Rendu rapport}{12} \\
            %\ganttbar[progress=50,inline=false, bar progress label node/.append style={below left= 10pt and 7pt}]{Task B}{13}{24} \\ \\
        \end{ganttchart}
        \node [left] at ([yshift=-1.3cm]mycanvas.north west) {Weeks};
    \end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you very much for your excellent work and for to have helped the user.
    – Sebastiano
    Feb 23, 2019 at 20:27
  • Steven Well done on rescaling February however most chart users would expect and be very happy to see short but large Feb. especially as shown where it needs to balance the half May month Also brilliant lateral use of placing Easter Holidays as part of real week P10 (which it is) so am surprised that numbers after were not adjusted by the OP however I am glad to see they give workers the week off even though the work is going to have to be completed earlier than scheduled ah! just like a normal planners view, no allowance at all for slack time & no realistic time for post validation clean-up
    – user170109
    Feb 24, 2019 at 1:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .