# gantt chart issues

I have two problems:

• The title of the gantt chart contains dotted lines that I don't want.
• Is it possible to also provide the progression of the taskbars? If so, how would that be done? ( please see second figure below for more clarification, the picture is taken from the pgfgantt package)

gantt package used can be found here

All help is highly appreciated.

Greetings

    \documentclass[border=12pt]{standalone}
\usepackage{gantt}

\newcommand{\defcolor}{blue}

\begin{document}

\begin{gantt}[drawledgerline=true]{18}{24}
% vertical, horizontal 'boxes'
\begin{ganttitle}  % First title: Year
\numtitle{2019}{1}{2019}{24}
% start, label, width
\end{ganttitle}

\begin{ganttitle} % Second title: Months
\titleelement{Feb}{4}
\titleelement{Mar}{4}
\titleelement{Apr}{4}
\titleelement{May}{4}
\titleelement{Jun}{4}
\titleelement{Jul}{4}
\end{ganttitle}

\begin{ganttitle} % Third title: Weeks
\numtitle{6}{1}{29}{1}
% start, skip, end, width
\end{ganttitle}

%---------------------------------------
\ganttmilestone{Task A}{0} % Milestone: Label, position
%---------------------------------------

%---------------------------------------
%---------------------------------------
%
%
%---------------------------------------

%---------------------------------------
%---------------------------------------
%
%
%
%
%---------------------------------------
\end{gantt}

\end{document}


• Welcome to TeX - LaTeX! It is best to ask just one specific question in a given posting; your posting asks two. The second one about progression is not so clear. I suggest you edit your posting removing that part, and think about how to formulate a second positing for a specific version of that problem. – Andrew Swann Jan 14 at 10:00
• Thank you Andrew! I have added a new picture to clarify the second question. I know that the progressbar is possible within pgfgantt. But I'd like to stick to my format/design and include the progress if possible. I tried within pgfgantt, but I couldn't get the same out, unfortunately. – Nadia Merquez Jan 14 at 10:06
• Just so that I understand the second question better, for any task you want to partially fill the bar with a completion percentage and also add a label? – Alan Munn Jan 14 at 18:09
• Thanks for the reply! Yes, you got it totally right. I'd like to show the progress in terms precentages and filling for each particular task if possible. – Nadia Merquez Jan 14 at 19:57
• Just to let everyone know, I started a new question to keep in line with the required set-up of questioning. – Nadia Merquez Jan 15 at 9:26

## Getting rid of the spurious dotted lines

Here's an answer to the first question. This is IMO the result of a bug in the package. In the command that draws the vertical lines, the y coordinate is incorrectly specified. This can be patched using the xpatch package:

\documentclass[border=12pt]{standalone}
\usepackage{gantt}
\usepackage{xpatch}
\xpatchcmd{\gantt}{-0.5}{-1.5}{}{}

\newcommand{\defcolor}{blue}

\begin{document}

\begin{gantt}[drawledgerline=true]{18}{24}
% vertical, horizontal 'boxes'
\begin{ganttitle}  % First title: Year
\numtitle{2019}{1}{2019}{24}
% start, label, width
\end{ganttitle}

\begin{ganttitle} % Second title: Months
\titleelement{Feb}{4}
\titleelement{Mar}{4}
\titleelement{Apr}{4}
\titleelement{May}{4}
\titleelement{Jun}{4}
\titleelement{Jul}{4}
\end{ganttitle}

\begin{ganttitle} % Third title: Weeks
\numtitle{6}{1}{29}{1}
% start, skip, end, width
\end{ganttitle}

%---------------------------------------
\ganttmilestone{Task A}{0} % Milestone: Label, position
%---------------------------------------

%---------------------------------------
%---------------------------------------
%
%
%---------------------------------------

%---------------------------------------
%---------------------------------------
%
%
%
%
%---------------------------------------
\end{gantt}

\end{document}


Here's an answer to the second question. I've added a percent key to the \ganttbar commands which give the percentage completion (values range from 0-1). The default is 1. I've also added a key for the position of the completion label. This defaults to right but can be specified also as left. Finally there's a key plabeltext which defines the string printed out after the completion amount. It is preset to % Complete but can be changed using \presetkeys{ganttbarx}{plabeltext=<text>}{}.

Here's a complete example:

\documentclass[border=12pt]{standalone}
\usepackage{gantt}
\usepackage{xpatch}
\xpatchcmd{\gantt}{-0.5}{-1.5}{}{}
\makeatletter
\newlength{\gantttmpc}
\newlength{\ganttbarpercentage}
\define@key{ganttbarx}{percent}{\def\ganttbarpercent{#1}\pgfmathparse{int(round(\ganttbarpercent*100))}\let\ganttbarpercentage\pgfmathresult}
\define@key{ganttbarx}{percentpos}{\def\@tmp{left}\def\ganttbarpercentpos{#1}\ifx\ganttbarpercentpos\@tmp\def\ganttbarpercentanchor{\gantttmpa}\else\def\ganttbarpercentanchor{\gantttmpb}\fi}
\define@key{ganttbarx}{plabeltext}{\def\ganttbarplabeltext{#1}}
\presetkeys{ganttbarx}{pattern=north west lines,color=black,percent=1,plabeltext={\% Complete},percentpos=right}{}

\renewcommand{\ganttbar}[4][]{
\setlength{\gantttmpa}{#3\ganttunitlength}
\setlength{\gantttmpb}{#4\ganttunitlength}
\setlength{\gantttmpc}{#4\ganttunitlength}
\setlength{\gantttmpb}{\gantttmpa+\gantttmpb}

\ifKV@ganttx@drawledgerline
\draw[dotted] (0,\value{ganttnum}-0.2) -- (\value{ganttwidth}*\ganttunitlength,\value{ganttnum}-0.2);
\fi
\node at (0,\value{ganttnum}) [anchor=base east] {%
\ganttfontsize #2%
};
\setkeys{ganttbarx}{#1}{%
\setlength{\gantttmpc}{\gantttmpa+\ganttbarpercent\gantttmpc}
\draw[] (\gantttmpa,\value{ganttnum}+0.1) rectangle (\gantttmpb,\value{ganttnum}+0.5);
\node at (\ganttbarpercentanchor,\value{ganttnum}+0.25) [\ganttbarpercentpos=.5\ganttunitlength] {\ganttbarpercentage\ganttbarplabeltext};
\fill[pattern=\ganttbarpattern,pattern color=\ganttbarcolor] (\gantttmpa,\value{ganttnum}+0.1) rectangle (\gantttmpc,\value{ganttnum}+0.5);
}
\setlength{\ganttlastx}{\gantttmpb}
}
\makeatother
\newcommand{\defcolor}{blue}

\begin{document}

\begin{gantt}[drawledgerline=true]{18}{24}
% vertical, horizontal 'boxes'
\begin{ganttitle}  % First title: Year
\numtitle{2019}{1}{2019}{24}
% start, label, width
\end{ganttitle}

\begin{ganttitle} % Second title: Months
\titleelement{Feb}{4}
\titleelement{Mar}{4}
\titleelement{Apr}{4}
\titleelement{May}{4}
\titleelement{Jun}{4}
\titleelement{Jul}{4}
\end{ganttitle}

\begin{ganttitle} % Third title: Weeks
\numtitle{6}{1}{29}{1}
% start, skip, end, width
\end{ganttitle}

%---------------------------------------
\ganttmilestone{Task A}{0} % Milestone: Label, position
%---------------------------------------

%---------------------------------------
%---------------------------------------
%
%
%---------------------------------------

%---------------------------------------
%---------------------------------------
%