6

In the code below I would just like to manually decide to fill the second bar in the chart with a color or hash it! I want to be able to decide which bars to make these changes on a case by case basis. I know there are some solutions like Can I have a pgfgantt chart with different colors per bar? but this is not what I want. I simply want to use a single command like "fillbar" on the chart element in question.

\documentclass{article}
\usepackage{pgfgantt}

\begin{document}
\begin{ganttchart}[
    hgrid,
    vgrid,
    time slot format=isodate-yearmonth,
    compress calendar
]{2015-12}{2016-05}
  \gantttitlecalendar{year, month} \\ 

  \ganttbar{}{2016-02}{2016-03} \\                  
  \ganttbar{Task3}{2016-01}{2016-05} \\ %Fill with RED!                          

  \ganttlink{elem0}{elem1}
\end{ganttchart}

\end{document}
8

The documentation of pgfgantt includes a chapter "Style Examples", starting at page 45.

The syntax for ganttbars is: \ganttbar[ options ]{ label }{ start tss }{ end tss }. You can make different settings for most of the available elements. Also, you can adjust the colour of the bars quite easily:

\ganttbar[bar/.append style={fill=anycolor}]{}{2016-02}{2016-03}

Then your code should look like this:

\begin{ganttchart}[
      hgrid,
      vgrid,
      time slot format=isodate-yearmonth,
      compress calendar
      ]{2015-12}{2016-05}
   \gantttitlecalendar{year, month} \\ 
   \ganttbar[bar/.append style={fill=blue}]{}{2016-02}{2016-03}\\                  
   \ganttbar[bar/.append style={fill=red}]{Task3}{2016-01}{2016-05} \\ 
   \ganttbar[bar/.append style={fill=cyan}]{Task6}{2016-01}{2016-04} \\ 
   \ganttlink{elem0}{elem1}
\end{ganttchart}

Which looks like the following:

Adjusted bar colours

  • 2
    If you use the progress bar, then it may happen, that you have to adapt bar incomplete (It happened just to me and I wondered why the solution did not work in my case). – knut May 3 '17 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.