2

I want to draw a flow chart like this: enter image description here

but I can only draw the following picture:

enter image description here

I can not control the labels position precisely, and I don't know how to draw a arrow from one node to the middle of the other arrow; how to draw line between labels(the left red line between labels. And this flowchart looks not beautiful, who have more beautiful flowchart example?

\documentclass[tikz,border=2pt]{standalone}
\usepackage{inputenc}
\usetikzlibrary{positioning,chains}
\usetikzlibrary{shapes,arrows,matrix,scopes}
\begin{document}
\begin{tikzpicture}
    [auto,
        decision/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5.2em, text centered, rounded corners,minimum height=1.2em},
        block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=10.2em, text centered, rounded corners,minimum height=1.2em},
        block1/.style={rectangle, draw=blue, thick, fill=blue!20,text width=11.2em, text centered, rounded corners,minimum height=1.2em},
        line/.style={draw, thick, -latex', shorten >=2pt},
        cloud/.style={rectangle, draw=red, thick, fill=red!20,text width=1.2em, text centered, rounded corners,minimum height=4.2em}]
    \matrix [column sep=5mm,row sep=5mm,ampersand replacement=\&]
      {
      % row 1
          \&  \node [block] (r1){abcdefghi}; \& \\
        % row2
        \node [block] (r21){abcd}; \&
         \node [decision] (r22){abcdef}; \&
        \node [decision] (r23){abcdefg}; \\
      % row 3
        \node [block] (r31) {abcdefgh}; \& 
        \node [decision] (r32) {abcdefghijkl}; \&
        \node [decision] (r33) {abcdegfhij}; \&\\
      % row 4
          \node [block] (r4){abcedef}; \&\\
          % row 5
          \node [block] (r5) {abcdefgh}; \& \\
      % row 6
       \node [block] (r6) {abvdfasdfsdfdsafsadf}; \& \\
      % row 7
       \& \hspace{-3em} \node [block1] (r7){sdfsdfsdfs}; \& \\
          % row 8
          \node [block] (r8){dfassdfsdf}; \& \\
         % row 9
          \node [block] (r9){dfsdfsdf}; \& \\
         % row 10
        \node [block] (r10){dsfasdf}; \& \\
      };
\begin{scope}[every path/.style=line]
  \path   (r1)-- (r21);
  \path   (r1)-- (r22);
    \path   (r1)-- (r23);
      \path   (r21)-- (r31);
  \path   (r22)-- (r32);
    \path   (r23)-- (r33);
      \path   (r31)-- (r4);
  \path   (r4)-- (r5);
    \path   (r5)--node[right]{abce} (r6);
      \path   (r6)-- (r8);
  \path   (r8)-- (r9);
    \path   (r9)-- (r10);
  \path   (r5)-| node[near end]{bded} (r32);
\end{scope}
% the labels on the left
    \begin{scope}[node distance=7mm]
\node[cloud,below left=-50mm of r1.north west]{a\\b};         
\node[cloud,below left=-50mm and 11mm of r31.north west]{a\\b\\d\\d};
\node[cloud,below left=-50mm and 11mm of r6.north west]{a\\e\\f\\g\\h};
\node[cloud,below left=-50mm and 11mm of r9.north west]{a\\b\\c\\d};
    \end{scope}
\end{tikzpicture}
\end{document} 

1 Answer 1

3

Try to understand following solution. It's just one possibility.

  \path (r7)->(r7-|r6); %<---- New line

draws a line from r7 to intersection between r7 and r6 centers.

\node[cloud, above left=0mm and 7mm of r21.south west] (ab) {a\\b};         

draws a cloud node 7mm left of r21.south west using south east (due to above left) as node anchor.

\node[cloud] at (ab|-r4) (abdd) {a\\b\\d\\d};

this one is easy if you understood the first.

For red lines, play a little bit until you obtain the desired result:

\draw[thick, red] ([shift={(3mm,-2mm)}]ab.south east)--+(180:13mm);

enter image description here

This is the complete code:

\documentclass[tikz,border=2pt]{standalone}
\usepackage{inputenc}
\usetikzlibrary{positioning,chains}
\usetikzlibrary{shapes,arrows,matrix,scopes}
\begin{document}
\begin{tikzpicture}
    [auto,
        decision/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5.2em, text centered, rounded corners,minimum height=1.2em},
        block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=10.2em, text centered, rounded corners,minimum height=1.2em},
        block1/.style={rectangle, draw=blue, thick, fill=blue!20,text width=11.2em, text centered, rounded corners,minimum height=1.2em},
        line/.style={draw, thick, -latex', shorten >=2pt},
        cloud/.style={rectangle, draw=red, thick, fill=red!20,text width=1.2em, text centered, rounded corners,minimum height=4.2em}]
    \matrix [column sep=5mm,row sep=5mm,ampersand replacement=\&]
      {
      % row 1
          \&  \node [block] (r1){abcdefghi}; \& \\
        % row2
        \node [block] (r21){abcd}; \&
         \node [decision] (r22){abcdef}; \&
        \node [decision] (r23){abcdefg}; \\
      % row 3
        \node [block] (r31) {abcdefgh}; \& 
        \node [decision] (r32) {abcdefghijkl}; \&
        \node [decision] (r33) {abcdegfhij}; \&\\
      % row 4
          \node [block] (r4){abcedef}; \&\\
          % row 5
          \node [block] (r5) {abcdefgh}; \& \\
      % row 6
       \node [block] (r6) {abvdfasdfsdfdsafsadf}; \& \\
      % row 7
       \& \hspace{-3em} \node [block1] (r7){sdfsdfsdfs}; \& \\
          % row 8
          \node [block] (r8){dfassdfsdf}; \& \\
         % row 9
          \node [block] (r9){dfsdfsdf}; \& \\
         % row 10
        \node [block] (r10){dsfasdf}; \& \\
      };
\begin{scope}[every path/.style=line]
  \path   (r1)-- (r21);
  \path   (r1)-- (r22);
    \path   (r1)-- (r23);
      \path   (r21)-- (r31);
  \path   (r22)-- (r32);
    \path   (r23)-- (r33);
      \path   (r31)-- (r4);
  \path   (r4)-- (r5);
    \path   (r5)--node[right]{abce} (r6);
      \path   (r6)-- (r8);
  \path   (r8)-- (r9);
    \path   (r9)-- (r10);
  \path   (r5)-| node[near end]{bded} (r32); 
  \path (r7)->(r7-|r6); %<---- New line
\end{scope}
% the labels on the left
\node[cloud, above left=0mm and 7mm of r21.south west] (ab) {a\\b};         
\node[cloud] at (ab|-r4) (abdd) {a\\b\\d\\d};
\node[cloud] at (ab|-r7) (aefgh) {a\\e\\f\\g\\h};
\node[cloud] at (ab|-r10) (abcd) {a\\b\\c\\d};

%red line
\draw[thick, red] ([shift={(3mm,-2mm)}]ab.south east)--+(180:13mm);
\draw[thick, red] ([shift={(3mm,2mm)}]aefgh.north east)--+(180:13mm);
\draw[thick, red] ([shift={(3mm,2mm)}]abcd.north east)--+(180:13mm);
\end{tikzpicture}
\end{document} 
4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .