4

I have five nodes defined and positioned as following:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}
    \begin{figure}[!htb]
        \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
            block/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=4em},
            bloc/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
            store/.style={cylinder, draw, shape border rotate=90, aspect=0.4, minimum height=1.5cm, minimum width=1.2cm, fill=cyan!23},
            dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt},
            blob/.style={cloud, draw, cloud puffs=17.8, cloud ignores aspect, minimum width=4cm, minimum height=2.5cm, align=center},
            link/.style={latex-latex, shorten <=8pt, shorten >=1pt}]
            % Place nodes
            \node [title] (backend) at (5.5,10.05) {Sample};
            \node [block, outer sep=5pt, align=center] (server3) at (3.7,6.75) {Component A};
            \node [block, outer sep=5pt, align=center] (server1) at (7.15,9.0) {Component B\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server2) at (7.15,7.45) {Component C\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server4) at (7.15,5.9) {Component D\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server5) at (7.15,4.35) {Component E\\(Blah)};
            \node [draw=black!50, fit={(backend) (server1) (server2) (server3) (server4) (server5)}] (sample) {};
        \end{tikzpicture}
        \caption{A Test Graph}
    \end{figure}
\end{document}

I want to make float-chart-style arrows between Component A and the other four nodes, and I want them look like in the answer to this question: Horizontal hierarchy tree in tikz-qtree: bad layout for longer node-names, but with arrow heads at both ends. In other words, ignoring other parts, replace nice-child0 with Component A, and grandchild0-0-grandchild0-3 with Component B-Component E in my example.

Is there any way to do this without using the tree packages?

3

Something like this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}

\begin{document}
    \begin{figure}[!htb]
\centering
        \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
            block/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=4em},
            bloc/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
            store/.style={cylinder, draw, shape border rotate=90, aspect=0.4, minimum height=1.5cm, minimum width=1.2cm, fill=cyan!23},
            dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt},
            blob/.style={cloud, draw, cloud puffs=17.8, cloud ignores aspect, minimum width=4cm, minimum height=2.5cm, align=center},
            link/.style={latex-latex, shorten <=8pt, shorten >=1pt}]
            % Place nodes
            \node [title] (backend) at (5.5,10.05) {Sample};
            \node [block, outer sep=5pt, align=center] (server3) at (3.7,6.75) {Component A};
            \node [block, outer sep=5pt, align=center] (server1) at (7.15,9.0) {Component B\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server2) at (7.15,7.45) {Component C\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server4) at (7.15,5.9) {Component D\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server5) at (7.15,4.35) {Component E\\(Blah)};
            \node [draw=black!50, fit={(backend) (server1) (server2) (server3) (server4) (server5)}] (sample) {};

\foreach \i in {1,2,4,5}
  \draw[<->] (server3.east) -- +(10pt,0) |- (server\i.west);
        \end{tikzpicture}
        \caption{A Test Graph}
    \end{figure}
\end{document}

enter image description here

Instead of "manually" adding 10pt to the x-coordinate in

 \foreach \i in {1,2,4,5}
  \draw[<->] (server3.east) -- +(10pt,0) |- (server\i.west);

one can use

\foreach \i in {1,2,4,5}
  \draw[<->] let \p1= (server2.west|-server3.east) in 
    (server3.east) -- +( $ 0.5*(\x1,\y1) - 0.5*(server3.east) $ ) |- (server\i.west);

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.