0

I am trying to draw a tree horizontal tree diagram with one node's level, this tree has 13 nodes so I want to make use of the space by spanning nodes on both sides (left and right) instead of the current view.

\usepackage{tikz}
\usetikzlibrary{trees,positioning,shapes,shadows,arrows}
\begin{figure}
    \centering
    \begin{tikzpicture}[
every node/.style = {draw, rounded corners, fill=red!30,
    text width=18mm, minimum height=9mm, align=center,
    drop shadow},
             grow = right,
growth parent anchor=east,
level distance = 27mm,
sibling distance=10mm,
edge from parent path=(\tikzparentnode.east) -- (\tikzchildnode.west)
                        ]

% root of the the initial tree, level 1 \node[root] {\textbf{\textarabic{البرمجة كائنية التوجه}}} % The first level, as children of the initial tree child {node[level-2] (c1) {\textbf{OOP}}} child {node[level-2] (c2) {\textbf{\textarabic{برمجة كائنية}}}} child {node[level-2] (c3) {\textbf{\textarabic{البرمجة كائنية التوجيه}}}} child {node[level-2] (c4) {\textbf{\textarabic{برمجة كانئية المنحى}}}} child {node[level-2] (c5) {\textbf{\textarabic{البرمجة كائنية التوجه}}}} child {node[level-2] (c6) {\textbf{\textarabic{برمجة كائنات موجهة}}}} child {node[level-2] (c7) {\textbf{\textarabic{شيئية المنحى}}}} child {node[level-2] (c8) {\textbf{\textarabic{برمجة كانئية المنحنى}}}} child {node[level-2] (c9) {\textbf{\textarabic{البرمجة الشيئية}}}} child {node[level-2] (c10) {\textbf{\textarabic{برمجه كائنيه التوجه}}}} child {node[level-2] (c11) {\textbf{\textarabic{برمجة غرضية التوجه}}}} child {node[level-2] (c12) {\textbf{\textarabic{برمجة موجهة}}}}
child {node[level-2] (c13) {\textbf{\textarabic{برمجة شيئية}}}}; \end{tikzpicture} \caption{Aliases for Object-Oriented Programming \href{https://www.wikidata.org/wiki/Q79872}{Q79872} in Wikidata in the Arabic language.} \label{ne_aliasies} \end{figure}

The output view of the above code is: enter image description here

What I want is something like this: enter image description here

Mai
  • 87
  • @SebGlav thanks for your comment, I tried to apply the solution in the link but it does not work for me, If it is possible to apply some changes on the above code it will be easier for me – Mai Jan 06 '22 at 14:28
  • In the above code, you specify grow=right into the tikpicture definition, so you can't expect to add anything growing left automatically afterwards. You will have to build it from your root node, growing left. And not related, but you didn't specify neither the fork edges, nor the level styles (root and level-2). – SebGlav Jan 06 '22 at 15:39

1 Answers1

0

Here's what is the closest to what you expect, imho, using your original design, but with a bit of cleaning. Feel free to adapt it to your very needs.

Tree growing both left and right

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{trees,positioning,shapes,shadows,arrows.meta}

\begin{document}

\begin{tikzpicture}[
    every node/.style = {
        draw,
        rounded corners,
        fill=red!30,
        text width=18mm,
        minimum height=9mm,
        align=center,
        drop shadow},
    >=Stealth,
    level distance = 30mm,
    sibling distance=13mm]

    \begin{scope}[grow'=right,edge from parent fork right,->]
        \node (root) at (0,0) {}
            child  {node (b1) {B1}}
            child  {node (b2) {B2}}
            child  {node (b3) {B3}};
     \end{scope}
     \begin{scope}[grow=left,edge from parent fork left,->]
        \node (root) at (0,0) {ROOT}
            child  {node (a1) {A1}}
            child  {node (a2) {A2}}
            child  {node (a3) {A3}};
         \end{scope}            
\end{tikzpicture}

\end{document}

SebGlav
  • 19,186