[Tex/LaTex] pattern for pgfgantt ganttchartelements

patternpgfgantt

I like to add a shading pattern for black and white printing to the foobar elements of this example code from the pgfgantt manual.

\documentclass[a2paper, 10pt, parskip=full, listof=toc,  bibliography=numbered, draft=false]{scrartcl}
\usepackage{pgfgantt}
\usetikzlibrary{shapes,arrows,patterns}
\begin{document}
\definecolor{foobarblue}{RGB}{0,153,255}
\definecolor{foobaryellow}{RGB}{234,187,0}
\newganttchartelement{foobar}{
        foobar/.style={
                shape=rounded rectangle,
                inner sep=0pt,
                draw=foobarblue!50!black,
                very thick,
                top color=white,
                bottom color=foobarblue!50
        },
        foobar incomplete/.style={
                /pgfgantt/foobar,
                draw=foobaryellow,
                bottom color=foobaryellow!50
        },
        foobar label font=\slshape,
        foobar left shift=-.1,
        foobar right shift=.1
}
\begin{ganttchart}[
        vgrid,
        progress=today,
        progress label text=\relax,
        today=6
]{1}{12}
\gantttitlecalendar{day} \\[grid]
\ganttfoobar{Foobar 1}{1}{2} \\
\ganttfoobar{Foobar 2}{3}{7} \\
\ganttlinkedfoobar{Foobar 3}{9}{12}
\end{ganttchart}
\end{document}

In this question
pattern in pgfgantt's ganttbars? it is explained how to do it to a single entry, but since I have lots of entries, I would prefer to add it to the newganttchartelement definition, but I haven't found a way to do so. Is this possible at all? And if so, could you please provide an example?

Best Answer

The method is not really much different from the question you refer to actually, i.e. add e.g. pattern=north east lines to the foobar style. The only problem is that the filling covers over the pattern, but if you set fill opacity=0.5 the pattern becomes visible through the fill.

enter image description here

\documentclass[a2paper, 10pt, parskip=full, listof=toc,  bibliography=numbered, draft=false]{scrartcl}
\usepackage{pgfgantt}
\usetikzlibrary{shapes,arrows,patterns}
\begin{document}
\definecolor{foobarblue}{RGB}{0,153,255}
\definecolor{foobaryellow}{RGB}{234,187,0}
\newganttchartelement{foobar}{
        foobar/.style={
                shape=rounded rectangle,
                inner sep=0pt,
                draw=foobarblue!50!black,
                very thick,
                top color=white,
                bottom color=foobarblue,
                fill opacity=0.5,
                pattern=north west lines
        },
        foobar incomplete/.style={
                /pgfgantt/foobar,
                draw=foobaryellow,
                bottom color=foobaryellow,
                pattern=north east lines
        },
        foobar label font=\slshape,
        foobar left shift=-.1,
        foobar right shift=.1
}
\begin{ganttchart}[
        vgrid,
        progress=today,
        progress label text=\relax,
        today=6
]{1}{12}
\gantttitlecalendar{day} \\[grid]
\ganttfoobar{Foobar 1}{1}{2} \\
\ganttfoobar{Foobar 2}{3}{7} \\
\ganttlinkedfoobar{Foobar 3}{9}{12}
\end{ganttchart}
\end{document}
Related Question