1

I'm trying to apply animations such as the one here Tikz animated figure in Beamer to a gantt chart that uses pgfgantt: I'm trying to make the ganttbars appear after clicking, incrementally. If I manually change the fill opacity and opacity keys to 0 in the ganttbar keys, I see they appear and disappear so I know it could work. But I'm unsure about how to edit my code to add the invisible and visible styles to my bars and tie that to the <2-> events like in the tikz example:

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}

My working example where I can manually change the opacity of the bars:


\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\definecolor{color1}{HTML}{878787}
\definecolor{color3}{HTML}{ff0000}
  \begin{figure}
          \centering
          \begin{tikzpicture}
            \begin{ganttchart}[
                expand chart=\textwidth,
                hgrid,
                vgrid
            ]{1}{15}
                \gantttitlelist{1,...,15}{1} \\
                \ganttbar[bar/.append style={fill=color1}, inline, bar label font=\tiny\bfseries]{}{2}{3}
                \ganttbar[bar/.append style={fill=color3, pattern=north west lines, pattern color=color3, fill opacity=1, opacity=1}, inline, bar label font=\tiny\bfseries]{ }{5}{8}
                \node (a) [anchor=north] at (current bounding box.south east){};
                \node (m) [fill=color1,draw, label=left:{Check}, minimum width=1.5cm, minimum height=0.5cm, anchor=north] at ([yshift=-12pt]a.south east){};
                \node[fill=color3,draw, label=left:{Mission assignment}, minimum width=1.5cm, minimum height=0.5cm, pattern=north west lines, pattern color=color3] at ([yshift=-12pt]m.south){};
            \end{ganttchart}

          \end{tikzpicture}
  \end{figure}
\end{document}

1 Answer 1

2

Apparently, one easy way is just to add the \onslide for each bar and when run with beamer "it just works". I should have tried it before...

\documentclass[leqno,mathserif]{beamer}  
\usepackage{graphics,bm}
\usetheme{Luebeck} 
\usepackage{pgfgantt}
\definecolor{color1}{HTML}{878787}
\definecolor{color3}{HTML}{ff0000}
\begin{document}
\begin{frame}
  \begin{figure}
          \centering
          \begin{tikzpicture}
            \begin{ganttchart}[
                expand chart=\textwidth,
                hgrid,
                vgrid
            ]{1}{15}
                \gantttitlelist{1,...,15}{1} \\
                \onslide<2->{
                  \ganttbar[bar/.append style={fill=color1}, inline, bar label font=\tiny\bfseries]{}{2}{3}
                }
                \onslide<3->{
                  \ganttbar[bar/.append style={fill=color3, pattern=north west lines, pattern color=color3, fill opacity=1, opacity=1}, inline, bar label font=\tiny\bfseries]{ }{5}{8}
                }
                \node (a) [anchor=north] at (current bounding box.south east){};
                \node (m) [fill=color1,draw, label=left:{Check}, minimum width=1.5cm, minimum height=0.5cm, anchor=north] at ([yshift=-12pt]a.south east){};
                \node[fill=color3,draw, label=left:{Mission assignment}, minimum width=1.5cm, minimum height=0.5cm, pattern=north west lines, pattern color=color3] at ([yshift=-12pt]m.south){};
            \end{ganttchart}
          \end{tikzpicture}
  \end{figure}
\end{frame}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .