1

pgfgantt manual says one has to use vgrid={draw=none} to remove vertical lines of a grid. But, how can one restrict the removal to only a particular element? In particular, suppose a group and a bar like below.

\documentclass[border=3pt]{standalone}
\usepackage{pgfgantt}
\usepackage{tikz}

\begin{document}
\begin{ganttchart}[ x unit= 5mm, y unit title=0.7cm, y unit chart=0.9cm, vgrid={*1{dashed}}, title height=1, bar/.style={fill=blue}, bar height=1, bar top shift=0, ]{1}{2}

    \gantttitle{Time}{2}\\             
    \gantttitlelist{1,...,2}{1} \\

    \ganttgroup[/pgfgantt/group/.style={font=\bfseries}]{Level 1: ...}{1}{2}
    \ganttnewline[black]
    \ganttbar{Requirement 1: ...}{1}{1}
\end{ganttchart}

\end{document}

What is the way to remove those parts of the vgrid residing at the scope of the group?

  • I am not sure that I understand you correctly, but do you want to have no vertical lines in the first row (labelled "Level "), but only in the second (labelled "Requirement 1")? How about the following columns? – Jasper Habicht Jul 25 '22 at 05:43
  • @JasperHabicht: Yes, that's exactly what I want. I basically need to remove all vertical lines of the first row, whatever columns it encompasses. –  Jul 25 '22 at 06:01
  • 1
    Then you can probably add the option shorten <=0.9cm to the vgrid style: *1{dashed, shorten <=0.9cm}, since you set y unit chart=0.9cm. – Jasper Habicht Jul 25 '22 at 06:08
  • What if the desired line is in the middle of the chart? –  Jul 25 '22 at 06:15
  • Then, obviously you cannot use this approach ... – Jasper Habicht Jul 25 '22 at 06:47

1 Answers1

0

In case that you only need to remove the vgrid from the first row, you could probably say vgrid=*1{dashed, shorten <=0.9cm}. However, if the row without the vgrid lines should be in the middle of the plot, this approach would not work.

I took inspiration from this answer that adds color to the backgroud of a row by adding a hgrid. So, you could use this approach and draw thick white lines over the vgrid everywhere you need it. You need to tell the hgrid option where exactly you want to have this line drawn:

\documentclass[border=3pt]{standalone}
\usepackage{pgfgantt}
\usepackage{tikz}

\tikzset{ grouprow/.style={ line width=\ganttvalueof{y unit chart}, yshift=-0.5*\ganttvalueof{y unit chart}, shorten >=.2pt, shorten <=.2pt, white }, normalrow/.style={ opacity=0, }, }

\begin{document}
\begin{ganttchart}[ x unit= 5mm, y unit title=0.7cm, y unit chart=0.9cm, hgrid={1{grouprow}, 2{normalrow}, 1{grouprow}, 1{normalrow}}, vgrid={*1{dashed}}, title height=1, bar/.style={fill=blue}, bar height=1, bar top shift=0, ]{1}{2}

    \gantttitle{Time}{2}\\             
    \gantttitlelist{1,...,2}{1} \\

    \ganttgroup[/pgfgantt/group/.style={font=\bfseries}]{Level 1: ...}{1}{2}
    \ganttnewline[black]
    \ganttbar{Requirement 1: ...}{1}{1}
    \ganttnewline[black]
    \ganttbar{Requirement 2: ...}{1}{1}

    \ganttnewline[black]
    \ganttgroup[/pgfgantt/group/.style={font=\bfseries}]{Level 2: ...}{1}{2}
    \ganttnewline[black]
    \ganttbar{Requirement 3: ...}{2}{2}
\end{ganttchart}

\end{document}

enter image description here