# Smartdiagram - keeping settings local - ? a bug

Not sure if I am being stupid or if this is a bug. I am having great problems keeping smartdiagram settings local to the diagram. Settings in one diagram has side effects across other diagrams in the same document, and diagrams differ depending on the order presented.

I would have thought settings within a group should remain local -- and they sometimes do, but often they do not.

Take the following MWE and resulting output. Diagram A and C are identical, and each is within a group. The larger central planet size in diagram A does not carry forward to diagram B even though diagram B does not explicitly set a planet size (so far so good).

However Diagram B resets the arrows (to be uniform color) and resets colors of satellites -- again both these changes within a group.

Diagram C (identical to A) "sees" these changes and retains the satellite re-colorings, and does something odd with the arrow colors (making some uniform but not others).

Surely this is a bug? So how do I keep setting changes absolutely and always local?

    \documentclass{article}
\usepackage{smartdiagram}
\begin{document}

%Diagram A
\begingroup
\smartdiagramset{
planet size=4.0cm,
satellite size=1.0cm,
}
\smartdiagram[constellation diagram]{A,1,2,3,4,5,6 }
\endgroup

%Diagram B
\begingroup
\smartdiagramset{
%   planet size=1.5cm,
satellite size=1.0cm,
set color list={red, red,red},
uniform connection color=true,
}

\smartdiagram[constellation diagram]{B,1,2,3,4,5,6 }
\endgroup

%Diagram C - identical to A
\begingroup
\smartdiagramset{
planet size=4.0cm,
satellite size=1.0cm,
}
\smartdiagram[constellation diagram]{C,1,2,3,4,5,6 }
\endgroup

\end{document}


The definitions performed by set color list are global:

% smartdiagramlibrarycore.definitions.code.tex lines 161-166

\pgfkeys{/smart diagram/.cd, set color list/.code={%
\foreach \listitem [count=\i] in {#1}{%
\global\@namedef{color@\i\expandafter}\expandafter{\listitem}%
}%
}%
}


This can be fixed:

\documentclass{article}
\usepackage[landscape,a3paper]{geometry}
\usepackage{smartdiagram}

\makeatletter
\pgfkeys{
/smart diagram/.cd, set color list/.code={%
\xdef\sm@global@temp{}%
\foreach \listitem [count=\i] in {#1}{%
\xdef\sm@global@temp{%
\unexpanded\expandafter{\sm@global@temp}%
\noexpand\@namedef{color@\i}{\listitem}%
}%
}%
\sm@global@temp
}%
}
\makeatother

\begin{document}

%Diagram A
\begingroup
\smartdiagramset{
planet size=4.0cm,
satellite size=1.0cm,
}
\smartdiagram[constellation diagram]{A,1,2,3,4,5,6}
\endgroup
%
%Diagram B
\begingroup
\smartdiagramset{
planet size=1.5cm,
satellite size=2.0cm,
set color list={red, red,red},
uniform connection color=true,
}
\smartdiagram[constellation diagram]{B,1,2,3,4,5,6}
\endgroup
%
%Diagram C - identical to A
\begingroup
\smartdiagramset{
planet size=3.0cm,
satellite size=3.0cm,
}
\smartdiagram[constellation diagram]{C,1,2,3,4,5,6}
\endgroup

\end{document}


• That's unfortunate -- some local and some global -- and how would one even know that for the huge variety of different settings? It would mean that there is no way to produce a smartdiagram that is going to be known to be immune to changes elsewhere in the document or to changes in ordering of chapters - making the package pretty much unusable.... Pretty much explains the troubles I have been having. – Aubrey Blumsohn Jun 8 '18 at 21:18
• @AubreyBlumsohn I added a fix. Maybe you can ask the author to implement it. – egreg Jun 8 '18 at 21:19
• @AubreyBlumsohn I mailed the author. – egreg Jun 8 '18 at 21:25