2

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

But it did not work out for me especially for arrows. When connecting the arrows between nodes they cross each other. enter image description here Here is my code:

\documentclass[12pt]{article}
\usepackage{float} 
\usepackage{tikz}
\begin{document}


\begin{figure}[H] 
\centering
\begin{tikzpicture}
\begin{scope}[xshift=0cm,yshift=0cm]
\node (start) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (0,3) {Start};

\node (x1) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (4,4) {X1};
\node (x2) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (4,3) {X2};
\node (x3) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (4,2) {X3};

\node (y1) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (8,4) {Y1};
\node (y2) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (10,3) {Y2};
\node (y3) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (12,2) {Y3};

\node (end) [rectangle, rounded corners, minimum width=1.5cm, minimum height=0.5cm,text centered, draw=black, fill=gray!30] at (6,0) {END};

\draw[-latex] (start.east) -> (x1.west);
\draw[-latex] (start.east) -> (x2.west);
\draw[-latex] (start.east) -> (x3.west);

\draw[loosely dotted] (x1.east) -> (y1.west);
\draw[loosely dotted] (x2.east) -> (y2.west);
\draw[loosely dotted] (x3.east) -> (y3.west);


\draw[-latex] (y1.south) -> (y2.north);
\draw[-latex] (y1.south) -> (y3.north);
\draw[-latex] (y2.south) -> (y3.north);

\draw[densely dotted] (y1.south) -> (end.north);
\draw[densely dotted] (y2.south) -> (end.north);
\draw[densely dotted] (y3.south) -> (end.north);

\end{scope}
\end{tikzpicture}
\caption{Test.}
\label{test}
\end{figure}

\end{document}
  • What exactly is your question? How you can prevent arrows from crossing? But they also cross in the referenced picture! Also, the layout in your example is different, is this intentional? – pschulz Dec 5 '16 at 20:59
1

Redrawn your image with considering your nodes' style:

enter image description here

\documentclass[tikz,12pt,border=3mm]{standalone}
\usetikzlibrary{fit,positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance = 7mm and -3mm,
every node/.style = {draw=black, rounded corners, fill=gray!30, 
                     minimum width=2cm, minimum height=0.5cm,
                     align=center},
every path/.style = {draw, -latex}
                        ]
\node (start) {Start};
%
\node (y1) [below  left=of start]       {Y1}; 
\node (y2) [below right=of y1.east]     {Y2};
\node (y3) [below right=of y2.east]     {Y3};
%
\node (x1) [right=12mm of y3.east |- y1]{X1};
\node (x2) [right=12mm of y3.east |- y2]{X2};
\node (x3) [right=12mm of y3.east]      {X2};
%
\node (end) [below=21mm of y2 |- y3]    {END};
%
\node [dashed, fill=none, fit=(x1) (x3)] {};
%%
\draw   (start) -| (y1);
\draw   (start) -- (y2);
\draw   (start) -| (y3);
%
\draw   (x1) edge (y1)
        (x2) edge (y2)
        (x3)  to  (y3);
%
    \begin{scope}[densely dashed]
\draw   (y1) |- ([shift={(-5mm,9mm)}] end.north) -- ([xshift=-5mm] end.north);
\draw   (y2) -- (end);
\draw   (y3) |- ([shift={( 5mm,9mm)}] end.north) -- ([xshift= 5mm] end.north);
%
\draw   (y1 |- y2) -- (y2);
\draw[transform canvas={yshift= 1mm}]  (y1 |- y3) -- (y3);
\draw[transform canvas={yshift=-1mm}]  (y2 |- y3) -- (y3);
    \end{scope}
    \end{tikzpicture}
\end{document}

Nodes' style for all nodes are defined in tikzpicture options with every node/.style. For node positioning is used TikZ library positioning. Dashed line around nodes X is done by node with dashed line, in which are fitted nodes X.

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.