After several (fruitless) attempts using \parbox
es and modifying the maximum length allowed for the text, I think that given the length of the text for the objectives and tasks, it would be appropriate to use a different approach.
One option would be to use tooltips so the Gantt chart only displays a little amount of text (the labels) and the information for a given objective or task will only be visible when hovering over that element.
The facytooltips
package helps to achieve this task.
You need to create a PDF file containing the text for the tooltips (one tooltip per page). This PDF document can be produced using LaTeX; in this example I used a file (called tasktips.tex
) having the following aspect:
\documentclass{article}
\usepackage{url}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[createtips]{fancytooltips}
\newcommand\MyTip[2]{%
\keytip{#1}%
\begin{mdframed}[
innerlinewidth=1mm,linecolor=olive!50,
backgroundcolor=yellow!20,roundcorner=5pt,rightmargin=.25\textwidth]
#2
\end{mdframed}%
\newpage%
}
\begin{document}
\MyTip{obje1}{Continuous news coverage of 911 events presented by Worldnet (Voice of America). Please Note: This news program was recorded by the non-profit Television Archive. The video is available as a "loan" only: This means it may be streamed but not downloaded. Network URL: \url{http://www.ibb.gov}}
\MyTip{task1a}{ International Union, United Automobile Workers of America
This is from the UAW-AFL faction that split with Homer Martin from the majority UAW-CIO HD6350.A8}
\end{document}
The \MyTip
command generates the tooltip text and its <key>
; this <key>
is to be used in the main document (the one containing the Gantt chart). The syntax for \MyTip
is;
\MyTip{<key>}{<text>}
In the example, each tooltip text will be placed inside a framed colored box produced with the help of the mdframed
package, but of course you can change the style according to your needs. Processing tasktips.tex
(using pdflatex
) you get a file tasktips.pdf
containing the tooltips.
Now in your main file, all you have to do is to use the name of the PDF created in the previous step as the value for the package option filename
, when loading fancytooltips:
\usepackage[filename=tasktips,mouseover,noextratext]{fancytooltips}
and then in the body of your document you use the \tooltip
command:
\tooltip{<text>}{<key>}
to associate <text>
with the tooltip corresponding to <key>
. Here's the file with the Gantt chart and the \tooltip
commands:
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{pgf}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\usepackage{rotating}
\usepackage[filename=tasktips,mouseover,noextratext]{fancytooltips}
\begin{document}
\pagebreak
\begin{rotate}{270}
\begin{ganttchart}[y unit title=0.6cm,
y unit chart=0.7cm,
vgrid,
title height=.85,
hgrid=true,
canvas/.style={fill=yellow!25, draw=blue, solid, very thick},
bar/.style={fill=gray, rounded corners=3pt},
bar left shift=.05,
bar right shift=-.05,
bar top shift=.3,
bar height=.3,vgrid={*1{blue, dashed}},
bar label font=\normalsize\color{black!50},
bar label anchor/.append style={align=left, text width=1.5cm},
group right shift=0,group top shift=.6,group height=.3,group peaks={}{}{0}]{23}
\gantttitle{2012}{5}
\gantttitle{2013}{12}
\gantttitle{2014}{6}\\
\gantttitlelist{8,...,12}{1}
\gantttitlelist{1,...,12}{1}
\gantttitlelist{1,...,6}{1}\\
\ganttgroup{\tooltip{Objective 1}{obje1}}{1}{4} \\
\ganttbar{\tooltip{\textbf{Task a}}{task1a}}{4}{2} \\
\ganttbar{\textbf{Task b}}{4}{2} \\
\ganttbar{\textbf{Task c}}{4}{2} \\
\ganttgroup{Objective 2:}{4}{6} \\
\ganttbar{Task a}{4}{6} \\
\ganttbar{Task b}{4}{6} \\
\ganttgroup{Objective 3}{4}{6} \\
\ganttbar{Task a}{4}{2} \\
\ganttbar{Task b}{4}{2} \\
\ganttbar{Task c}{4}{2} \\
\ganttbar{Task d}{4}{2} \\
\ganttgroup{Objective 4}{4}{6} \\
\ganttbar{Task a}{4}{2} \\
\ganttbar{Task b}{4}{2} \\
\ganttgroup{Objective 5}{4}{6} \\
\ganttbar{Task a}{4}{2} \\
\ganttbar{Task b}{4}{2} \\
\ganttbar{Task c}{4}{2} \\
\end{ganttchart}
\end{rotate}
\end{document}
Some images:
and the tooltips once you hover over the text:
The downside is that you need to use AcrobatReader to properly display the tooltips.
This seems to work fine (Suggestions are welcome):
\documentclass[tikz]{standalone}
\usepackage{pgfgantt}
\title{Gantt Charts with the pgfgantt Package}
\begin{document}
%
%
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{150,150,150}
\renewcommand\sfdefault{phv}
\renewcommand\mddefault{mc}
\renewcommand\bfdefault{bc}
\sffamily
\ganttset
{%
calendar week text={%
\pgfcalendarmonthshortname{\startmonth}~\startday,\startyear%
}%
}
\begin{ganttchart}[
canvas/.append style={fill=none, draw=black!5, line width=.75pt},
hgrid style/.style={draw=black!6, line width=.75pt},
vgrid={*1{draw=black!6, line width=.75pt}},
today=2014-07-23,
today rule/.style={
draw=black!34,
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, linkred},
link label font=\scriptsize\bfseries,
%link label node/.append style={below left=-2pt and 0pt}
time slot format=isodate
]{2014-06-17}{2014-07-31}
% top nodes
\ganttbar[name=holiday-2014-06-22-top,bar/.style={fill=none, draw=none}]{}{2014-06-22}{2014-06-22}
\ganttbar[name=holiday-2014-06-29-top,bar/.style={fill=none, draw=none}]{}{2014-06-29}{2014-06-29}
\ganttbar[name=holiday-2014-07-6-top,bar/.style={fill=none, draw=none}]{}{2014-07-6}{2014-07-6}
\ganttbar[name=holiday-2014-07-12-top,bar/.style={fill=none, draw=none}]{}{2014-07-12}{2014-07-12}
\ganttbar[name=holiday-2014-07-13-top,bar/.style={fill=none, draw=none}]{}{2014-07-13}{2014-07-13}
\ganttbar[name=holiday-2014-07-20-top,bar/.style={fill=none, draw=none}]{}{2014-07-20}{2014-07-20}
\ganttbar[name=holiday-2014-07-27-top,bar/.style={fill=none, draw=none}]{}{2014-07-27}{2014-07-27}
\gantttitlecalendar{week, day} \\
\ganttgroup[progress=100]{Analysis}{2014-06-17}{2014-07-22} \\
\ganttbar[
progress=100,
name=WBS1A
]{\textbf{Risk Analysis}}{2014-06-17}{2014-06-25} \\
\ganttbar[
progress=100,
name=WBS1B
]{\textbf{System Requirement Specification}}{2014-06-26}{2014-06-27} \\
\ganttbar[
progress=100,
name=WBS1C
]{\textbf{Functional Specification}}{2014-06-28}{2014-07-16} \\
\ganttbar[
progress=100,
name=WBS1D
]{\textbf{Project Plan}}{2014-07-17}{2014-07-21} \\
\ganttbar[
progress=100,
name=WBS1E
]{\textbf{Project Schedule}}{2014-07-22}{2014-07-22} \\
\ganttmilestone[name=M1]{Analysis Completion}{2014-07-21} \ganttnewline [grid]
\ganttgroup[progress=100]{Design}{2014-07-23}{2014-07-23} \\
\ganttbar[progress=100,name=WBS2A]{\textbf{High Level Design}}{2014-07-23}{2014-07-23} \\
\ganttmilestone[name=M2]{Design Completion}{2014-07-22} \ganttnewline [grid]
\ganttgroup[progress=0]{Coding}{2014-07-24}{2014-07-31} \\
%\ganttbar[prog=50: Resource 1]{Task 1}{2014-07-24}{2} \\
\ganttbar[progress=0,name=WBS3A]{\textbf{Building Prototype}}{2014-07-24}{2014-07-31} \\
\ganttmilestone[name=M3]{Code Completion}{2014-07-30} \ganttnewline [grid]
\ganttlink[]{WBS1A}{WBS1B}
\ganttlink[]{WBS1B}{WBS1C}
\ganttlink[]{WBS1C}{WBS1D}
\ganttlink[]{WBS1D}{WBS1E}
\ganttlink[]{WBS1E}{M1}
\ganttlink[]{M1}{WBS2A}
\ganttlink[]{WBS2A}{M2}
\ganttlink[]{M2}{WBS3A}
\ganttlink[]{WBS3A}{M3}
% bottom nodes
\ganttbar[name=holiday-2014-06-22-bottom,bar/.style={fill=none, draw=none}]{}{2014-06-22}{2014-06-22}
\ganttbar[name=holiday-2014-06-29-bottom,bar/.style={fill=none, draw=none}]{}{2014-06-29}{2014-06-29}
\ganttbar[name=holiday-2014-07-6-bottom,bar/.style={fill=none, draw=none}]{}{2014-07-6}{2014-07-6}
\ganttbar[name=holiday-2014-07-12-bottom,bar/.style={fill=none, draw=none}]{}{2014-07-12}{2014-07-12}
\ganttbar[name=holiday-2014-07-13-bottom,bar/.style={fill=none, draw=none}]{}{2014-07-13}{2014-07-13}
\ganttbar[name=holiday-2014-07-20-bottom,bar/.style={fill=none, draw=none}]{}{2014-07-20}{2014-07-20}
\ganttbar[name=holiday-2014-07-27-bottom,bar/.style={fill=none, draw=none}]{}{2014-07-27}{2014-07-27}
% shading
\begin{scope}
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-06-22-top) -- (holiday-2014-06-22-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-06-29-top) -- (holiday-2014-06-29-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-07-6-top) -- (holiday-2014-07-6-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-07-12-top) -- (holiday-2014-07-12-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-07-13-top) -- (holiday-2014-07-13-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-07-20-top) -- (holiday-2014-07-20-bottom);
\draw [opacity=0.05,line width=12,color=brown] (holiday-2014-07-27-top) -- (holiday-2014-07-27-bottom);
\end{scope}
\end{ganttchart}
\end{document}
Best Answer
You can use the
east
anchor (ans possibly anxshift
) for themilestone
style: