# Is it possible to overlay bubble diagrams clockwise?

While the answer here provided the solution to my first question (whether the bubble diagram could be overlayed at all ?), the next branching question naturally arose :

• Is it possible to animate the bubbles clockwise ?

Example borrowed from marmot :

\documentclass[border=10pt]{beamer}
\usepackage{smartdiagram}
\begin{document}
\begin{frame}[t]
\frametitle{}
\smartdiagramanimated[bubble diagram]{Machine Learning,
Supervised, Unsupervised, Reinforcement}
\end{frame}
\end{document}


I looked through the code. Even though most (animated) diagrams have a clockwise option, the bubble diagram doesn't. However, the code for this one is rather short, so I copied and "hacked" it. You have now optional keys orientation (-1 means clockwise) and start angle that you can adjust to your needs.

\documentclass[border=10pt]{beamer}
\usepackage{smartdiagram}
\tikzset{Partha/.cd,
start angle/.initial=0,
orientation/.initial=1}
\makeatletter
\newcommand{\BubbleDiagramAnimated}[2][]{%
\begin{tikzpicture}[every node/.style={align=center,let hypenation},
Partha/.cd,#1]
\foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
\pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
\foreach \smitem [count=\xi] in {#2}{%
\ifnumequal{\xi}{1}{ %true
\node[bubble center node, smvisible on=<\xi->](center bubble){\smitem};
}{%false
\pgfmathtruncatemacro{\xj}{\xi-1}
\pgfmathtruncatemacro{\angle}{\pgfkeysvalueof{/tikz/Partha/start angle}+%
\pgfkeysvalueof{/tikz/Partha/orientation}*360/\actualnumitem*\xj}
\edef\col{\@nameuse{color@\xj}}
\node[bubble node, smvisible on=<\xi->](module\xi)
at (center bubble.\angle) {\smitem};
}%
}%
\end{tikzpicture}}
\makeatother
\begin{document}
\begin{frame}[t]
\frametitle{}
\BubbleDiagramAnimated[orientation=-1,start angle=-120]{Machine Learning,
Supervised, Unsupervised, Reinforcement}
\end{frame}
\end{document}


Of course, you can make it more reminiscent of the other keys by defining a clockwise code.

\documentclass[border=10pt]{beamer}
\usepackage{smartdiagram}
\tikzset{Partha/.cd,
start angle/.initial=0,
orientation/.initial=1,
clockwise/.code=\tikzset{Partha/orientation=-1,Partha/start angle=-120}}
\makeatletter
\newcommand{\BubbleDiagramAnimated}[2][]{%
\begin{tikzpicture}[every node/.style={align=center,let hypenation},
Partha/.cd,#1]
\foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
\pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
\foreach \smitem [count=\xi] in {#2}{%
\ifnumequal{\xi}{1}{ %true
\node[bubble center node, smvisible on=<\xi->](center bubble){\smitem};
}{%false
\pgfmathtruncatemacro{\xj}{\xi-1}
\pgfmathtruncatemacro{\angle}{\pgfkeysvalueof{/tikz/Partha/start angle}+%
\pgfkeysvalueof{/tikz/Partha/orientation}*360/\actualnumitem*\xj}
\edef\col{\@nameuse{color@\xj}}
\node[bubble node, smvisible on=<\xi->](module\xi)
at (center bubble.\angle) {\smitem};
}%
}%
\end{tikzpicture}}
\makeatother
\begin{document}
\begin{frame}[t]
\frametitle{}
\BubbleDiagramAnimated[clockwise]{Machine Learning,
Supervised, Unsupervised, Reinforcement}
\end{frame}
\end{document}

• The second solution is easy-to-remember, but at the same-time more application-specific. I liked the first solution more because it's more flexible, and can start from any angle-- that's something I learnt as a bonus from your answer ! – Partha D. May 14 '19 at 6:28
• @ParthaD. Thanks! You can of course combine them, i.e. these things are not mutually exclusive, e.g. \BubbleDiagramAnimated[clockwise,start angle=150]{Machine Learning, Supervised, Unsupervised, Reinforcement} also works (but the order matters here, if you set start angle first, it ill be overwritten.) – user121799 May 14 '19 at 6:31
• Oh-- so, clockwise replaces -1` ?! Then, that's fantastic... I misundertood, or rather under-understood :) – Partha D. May 14 '19 at 7:00