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.
Code (Update)
\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{pgfgantt}
\makeatletter
\ganttset{
prog default/.initial=100,
prog/.code={
\pgfutil@in@{:}{#1}
\ifpgfutil@in@
\pgfqkeysalso{/pgfgantt}{@prog={#1}}
\else
\pgfqkeysalso{/pgfgantt}{@prog={\pgfkeysvalueof{/pgfgantt/prog default}:#1}}
\fi
},
@prog/.code args={#1:#2}{
\pgfqkeysalso{/pgfgantt}{progress=100, progress label text={#2 (#1\,\%)}}
}
}
\makeatother
\ganttset{progress label anchor/.append style={text=red}}
\begin{document}
\begin{ganttchart}[y unit title=0.4cm,
y unit chart=0.5cm,
vgrid={draw=none, dotted},
hgrid,
title label anchor/.style={below=-1.6ex},
title left shift=.05,
title right shift=-.05,
title height=1,
bar/.style={fill=gray!50},
incomplete/.style={fill=white},
progress label text={},
bar height=0.7,
group right shift=0,
group top shift=.6,
group height=.3,
group peaks={}{}{.2},
]{12}
\gantttitle{2012}{12} \\
\gantttitle{October}{4}
\gantttitle{November}{4}
\gantttitle{December}{4} \\
\ganttgroup{Group 1}{1}{8}\\
\ganttbar[prog=50: Resource 1]{Task 1}{1}{2} \\
\ganttbar[prog= Resource 2]{Task 2}{3}{4} \\
\ganttbar[prog= Resource 3]{Task 3}{5}{6}\\
\ganttbar[prog=50: Resource 1, progress label anchor/.append style={below=4pt}]{Task 4}{1}{8} \\
\end{ganttchart}
\end{document}
Output
Code
\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{pgfgantt}
\makeatletter
\ganttset{
prog default/.initial=100,
prog/.code={
\pgfutil@in@{:}{#1}
\ifpgfutil@in@
\pgfqkeysalso{/pgfgantt}{@prog={#1}}
\else
\pgfqkeysalso{/pgfgantt}{@prog={\pgfkeysvalueof{/pgfgantt/prog default}:#1}}
\fi
},
@prog/.code args={#1:#2}{
\edef\pgf@tempa{#1}%
\ifx\pgf@tempa\tikz@nonetext
\pgfqkeysalso{/pgfgantt}{progress={100},progress label text={#2}}
\else
\pgfqkeysalso{/pgfgantt}{progress={#1},progress label text={#2 (##1\,\%)}}
\fi
}
}
\makeatother
\ganttset{progress label anchor/.append style={text=red}}
\begin{document}
\begin{ganttchart}[y unit title=0.4cm,
y unit chart=0.5cm,
vgrid={draw=none, dotted},
hgrid,
title label anchor/.style={below=-1.6ex},
title left shift=.05,
title right shift=-.05,
title height=1,
bar/.style={fill=gray!50},
incomplete/.style={fill=white},
progress label text={},
bar height=0.7,
group right shift=0,
group top shift=.6,
group height=.3,
group peaks={}{}{.2},
]{12}
\gantttitle{2012}{12} \\
\gantttitle{October}{4}
\gantttitle{November}{4}
\gantttitle{December}{4} \\
\ganttgroup{Group 1}{1}{8}\\
\ganttbar[prog=50: Resource 1]{Task 1}{1}{2} \\
\ganttbar[prog= Resource 2]{Task 2}{3}{4} \\
\ganttbar[prog=none:Resource 3]{Task 3}{5}{6}\\
\ganttbar[prog=50: Resource 1, progress label anchor/.append style={below=4pt}]{Task 4}{1}{8} \\
\end{ganttchart}
\end{document}
Output
Best Answer
This answer sets up two new Gantt chart elements using the
\newganttchartelement*
macro. It takes a single optional argument and two mandatory arguments<label>
and the time slot,<tss>
. It operates the same way as does the\milestone
macro. Thenewgantchartelement
named lresource can be used to set a node on the left of the task to define the corresponding resource.tss
can be given by a value >=1 less than the tss for the corresponding task. For left placed resources, the resource must be specified before the task. The same logic applies to rresource newganttchartelement, except that it sets the resource on the right of the corresponding task. In this case, the resource must be specified after the task.Regarding the OP's question about setting
[inline=false]
globally forganttbar
, this may not be possible. The manual says in section 2.2:My interpretation of this statement is that having set
inline=true
for the lresource and rresource, that setting operates globally until it is specifically reset in eachganttbar
by writingganttbar[inline=false]
.This is the result, with the
ganttbar[inline=false]
:Here is the MWE, with some additional comments in the code: