1

Wanted

I would like to draw a flow chart like one shown in the image. The problem with the code I have generated is the arrows leading to top blocks and the bottom blocks, i.e., B&C,D&E meet at a central point but I would like them to be separately touching the sphere as shown in the picture. The following is my code:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes,arrows,calc}

% Define block styles
\tikzstyle{block} = [rectangle, draw, fill=white, 
text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=white, node distance=3cm,
minimum height=8em]

\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [cloud] (A) {AUTOMATIC TELLER MACHINE};


\node [block, left of=A,xshift=-4cm] (B) {B};
\node [block, below of=B,yshift=-2cm] (C) {C};
\node [block, above of=B,yshift=2cm] (D) {D};

\node [block, right of=A,xshift=4cm] (E) {E};
\node [block, below of=E,yshift=-2cm] (F) {F};
\node [block, above of=E,yshift=2cm] (G) {G};


%draw path 
\path [line] (A) -- node {}(B);
\path [line] (A) -- node {}(E);

\path [line] (A) |- (C);
\path [line] (A) |- (D);
\path [line] (A) |- (F);
\path [line] (A) |- (G);

\end{tikzpicture}
\end{document}
2

Is it like this?

enter image description here

This is obtained with

\path [line] (A.220) |- (C);
\path [line] (A.140) |- (D);
\path [line] (A.310) |- (F);
\path [line] (A.50) |- (G);

Your full code:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes,arrows,calc}

% Define block styles
\tikzstyle{block} = [rectangle, draw, fill=white,
text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=white, node distance=3cm,
minimum height=8em]

\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [cloud] (A) {AUTOMATIC TELLER MACHINE};


\node [block, left of=A,xshift=-4cm] (B) {B};
\node [block, below of=B,yshift=-2cm] (C) {C};
\node [block, above of=B,yshift=2cm] (D) {D};

\node [block, right of=A,xshift=4cm] (E) {E};
\node [block, below of=E,yshift=-2cm] (F) {F};
\node [block, above of=E,yshift=2cm] (G) {G};


%draw path
\path [line] (A) -- node {}(B);
\path [line] (A) -- node {}(E);

\path [line] (A.220) |- (C);
\path [line] (A.140) |- (D);
\path [line] (A.310) |- (F);
\path [line] (A.50) |- (G);

\end{tikzpicture}
\end{document}
  • 100% Correct! Thanks very much and Sorry about the picture. – Jones Abba Musango Jan 23 '15 at 10:23
  • 1
    @JonesAbbaMusango No it is my internet. Glad it helped. Please don't forget to accept the answers that solved your problem. For details: How do you accept an answer – user11232 Jan 23 '15 at 11:01
  • @JonesAbbaMusango Thank you. Happy TikZing. :-) – user11232 Jan 23 '15 at 12:57
2

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}

% parameter
\def\point{0.8 }

\begin{document}

\begin{pspicture}(-4,-2.5)(4,2.5)
  % ellipse
  \psellipse(0,0)(2,0.8)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
  \psset{arrows = ->}
  % left
  \psline(-2,0)(-3,0)
  \psframe(-4,-0.5)(-3,0.5)
  \psline(!-\point 0.4 4 \point dup mul sub sqrt mul)(-\point,2)(-3,2)
  \psframe(-4,1.5)(-3,2.5)
  \rput(-3.5,2){C}
  \rput(-3.5,0){F}
  \psline(!-\point -0.4 4 \point dup mul sub sqrt mul)(-\point,-2)(-3,-2)
  \psframe(-4,-2.5)(-3,-1.5)
  \rput(-3.5,-2){D}
  % right
  \psline(2,0)(3,0)
  \psframe(4,-0.5)(3,0.5)
  \psline(!\point 0.4 4 \point dup mul sub sqrt mul)(\point,2)(3,2)
  \psframe(4,1.5)(3,2.5)
  \rput(3.5,2){B}
  \rput(3.5,0){G}
  \psline(!\point -0.4 4 \point dup mul sub sqrt mul)(\point,-2)(3,-2)
  \psframe(4,-2.5)(3,-1.5)
  \rput(3.5,-2){E}
\end{pspicture}

\end{document}

output

Notice that Automatic Teller Machine has been moved down by 0.1 to make it more aesthetically pleasing.

Also, I found that a value for \point of around 0.8 gives the best result.

Update

Here is a fully 'automated' version where all you have to do is choose the values of the parameters and the drawing will then be adjusted accordingly:

\documentclass{article}

\usepackage{pstricks}
\usepackage{expl3}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

%% pspicture boundry
\newcommand*\width{\calc{\major+2}}
\newcommand*\height{\calc{\minor+1.5}}

%% box with label
\def\boxLabel(#1,#2)#3{%
  \psframe(\calc{#1+0.5},\calc{#2+0.5})(\calc{#1-0.5},\calc{#2-0.5})
  \rput(\calc{#1},\calc{#2}){#3}}

%% constant
\def\const{\calc{\minor*sqrt(1-(\point/\major)^2)}}

%% parameters
\def\point{1}
\def\major{2}
\def\minor{0.8}

\begin{document}

\begin{pspicture}(-\width,-\height)(\width,\height)
\psset{arrows = ->}
  %% ellipse
  \psellipse(0,0)(\major,\minor)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
  %% left
  % top
  \psline(-\point,\const)%
         (-\point,\calc{\minor+1})%
         (-\calc{\major+1},\calc{\minor+1})
  \boxLabel(-\major-1.5,\minor+1){C}
  % middle
  \psline(-\major,0)(-\calc{\major+1},0)
  \boxLabel(-\major-1.5,0){F}
  % bottom
  \psline(-\point,-\const)%
         (-\point,-\calc{\minor+1})%
         (-\calc{\major+1},-\calc{\minor+1})
  \boxLabel(-\major-1.5,-\minor-1){D}
  %% right
  % top
  \psline(\point,\const)%
         (\point,\calc{\minor+1})%
         (\calc{\major+1},\calc{\minor+1})
  \boxLabel(\major+1.5,\minor+1){B}
  % middle
  \psline(\major,0)(\calc{\major+1},0)
  \boxLabel(\major+1.5,0){G}
  % bottom
  \psline(\point,-\const)%
         (\point,-\calc{\minor+1})%
         (\calc{\major+1},-\calc{\minor+1})
  \boxLabel(\major+1.5,-\minor-1){E}
\end{pspicture}

\end{document}

Update 2

Here is another 'automated' version but with less code:

\documentclass{article}

\usepackage{pstricks}
\usepackage{expl3}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

%% pspicture boundry
\newcommand*\width{\calc{\major+2}}
\newcommand*\height{\calc{\minor+1.5}}

%% box with label
\def\boxLabel(#1,#2)#3{%
  \psframe(\calc{#1+0.5},\calc{#2+0.5})(\calc{#1-0.5},\calc{#2-0.5})
  \rput(\calc{#1},\calc{#2}){#3}}

%% parameters
\def\point{1}
\def\major{2}
\def\minor{0.8}

\begin{document}

\begin{pspicture}(-\width,-\height)(\width,\height)
  %% left
  % connections
  \psline{<->}%
    (-\calc{\major+1},\calc{\minor+1})%
    (-\point,\calc{\minor+1})%
    (-\point,-\calc{\minor+1})%
    (-\calc{\major+1},-\calc{\minor+1})
  \psline{->}(-\major,0)(-\calc{\major+1},0)
  % boxes with label
  \boxLabel(-\major-1.5,\minor+1){C}
  \boxLabel(-\major-1.5,0){F}
  \boxLabel(-\major-1.5,-\minor-1){D}
  %% right
  % connections
  \psline{<->}%
    (\calc{\major+1},\calc{\minor+1})%
    (\point,\calc{\minor+1})%
    (\point,-\calc{\minor+1})%
    (\calc{\major+1},-\calc{\minor+1})
  \psline{->}(\major,0)(\calc{\major+1},0)
  % boxes with label
  \boxLabel(\major+1.5,\minor+1){B}
  \boxLabel(\major+1.5,0){G}
  \boxLabel(\major+1.5,-\minor-1){E}
  %% ellipse
  \psellipse[fillstyle = solid](0,0)(\major,\minor)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
\end{pspicture}

\end{document}

The point of this solution is that the ellipse, which is filled with white, is drawn on top of the lines so that they don't need to start exactly at the border of the ellipse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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