How is it possible to build a Gantt – Chart with 12 months for 2017 and 12 months for 2018. The idea would be to add task from 2017 which can go until 2018.
Maybe 24 months would be ideal, but I am looking forward to help.
Thank you in advance
\documentclass[tikz]{standalone}
\usepackage{pgfgantt}
\title{Gantt Charts with the pgfgantt Package}
\begin{document}
%
% A fairly complicated example from section 2.9 of the package
% documentation. This reproduces an example from Wikipedia:
% http://en.wikipedia.org/wiki/Gantt_chart
%
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{165,0,33}
\renewcommand\sfdefault{phv}
\renewcommand\mddefault{mc}
\renewcommand\bfdefault{bc}
\setganttlinklabel{s-s}{START-TO-START}
\setganttlinklabel{f-s}{FINISH-TO-START}
\setganttlinklabel{f-f}{FINISH-TO-FINISH}
\sffamily
\begin{ganttchart}[
canvas/.append style={fill=none, draw=black!5, line width=.75pt},
hgrid style/.style={draw=black!5, line width=.75pt},
vgrid={*1{draw=black!5, line width=.75pt}},
today=7,
today rule/.style={
draw=black!64,
dash pattern=on 3.5pt off 4.5pt,
line width=1.5pt
},
today label font=\small\bfseries,
title/.style={draw=none, fill=none},
title label font=\bfseries\footnotesize,
title label node/.append style={below=7pt},
include title in canvas=false,
bar label font=\mdseries\small\color{black!70},
bar label node/.append style={left=2cm},
bar/.append style={draw=none, fill=black!63},
bar incomplete/.append style={fill=barblue},
bar progress label font=\mdseries\footnotesize\color{black!70},
group incomplete/.append style={fill=groupblue},
group left shift=0,
group right shift=0,
group height=.5,
group peaks tip position=0,
group label node/.append style={left=.6cm},
group progress label font=\bfseries\small,
link/.style={-latex, line width=1.5pt, linkred},
link label font=\scriptsize\bfseries,
link label node/.append style={below left=-2pt and 0pt}
]{1}{13}
\gantttitle[
title label node/.append style={below left=7pt and -3pt}
]{WEEKS:\quad1}{1}
\gantttitlelist{2,...,20}{1} \\
\ganttgroup[progress=57]{WBS 1 Summary Element 1}{1}{10} \\
\ganttbar[
progress=75,
name=WBS1A
]{\textbf{WBS 1.1} Activity A}{1}{8} \\
\ganttbar[
progress=67,
name=WBS1B
]{\textbf{WBS 1.2} Activity B}{1}{3} \\
\ganttbar[
progress=50,
name=WBS1C
]{\textbf{WBS 1.3} Activity C}{4}{10} \\
\ganttbar[
progress=0,
name=WBS1D
]{\textbf{WBS 1.4} Activity D}{4}{10} \\[grid]
\ganttgroup[progress=0]{WBS 2 Summary Element 2}{4}{10} \\
\ganttbar[progress=0]{\textbf{WBS 2.1} Activity E}{4}{5} \\
\ganttbar[progress=0]{\textbf{WBS 2.2} Activity F}{6}{8} \\
\ganttbar[progress=0]{\textbf{WBS 2.3} Activity G}{9}{10}
\ganttlink[link type=s-s]{WBS1A}{WBS1B}
\ganttlink[link type=f-s]{WBS1B}{WBS1C}
\ganttlink[
link type=f-f,
link label node/.append style=left
]{WBS1C}{WBS1D}
\end{ganttchart}
\end{document}
Best Answer
In the example you gave, they defined a grid range from 1 to 13 for the grid (this is the
{1}{13}
after the\begin{ganttchart}
commands), effectively giving you the 13 vertical bars in the result with light gray borders.Then they added
ganttitlelist{2,...,20}{1}
to the earlier defined title.I think the easier approach would be to just use the
ganttitlecalendar
approach and to define the range (e.g. 2017 to 2018). I would suggest to start out with the following example, where I created a gantt chart from today to next year (today - 28th November, 2018), where each month represents one 'unit':You can play around with those values to get a feel of what the different commands do. I'll explain the ones in my example here:
vgrid
is used to layout the vertical grid. In here, I told it to draw 2 black lines, then a dashed one. It will repeat this pattern for all vertical lines after that.x unit=10mm
is a command where I specified that each unit's (month) horizontal distance (distance between each vertical line, or each 'month's worth' in this example) is 10mm wide.y unit chart=9mm
the vertical distance of the units (months). Put this at 1mm or 2mm and see what happens!y unit title=12mm
will set the height of the title, in this case the years are the title.time slot format=isodate
is really handy when using actual dates -- I use this all the time when automating gantt charts. It allows you to create a gantt chart based on ayyyy-mm-dd
format, instead of 'number of units specified' (like in your example, the{1}{13}
)compress calendar=true
in the default mode, this isfalse
, meaning that each 'unit' in the gantt calendar will be one day. Obviously, when having a gantt chart spanning one or multiple years, this can get quite large (in this case, we'd have 365 times 10mm). Setting this totrue
will make the months the units instead, effectively compressing the calendar.After these options, the range of the gantt calendar is defined. As an example, I took today until next year
{2017-11-29}{2018-11-28}
. Fill in any other (iso-formatted) date of your choice to experiment.Then I tell how I want the calendar to be displayed. In this example, I wanted the years and the months, but only the first three letters. Leave out
=shortname
and see what happens! You can also add week, weekday, or day. Weekdays also have a shortname option (Mon, Tue, ...).I suggest getting the hang of these settings and playing around a bit, as they effectively create your gantt chart foundation. Then it's a matter of filling it up with elements and links, but that deserves a different question should you still have trouble. I'll also link to a different answer I made that builds upon this small example here to add some colour to your chart.
Good luck!