I am trying to build a block diagram and achieved as below so far.
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{system overview}
\author{Paari Vendhan}
\date{November 2018}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, arrows.meta, fit,backgrounds, positioning, calc}
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{container1} = [draw, rectangle, inner sep=0.3cm, fill=gray!20,minimum height=5cm]
\tikzset{
mybackground/.style={execute at end picture={
\begin{scope}[on background layer]
\node[] at (current bounding box.north){\bottom{1cm} #1};
\end{scope}
}},
}
\begin{document}
\maketitle
\section{Flowchart}
\begin{figure}[!h]
\begin{tikzpicture}[%
every path/.style={thick, shorten >=2pt, shorten <=2pt},
node distance=2cm
]
\node (pro1) [process] {K};
\node (pro2) [process, below of=pro1, yshift=-0.5cm] {A};
\node (pro3) [process, right of=pro2, xshift = 2cm, yshift=1.25cm] {B};
\node (pro4) [process, below of=pro2, yshift=-0.5cm] {C};
\node (pro5) [process, below of=pro4, yshift=-0.5cm] {D};
\node (pro6) [process, right of=pro5, xshift = 2cm] {E};
\node (pro7) [process, right of=pro6, xshift = 2cm, yshift=2.5cm] {F};
\node (pro8) [process, right of=pro7, xshift = 2cm] {G};
\node (clo1)[cloud, cloud puffs=15.7, right of=pro1, minimum width=3cm, draw, fill=green!20, xshift=8.25cm] {H};
\begin{scope}[on background layer]
\node (block1) [container1,fit= { (pro1) (pro2) (pro4) (pro5) }, ] (container) {};
\node (block2) [container1,fit=(pro3) (pro7) (pro6), fill=cyan!20] (container) {};
\node (block3) [container1,fit=(pro8), fill=red!10] (container) {};
\end{scope}
\draw [arrow] (pro1) -| (pro3);
\draw [arrow] (pro2) -| (pro3);
\draw [arrow] (pro5) -- (pro6);
\draw [arrow] (pro3) -| (pro7);
\draw [arrow] (pro6) -| (pro7);
% \draw [arrow] (pro7) -| (clo1); # needs an offset arrow from pro7
\draw [arrow] (clo1) -| (pro8);
\path [draw=black,->, -Stealth] ([xshift=.25cm]pro7.north) |- (clo1.west);
\end{tikzpicture}
\caption{System Overview} \label{fig:sys_ov}
\end{figure}
\end{document}
Problems:
1. How do I increase space between background containers? I tried moving, but blocks on them do not move with them complicating things.
2. The arrows do not exactly start from node, but there is a small gap between the arrow endpoint(start or end) and the blocks). how to solve that?
3. I am unable to draw arrow between block and container. For eg, I want to connect C to blue container and also pink at right end.
4. Also how do I have all containers of same height? Min height messes up with alignment of them.
Update 1:
As per AndreC's suggestions, pic has been improvised as below. Only two problems. The arrow from C to block 1 should be straight (from where C is, arrow originating from its right, go straight to meet blue container on the right). Also another arrow should emanate from C from its left, go a round about on the bottom to meet pink container, not currently directly as shown below. How do we do these?
Update 2:
One of above problems in update 1 almost fixed as below. However, the arrow from C to blue is still bent, I want it go straight from C on tis right to blue container. What do we do?
Updated MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{system overview}
\author{Paari Vendhan}
\date{November 2018}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, arrows.meta, fit,backgrounds, positioning, calc}
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{container1} = [draw, rectangle, inner sep=0.3cm, fill=gray!20,minimum height=9cm]
\tikzstyle{line} = [draw, -latex']
\tikzset{
mybackground/.style={execute at end picture={
\begin{scope}[on background layer]
\node[] at (current bounding box.north){\bottom{1cm} #1};
\end{scope}
}},
}
\begin{document}
\maketitle
\section{Flowchart}
\begin{figure}[!htp]
\begin{tikzpicture}[%
every path/.style={thick,% shorten >=pt, shorten <=2pt
},
node distance=2cm,
]
\node [process] (pro1) at (0,0) {K};
\node [process](pro2) [below=1cm of pro1 ] {A};
\node [process] (pro3) [right=1cm of pro2, yshift=1cm] {B};
\node [process] (pro4) [below= 1cm of pro2] {C};
\node [process](pro5) [below= 1cm of pro4] {D};
\node [process](pro6) [right =1cm of pro5,yshift=1cm] {E};
\node [process](pro7) [right of =pro6, yshift=2cm] {F};
\node [process](pro8) [right =1cm of pro7] {G};
\node (clo1)[cloud, cloud puffs=15.7, above=4.5cm of pro7,xshift=2.5cm, minimum width=3cm, draw, fill=green!20] {H};
\begin{scope}[on background layer]
\node [container1,fit= { (pro1) (pro2) (pro4) (pro5) }] (block1) {};
\node [container1,fit=(pro3) (pro7) (pro6), fill=cyan!20] (block2) {};
\node [container1,fit=(pro8), fill=red!10] (block3) {};
\path [arrow,out=0,in=180] (pro4)edge(block2);
\path[line] (pro4) -| ([xshift=-0.5cm,yshift=-1.5cm]pro5.south west) -| (block3);
\end{scope}
\draw [arrow] (pro1) -| (pro3);
\draw [arrow] (pro2) -| (pro3);
\draw [arrow] (pro5) -| (pro6);
\draw [arrow] (pro3) -| (pro7);
\draw [arrow] (pro6) -| (pro7);
% \draw [arrow] (pro7) -| (clo1); # needs an offset arrow from pro7
\draw [arrow] (clo1) -| (pro8);
\path [draw=black,->, -Stealth] ([xshift=.25cm]pro7.north) |- (clo1.west);
\end{tikzpicture}
\caption{System Overview} \label{fig:sys_ov}
\end{figure}
\end{document}