Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

A dataflow diagram

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}
share|improve this question
2  
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
2  
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
1  
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
1  
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
1  
@BaoRu Thanks for posting your example code. –  Alan Munn Nov 22 '13 at 5:49

1 Answer 1

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}

output of code

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.