help with tikz diagram 2
Gruezi from a marmot! ;-)
Here is how I would address the upper part of your questions:
- use
fit
to draw the boundary of the upper group and to define the starting points of the arrows; - add some auxiliary coordinates to make the lower frame as wide as the upper one (=4th edit);
- add auxiliary coordinates
h
andh'
to add the text withedge["text",swap]
, whereswap
swaps the text position from above to below; - and 5. use Kpym's extremely cool and undervoted callouts with multiple pointers. I replaced
cloudy
by something that might be more appropriate.
For some reason the umlaute do not show, which compiler do you use? They will of course show when you compile the code. (To compensate for that, I fixed the spelling of "persönlich". ;-)
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric,
chains,
calc,
fit,
arrows.meta,
backgrounds,
quotes,
matrix
}
% from https://tex.stackexchange.com/a/432326/121799
\usetikzlibrary{decorations.pathreplacing,shadows.blur,shapes}
\tikzset{
% styles to save the path in `\savedpath`
add path/.style = {
decoration={show path construction,
moveto code={
\xdef\savedpath{\savedpath (\tikzinputsegmentfirst)}
},
lineto code={
\xdef\savedpath{\savedpath -- (\tikzinputsegmentlast)}
},
curveto code={
\xdef\savedpath{\savedpath .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast)}
},
closepath code={
\xdef\savedpath{\savedpath -- cycle}
}
},
decorate
},
store path/.style = {add path},
store path/.prefix code={\xdef\savedpath{}},
% the style to create the path
callouts/.style={
store path,
append after command={
foreach \target in {#1}{
($(callout)!2pt!-90:\target$)--\target --($(callout)!2pt!90:\target$)
} \savedpath
},
alias=callout
},
% the style to display the callout
custom style/.style={fill=blue!20,text=,blur shadow},
% some fun cloudy node
cloudy/.style={cloud,cloud puffs=10,cloud puff arc=120, aspect=2},
more serious/.style={ellipse}
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={
text width=3cm,
align=center,
draw
},
diam/.style={
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white
},
basecirc/.style={
circle,
draw,
align=center,
text width=1.5cm
},
persoenlich/.style={
basecirc,
fill=black!60,
text=white
},
finanziell/.style={
basecirc,
fill=black!30
},
keine/.style={
basecirc,
fill=white
},
]
\begin{scope}[
start chain=groups,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
draw=none, %<- added
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {freiwillig, nur Katastrophen-\\schutz};
\node {freiwillig, nur Katastrophen-\\schutz};
\end{scope}
% add a frame
\node[fit=(groups-1) (groups-4) (values-1) (values-4),draw,inner
sep=-\pgflinewidth/2](upper fit){};
\foreach \X[count=\Y] in {2,3,4}
{\draw ($(groups-\Y.south east)!0.5!(groups-\X.south west)$) coordinate(aux)
-- (aux|-upper fit.south);}
\node [diam, below=2cm of values-1] (tauglich) {sicherheits-\\dienst\\-tauglich?};
\node [diam, right=4.2 of tauglich, inner sep=-2pt] (IV) {IV bzw.\\Integritäts-\\schädigung\\>40\%?};
\node [keine, right=0.75cm of IV] (EG) {keine\\Ersatz-\\abgabe};
\node [diam, below=of tauglich] (Gewissen) {mit\\Gewissen\\vereinbar?};
\node [finanziell, at=(IV|-Gewissen)] (Ersatzabgabe) {Ersatz\-abgabe};
\node [persoenlich, below=of Gewissen] (Armee) {Armee};
\node [finanziell, right=0.3 of Armee, , left color=black!60, right color=black!30,shading angle=90] (Schutz) {Katastrophen-\\schutz};
% modified the draw commands
\draw [-Triangle, line width=2mm] (upper fit.south -| values-1.center) -- coordinate (mid) (tauglich);
\draw [dashed, ultra thick] (upper fit.south -|values-2) |- (mid);
\draw [dashed, thick] (upper fit.south -|values-3) -- (values-3 |- mid) ;
\draw [dashed, thick] (upper fit.south -|values-4) |- (values-2 |- mid);
\coordinate (a) at (2.2,-11);
\coordinate (b) at (0,-7.2);
\draw [thick] [-] (a) |- (b) coordinate[midway] (h); % added hilfscoordinate
\coordinate (a) at (2.2,-11);
\coordinate (c) at (1,-8.85);
\draw [thick] [-] (a) |- (c) coordinate[midway] (h'); % added hilfscoordinate
\path[near start,thick]
(tauglich) edge["JA"] (Gewissen)
(Gewissen) edge["JA"] (Armee)
(b) edge["text",swap] (h) %<-add text
(tauglich) edge["NEIN"] (IV)
(IV) edge["JA"] (EG)
(IV) edge["NEIN"] (Ersatzabgabe);
% 3rd edit
\coordinate (aux-L) at ([xshift=5mm+\pgflinewidth]upper fit.west|-Armee.center);
\coordinate (aux-R) at ([xshift=-5mm-\pgflinewidth]upper fit.east|-Armee.center);
\node [draw,fit=(Armee)(EG)(aux-L)(aux-R), inner sep=5mm] (frame) {};
\matrix [
above left,
matrix of nodes,
nodes={anchor=west}
] (m) at (frame.south east) {
&&[0.5cm] |[persoenlich,text width=0cm]| & persönliche Dienstleistung \\
&& |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\
|[draw,minimum size=8pt]| & Sicherheitsdienstpflicht & |[keine,text width=0cm]| & keine Leistung \\
};
\path[custom style] ($(Schutz)!0.5!(Ersatzabgabe)$) node[more serious,callouts={(Schutz),(Ersatzabgabe)}]{blah blah};
\path[custom style] ($(h')+(1,1)$) node[more serious,callouts={(h')}]{blah blah};
\end{tikzpicture}
\end{document}
2nd EDIT: As for your second question, I would just include the matrix
in the fit.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric, % for diamond shape
chains, % for automatic placement nodes relative to the previous one, in "chains"
calc, % for ($...$) syntax of coordinate calculation
fit, % to create a node that fits around other specified nodes
arrows.meta, % for Triangle arrow tip
backgrounds, % for "on background layer", to place something behind already existing stuff
quotes, % for edge["label"] syntax, easy way of placing text along an edge
matrix % for matrix of nodes
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={ % base style for rectangles on top of the diagram
text width=3cm,
align=center,
draw
},
diam/.style={ % style for the black diamonds
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white
},
basecirc/.style={ % basic circle style, used in the next three styles
circle,
draw,
align=center,
text width=1.5cm
},
persohnlich/.style={
basecirc,
fill=black!60,
text=white
},
finanziell/.style={
basecirc,
fill=black!30
},
keine/.style={
basecirc,
fill=white
},
]
\begin{scope}[
% in this scope, start a chain called groups. nodes in this chain are named groups-1, groups-2 etc.
start chain=groups,
% set distance between nodes in the chain
node distance=-\pgflinewidth,
every node/.append style={ % set style for all the nodes in the scope
baserect,
on chain, % adds all the nodes to the chain
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
% now add all the nodes, no additional styling or positioning needed
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
% this scope is basically the same as the previous one.
% one main difference is that the first node in the chain is
% placed on the lower edge of the first node in the previous chain
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\end{scope}
% the nodes in the first row of the flow chart
\node [diam, below=2cm of values-1] (tauglich) {dienst-\\tauglich?};
\node [keine, right=7.9 of tauglich] (EG) {keine\\Ersatz-\\abgabe};
% last node in flow chart
\node [persohnlich, below=of tauglich] (Armee) {Armee};
\node [persohnlich, right=0.75cm of Armee] (Feuerwehr) {Feuerwehr};
\node [persohnlich, right=0.75cm of Feuerwehr] (Zivilschutz) {Zivilschutz};
\node [persohnlich, right=0.75cm of Zivilschutz] (SRK) {Einsatz-\\organisationen\\SRK*};
\node [persohnlich, right=0.75cm of SRK] (Gemeinschaftsdienste)
{Gemein-\\schafts-\\dienste};
% draw thick arrow from the dienstpflichtig node to the first node in the flow chart
% add a coordinate named "mid" halfway along the arrow, that is used to draw the dashed lines
\draw [-Triangle, line width=2mm] (values-1) -- coordinate (mid) (tauglich);
% here (values-2) |- (mid) means draw a vertical, then horizontal,
% line from values-2 to mid
\draw [line width=2mm] (values-2) |- (mid);
\draw [line width=2mm] (values-3) |- (mid);
\draw [line width=2mm] (values-4) |- (mid);
% here the -|/|- syntax is used both for coordinate specifications and path specifications
%\draw [dashed, thick] (values-3) -- (values-3 |- mid) -| (schutzdienst);
%\draw [dashed, thick] (values-4) |- (values-3 |- mid);
% draw the coloured background for the top right part of the flow chart, using a fit node
%\begin{scope}[on background layer]
% \node [fill=black!10, fit=(Zivilschutz)(EG), inner sep=3mm] {};
%\end{scope}
% draw the connections in the flow chart
% the ".." syntax comes from the quotes library
\path[near start,thick]
(tauglich) edge["JA"] (Armee)
(tauglich) edge["NEIN"] (EG);
\coordinate (a) at (2.5,-7.28);
\coordinate (b) at (0,-6.8);
\draw [-] (a) |- (b);
\coordinate (c) at (5,-7.28);
\coordinate (b) at (0,-6.8);
\draw [-] (c) |- (b);
\coordinate (d) at (7.7,-7.16);
\coordinate (b) at (0,-6.8);
\draw [-] (d) |- (b);
\coordinate (e) at (10.5,-7.29);
\coordinate (b) at (0,-6.8);
\draw [-] (e) |- (b);
% use a matrix to make the legend
\matrix [
below=1.1cm of Gemeinschaftsdienste.east,
anchor=north east,
matrix of nodes,
nodes={anchor=west}
] (m) {
&&[1cm]|[keine,text width=0cm]| & keine Leistung \\
|[draw,minimum size=8pt]| & Allgemeine Diensptpflicht & |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\
};
% use fit again, to draw the surrounding frame
\node [draw,fit=(Armee)(EG)(m), inner sep=5mm] (frame) {};
\end{tikzpicture}
\end{document}
ADDENDUM: Callouts from this answer.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric,
chains,
calc,
fit,
arrows.meta,
backgrounds,
quotes,
matrix
}
\makeatletter % from https://tex.stackexchange.com/questions/187165/callout-with-multiple-pointers-how-to-design-it/361532#361532]
\def\overlaynode<#1>#2;{
\gdef\stacknodecommonpart{#2}
\pgfkeys{/typeset node/.list={#1}}
% we are lazy
% pgfkeys will translate
% \pgfkeys{/typeset node/.list={red,blue}}
% into
% \pgfkeys{/typeset node=red}
% \pgfkeys{/typeset node=blue}
}
\pgfkeys{
/typeset node/.code={
\edef\pgf@marshal{\noexpand\node[#1]\stacknodecommonpart;}
\pgf@marshal
}
}
\def\overlaynodedrawfill{\pgfutil@ifnextchar[{\overlaynodedrawfill@opt}{\overlaynodedrawfill@opt[]}}
\def\overlaynodedrawfill@opt[#1]<#2>#3;{
\begin{scope}[transparency group,draw=black,fill=white,line cap=round,line join=round,#1]
\pgfmathsetmacro\pgflinewidthdouble{2\pgflinewidth}
\overlaynode<#2>[draw=pgfstrokecolor,line width=\pgflinewidthdouble]#3;
\overlaynode<#2>[fill=pgffillcolor]#3;
\end{scope}
}
\makeatother
% from https://tex.stackexchange.com/a/432326/121799
\usetikzlibrary{decorations.pathreplacing,shadows.blur,shapes}
\tikzset{
% styles to save the path in `\savedpath`
add path/.style = {
decoration={show path construction,
moveto code={
\xdef\savedpath{\savedpath (\tikzinputsegmentfirst)}
},
lineto code={
\xdef\savedpath{\savedpath -- (\tikzinputsegmentlast)}
},
curveto code={
\xdef\savedpath{\savedpath .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast)}
},
closepath code={
\xdef\savedpath{\savedpath -- cycle}
}
},
decorate
},
store path/.style = {add path},
store path/.prefix code={\xdef\savedpath{}},
% the style to create the path
callouts/.style={
store path,
append after command={
foreach \target in {#1}{
($(callout)!2pt!-90:\target$)--\target --($(callout)!2pt!90:\target$)
} \savedpath
},
alias=callout
},
% the style to display the callout
custom style/.style={fill=white,text=black,blur shadow},
% some fun cloudy node
cloudy/.style={cloud,cloud puffs=10,cloud puff arc=120, aspect=2},
more serious/.style={ellipse,draw=black}
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={
text width=3cm,
align=center,
draw
},
diam/.style={
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white
},
basecirc/.style={
circle,
draw,
align=center,
text width=1.5cm
},
persoenlich/.style={
basecirc,
fill=black!60,
text=white
},
finanziell/.style={
basecirc,
fill=black!30
},
keine/.style={
basecirc,
fill=white
},
]
\begin{scope}[
start chain=groups,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
draw=none, %<- added
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {freiwillig, nur Katastrophen-\\schutz};
\node {freiwillig, nur Katastrophen-\\schutz};
\end{scope}
% add a frame
\node[fit=(groups-1) (groups-4) (values-1) (values-4),draw,inner
sep=-\pgflinewidth/2](upper fit){};
\foreach \X[count=\Y] in {2,3,4}
{\draw ($(groups-\Y.south east)!0.5!(groups-\X.south west)$) coordinate(aux)
-- (aux|-upper fit.south);}
\node [diam, below=2cm of values-1] (tauglich) {sicherheits-\\dienst\\-tauglich?};
\node [diam, right=4.2 of tauglich, inner sep=-2pt] (IV) {IV bzw.\\Integritäts-\\schädigung\\>40\%?};
\node [keine, right=0.75cm of IV] (EG) {keine\\Ersatz-\\abgabe};
\node [diam, below=of tauglich] (Gewissen) {mit\\Gewissen\\vereinbar?};
\node [finanziell, at=(IV|-Gewissen)] (Ersatzabgabe) {Ersatz\-abgabe};
\node [persoenlich, below=of Gewissen] (Armee) {Armee};
\node [finanziell, right=0.3 of Armee, , left color=black!60, right color=black!30,shading angle=90] (Schutz) {Katastrophen-\\schutz};
% modified the draw commands
\draw [-Triangle, line width=2mm] (upper fit.south -| values-1.center) -- coordinate (mid) (tauglich);
\draw [dashed, ultra thick] (upper fit.south -|values-2) |- (mid);
\draw [dashed, thick] (upper fit.south -|values-3) -- (values-3 |- mid) ;
\draw [dashed, thick] (upper fit.south -|values-4) |- (values-2 |- mid);
\coordinate (a) at (2.2,-11);
\coordinate (b) at (0,-7.2);
\draw [thick] [-] (a) |- (b) coordinate[midway] (h); % added hilfscoordinate
\coordinate (a) at (2.2,-11);
\coordinate (c) at (1,-8.85);
\draw [thick] [-] (a) |- (c) coordinate[midway] (h'); % added hilfscoordinate
\path[near start,thick]
(tauglich) edge["JA"] (Gewissen)
(Gewissen) edge["JA"] (Armee)
(b) edge["text",swap] (h) %<-add text
(tauglich) edge["NEIN"] (IV)
(IV) edge["JA"] (EG)
(IV) edge["NEIN"] (Ersatzabgabe);
% 3rd edit
\coordinate (aux-L) at ([xshift=5mm+\pgflinewidth]upper fit.west|-Armee.center);
\coordinate (aux-R) at ([xshift=-5mm-\pgflinewidth]upper fit.east|-Armee.center);
\node [draw,fit=(Armee)(EG)(aux-L)(aux-R), inner sep=5mm] (frame) {};
\matrix [
above left,
matrix of nodes,
nodes={anchor=west}
] (m) at (frame.south east) {
&&[0.5cm] |[persoenlich,text width=0cm]| & persönliche Dienstleistung \\
&& |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\
|[draw,minimum size=8pt]| & Sicherheitsdienstpflicht & |[keine,text width=0cm]| & keine Leistung \\
};
\overlaynodedrawfill[draw,fill=white]<
{callout absolute pointer=(Schutz.45)},
{callout absolute pointer=(Ersatzabgabe.-135)}
>
[ellipse callout]
at ($(Schutz)!0.5!(Ersatzabgabe)$){hear me};
\overlaynodedrawfill[draw,fill=white]<
{callout absolute pointer=(h'.45)}
>
[ellipse callout]
at ($(h')+(1,1)$){hear me};
% \path[custom style] ($(Schutz)!0.5!(Ersatzabgabe)$) node[more serious,callouts={(Schutz),(Ersatzabgabe)}]{blah blah};
% \path[custom style] ($(h')+(1,1)$) node[more serious,callouts={(h')}]{blah blah};
\end{tikzpicture}
\end{document}
Regarding the enlargment of the frame and minor .north
calls instead of new \coordinate
definitions
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric, % for diamond shape
chains, % for automatic placement nodes relative to the previous one, in "chains"
calc, % for ($...$) syntax of coordinate calculation
fit, % to create a node that fits around other specified nodes
arrows.meta, % for Triangle arrow tip
backgrounds, % for "on background layer", to place something behind already existing stuff
quotes, % for edge["label"] syntax, easy way of placing text along an edge
matrix % for matrix of nodes
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={ % base style for rectangles on top of the diagram
text width=3cm,
align=center,
draw
},
diam/.style={ % style for the black diamonds
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white
},
basecirc/.style={ % basic circle style, used in the next three styles
circle,
draw,
align=center,
text width=1.5cm
},
persohnlich/.style={
basecirc,
fill=black!60,
text=white,
text width=1.7cm,
},
finanziell/.style={
basecirc,
fill=black!30
},
keine/.style={
basecirc,
fill=white
},
]
\begin{scope}[
% in this scope, start a chain called groups. nodes in this chain are named groups-1, groups-2 etc.
start chain=groups,
% set distance between nodes in the chain
node distance=-\pgflinewidth,
every node/.append style={ % set style for all the nodes in the scope
baserect,
on chain, % adds all the nodes to the chain
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
% now add all the nodes, no additional styling or positioning needed
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
% this scope is basically the same as the previous one.
% one main difference is that the first node in the chain is
% placed on the lower edge of the first node in the previous chain
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\end{scope}
% the nodes in the first row of the flow chart
\node [diam, below=2cm of values-1] (tauglich) {dienst-\\tauglich?};
\node [keine, right=7.9 of tauglich] (EG) {keine\\Ersatz-\\abgabe};
% last node in flow chart
\node [persohnlich, below=of tauglich] (Armee) {Armee};
\node [persohnlich, right=0.55cm of Armee] (Feuerwehr) {Feuerwehr};
\node [persohnlich, right=0.55cm of Feuerwehr] (Zivilschutz) {Zivilschutz};
\node [persohnlich, right=0.55cm of Zivilschutz] (SRK) {Einsatz-\\organisationen\\SRK*};
\node [persohnlich, right=0.55cm of SRK] (Gemeinschaftsdienste) {Gemein-schaftsdienste};
% draw thick arrow from the dienstpflichtig node to the first node in the flow chart
% add a coordinate named "mid" halfway along the arrow, that is used to draw the dashed lines
\draw [-Triangle, line width=2mm] (values-1) -- coordinate (mid) (tauglich);
% here (values-2) |- (mid) means draw a vertical, then horizontal,
% line from values-2 to mid
\draw [line width=2mm] (values-2) |- (mid);
\draw [line width=2mm] (values-3) |- (mid);
\draw [line width=2mm] (values-4) |- (mid);
% here the -|/|- syntax is used both for coordinate specifications and path specifications
%\draw [dashed, thick] (values-3) -- (values-3 |- mid) -| (schutzdienst);
%\draw [dashed, thick] (values-4) |- (values-3 |- mid);
% draw the coloured background for the top right part of the flow chart, using a fit node
%\begin{scope}[on background layer]
% \node [fill=black!10, fit=(Zivilschutz)(EG), inner sep=3mm] {};
%\end{scope}
% draw the connections in the flow chart
% the ".." syntax comes from the quotes library
\path[near start,thick]
(tauglich) edge["JA"] (Armee)
(tauglich) edge["NEIN"] (EG);
\coordinate (b) at (0,-6.8);
\draw [-] (Armee.north) |- (b);
\draw [-] (Feuerwehr.north) |- (b);
\draw [-] (Zivilschutz.north) |- (b);
\draw [-] (SRK.north) |- (b);
\draw [-] (Gemeinschaftsdienste) |- (b);
% use fit again, to draw the surrounding frame
\node [draw,fit=(Armee)(EG), inner sep=5mm] (frame) {};
% use a matrix to make the legend
\matrix [
above left,
matrix of nodes,
nodes={anchor=west}
] (m) at (frame.south east) {
&&[1cm]|[keine,text width=0cm]| & keine Leistung \\
|[draw,minimum size=8pt]| & Allgemeine Diensptpflicht & |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\
};
\end{tikzpicture}
\end{document}