# Drawing a data flow diagram in LaTeX

Would it be possible to draw a data flow diagram in LaTeX as follow? if so, how? (actually I am only puzzled with the bounding box).

Thanks a lot

Edit: the following code will get me everything except the bounding box can anyone pls help?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[
font=\rmfamily\footnotesize,
every matrix/.style={ampersand replacement=\&,column sep=2cm,row sep=.6cm},
source/.style={draw,thick,rounded corners,fill=yellow!20,inner sep=.3cm},
process/.style={draw,thick,circle,fill=blue!20},
sink/.style={source,fill=green!20},
datastore/.style={draw,very thick,shape=datastore,inner sep=.3cm},
dots/.style={gray,scale=2},
to/.style={->,>=stealth',shorten >=1pt,semithick,font=\rmfamily\scriptsize},
every node/.style={align=center}]

% Position the nodes using a matrix layout
\matrix{
\node[source] (a) {A}; \& \& \\
\& \& \node[source] (b) {B};\\
\node[source] (c) {C}; \& \node[source] (d) {D};\\
\& \& \node[source] (e) {E};\\
\node[source] (f) {F}; \& \& \\
};

% Draw the arrows between the nodes and label them.
\draw[to] (a) -- node[midway,above] {raw events}
node[midway,below] {level 0} (c);
\draw[to] (c) -- node[midway,right] {raw event data\\level 1} (f);
\draw[to] (f) to[bend right=20] node[midway,above] {events}
node[midway,below] {level 1} (d);
\draw[to] (d)-- node[midway,above] {events}
node[midway,below] {level 1} (b);
\draw[to] (d) -- node[midway,above] {events}
node[midway,below] {level 1} (e);
\end{tikzpicture}
\end{center}
\end{document}

-
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – texenthusiast Nov 22 '13 at 3:50
if you could post what you have so far, someone could probably finish it. the fit library would probably be useful – cmhughes Nov 22 '13 at 3:56
Check some examples at texample.net/tikz/examples/porter-model and tex.stackexchange.com/questions/8879/draw-image-data-flow and Linked Q's for a good starting point. – texenthusiast Nov 22 '13 at 3:56
You could search something like [tikz-pgf] fit flow. The third find on Google should also be helpful. – Qrrbrbirlbel Nov 22 '13 at 4:48
@BaoRu Thanks for posting your example code. – Alan Munn Nov 22 '13 at 5:49

As mentioned in the comments, the fit library is designed exactly for this purpose. One thing to know about the fit node is that it's hard to put text inside it any place other than its centre, so to label the dotted parts, you need to place separate nodes by hand.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,fit,positioning}

\begin{document}
\begin{tikzpicture}[
font=\rmfamily\footnotesize,
every matrix/.style={ampersand replacement=\&,column sep=2cm,row sep=.6cm},
source/.style={draw,thick,rounded corners,fill=yellow!20,inner sep=.3cm},
process/.style={draw,thick,circle,fill=blue!20},
sink/.style={source,fill=green!20},
datastore/.style={draw,very thick,shape=datastore,inner sep=.3cm},
dots/.style={gray,scale=2},
to/.style={->,>=stealth',shorten >=1pt,semithick,font=\rmfamily\scriptsize},
every node/.style={align=center}]

% Position the nodes using a matrix layout
\matrix{
\node[source] (a) {A}; \& \& \\
\& \& \node[source] (b) {B};\\
\node[source] (c) {C}; \& \node[source] (d) {D};\\
\& \& \node[source] (e) {E};\\
\node[source] (f) {F}; \& \& \\
};

% Draw the arrows between the nodes and label them.
\draw[to] (a) -- node[midway,above] {raw events}
node[midway,below] {level 0} (c);
\draw[to] (c) -- node[midway,right] {raw event data\\level 1} (f);
\draw[to] (f) to[bend right=20] node[midway,above] {events}
node[midway,below] {level 1} (d);
\draw[to] (d)-- node[midway,above] {events}
node[midway,below] {level 1} (b);
\draw[to] (d) -- node[midway,above] {events}
node[midway,below] {level 1} (e);
% Draw the dotted surrounding lines and add the labels as separate nodes
% This is necessary because the anchor of the fitted node is always center

\node[draw,dotted,fit=(a) (c) (f),inner sep=4ex,] (ACF) {};
\node[above=-3ex of ACF] (ACFt) {Title 1};
\node[draw,dotted,fit=(b) (e), inner sep=4ex] (BE) {};
\node[above=-3ex of BE] (Bet) {Title 2};
\end{tikzpicture}
\end{document}


-