1

What I Want

  1. I want the texts to be within each sector and not beyond.
  2. I want the texts to align at the top and not at the centre.

What I Have

Here is what I have

\documentclass[border=1cm]{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{newtxtext}
\usepackage{tikz}
\usetikzlibrary{decorations.text, fadings}
\tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!5]

\tikzset{ figNode/.style={ path picture={ \node at (path picture bounding box.center) {#1};}} } \usepackage[OT2, OT1]{fontenc} \begin{document} \pgfmathsetmacro\Nsector{15} \pgfmathsetmacro\Asector{360/\Nsector} \pgfmathsetmacro\Aorig{30}

\begin{tikzpicture}[font=\large, main/.style = {draw, circle, text=black,  
        preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 100 percent, opacity=0.25}
    }]
    \foreach[count=\xi] \dpt/\c/\uI in {%
        Human Resurce Mgt/Cyan!70!ForestGreen!40!/App Pro \& Disc\\Training \& Welfare,
        Gen. Service/Cyan!70!Magenta!40!/Gen. Service\\ Maintainance,
        Finance/Cyan!70!ForestGreen!40!/Exp\\ Budget\\ Revenue\\ Financial \& Fiscal Reporting,
        Legal Services \& Board Affair/Cyan!40!YellowOrange!70!/Legal Services\\Board Affairs,
        Comm \& Public Relation/Magenta!70!ForestGreen!40!/Communication\\ Public Affairs,
        Information Communication Tech/Cyan!70!ForestGreen!40!/Sys Prog \& Magtm\\Data Processing \& Analysis\\ Hardware \& Networking,
        Feild Services \& and Method./Cyan!40!ForestGreen!70!/Feild Services\\Methodology,
        National Acc Energy  \& Environment/Cyan!70!ForestGreen!40!/National Account\\ Energy \& Environment,
        Corperate Planning \& Statistical Coordination/Cyan!70!/Corperate Planning \\ Statistical Coordination,
        Agric \& Biz Enter/Cyan!30!/Agric Statistics\\Biz Enterprice,
        Trade \& Prices/Cyan!130!/Trade\\Prices,
        Gender \& Social Stat/ForestGreen!30!/Gender \& Social Inclusion\\Social Stat,
        Intl Statistical Devpt/Cyan!70!YellowOrange!30!/Donor Coordination\\Intl Action Plan,
        Demo \& HH Stat/Cyan!30!YellowOrange!70!/Demographics\\Household,
        Procurement/Cyan!30!ForestGreen!30!YellowOrange!30!/Procurement Plans\\Tender Advertisement
    }
    {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:3cm)-- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10) -- (\Aorig-\xi*\Asector-\Asector:3cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:3);
        \draw[decoration={text along path,
            text={|\bfseries\large|{\parbox{4em}{\centering{\large\color{red} \dpt}\\ \uI}}},text align={center}, raise=-1.2cm}, decorate] (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10);
        % or with
        %\node [align=center] at (\Aorig-\xi*\Asector-.5*\Asector:6.5cm){\dpt\\ \uI};
    }
    % inner circle
    \draw[draw=white,fill = gray!10,thick] circle[radius = 2.8cm];
    \draw[draw=white,fill = gray!40,thick] circle[radius = 2.3cm];
    \draw[draw=white,fill = gray!10,thick] circle[radius = 2cm];

    \pgfmathsetmacro\uAAAangle{90}
    \coordinate (uAAA) at (\uAAAangle:2.2cm);
    \draw[decoration={text along path, text={|\bfseries\large|Internal Audit},text align={center}, raise=0.2cm}, decorate] (uAAA) arc (\uAAAangle:\uAAAangle-180:2.2);
    %%Label2
    \draw[decoration={text along path, text={|\bfseries\large|Economic Intelligence Unit},text align={center}, raise=0.2cm}, decorate] (\uAAAangle-180:2.2cm) arc (\uAAAangle-180:\uAAAangle-360:2.2);
\end{tikzpicture}

\end{document}

  • May be this one from the Related section provides some insight https://tex.stackexchange.com/questions/311028/aligning-text-along-a-sector-of-a-circle?rq=1 ? – MS-SPO Jun 11 '22 at 11:31
  • I tried to make this look like the output of the link you paste here but I got no different output. Can you please help? – Daniel James Jun 11 '22 at 13:21
  • Ok, but it will take a while. What I recognized is a kind of "less code" in the link. May be some of your statements used "step on each other"? We'll see. – MS-SPO Jun 11 '22 at 13:28
  • Ok, I will wit for it. – Daniel James Jun 11 '22 at 13:30

2 Answers2

3

What you need to do is to align the \parboxes which you use to place the text, so that they are all aligned at the top. This can be done using the optional arguments: \parbox[t][][t]{4em}.

To achieve optimal placement, I further adjusted the value of the raise option and added a few hyphenation points in the text in the nodes.

Finally, I optimised your code a bit to make it more readable and more straightforward.

\documentclass[border=1cm]{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{newtxtext}
\usepackage{tikz}
\usetikzlibrary{decorations.text, fadings}
\tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!5]

\tikzset{ figNode/.style={ path picture={ \node at (path picture bounding box.center) {#1};}} } \usepackage[OT2, OT1]{fontenc} \begin{document} \pgfmathsetmacro\Nsector{15} \pgfmathsetmacro\Asector{360/\Nsector} \pgfmathsetmacro\Aorig{30}

\begin{tikzpicture}[font=\large, main/.style = {draw, circle, text=black,  
        preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 100 percent, opacity=0.25}
    }]
    \foreach[count=\xi] \dpt/\c/\uI in {%
        Human Resurce Mgt/Cyan!70!ForestGreen!40!/App Pro \& Disc\\Training \& Welfare,
        Gen. Service/Cyan!70!Magenta!40!/Gen. Service\\ Main\-tainance,
        Finance/Cyan!70!ForestGreen!40!/Exp\\ Budget\\ Revenue\\ Financial \& Fiscal Reporting,
        Legal Services \& Board Affair/Cyan!40!YellowOrange!70!/Legal Services\\Board Affairs,
        Comm \& Public Relation/Magenta!70!ForestGreen!40!/Communi\-cation\\ Public Affairs,
        Information Communication Tech/Cyan!70!ForestGreen!40!/Sys Prog \& Magtm\\Data Processing \& Analysis\\ Hardware \& Net-\\working,
        Feild Services \& and Method./Cyan!40!ForestGreen!70!/Feild Services\\Methodo\-logy,
        National Acc Energy  \& Environment/Cyan!70!ForestGreen!40!/National Account\\ Energy \& Environment,
        Corperate Planning \& Statistical Coordination/Cyan!70!/Corperate Planning \\ Statistical Coordination,
        Agric \& Biz Enter/Cyan!30!/Agric Statistics\\Biz Enterprice,
        Trade \& Prices/Cyan!130!/Trade\\Prices,
        Gender \& Social Stat/ForestGreen!30!/Gender \& Social Inclusion\\Social Stat,
        Intl Statistical Devpt/Cyan!70!YellowOrange!30!/Donor Coordination\\Intl Action Plan,
        Demo \& HH Stat/Cyan!30!YellowOrange!70!/Demo\-graphics\\Household,
        Procurement/Cyan!30!ForestGreen!30!YellowOrange!30!/Procurement Plans\\Tender Advertisement
    }
    {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:3cm) -- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10cm) -- (\Aorig-\xi*\Asector-\Asector:3cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:3cm);
    \draw[decoration={text along path,
        text={|\bfseries\large|{\parbox[t][][t]{5em}{\centering{\large\color{red} \dpt}\\ \uI}}},text align={center}, raise=-.9cm}, decorate] (\Aorig-\xi*\Asector:10cm) -- (\Aorig-\xi*\Asector-\Asector:10cm);
}
    % inner circle
    \draw[draw=white,fill = gray!10,thick] circle[radius = 2.8cm];
    \draw[draw=white,fill = gray!40,thick] circle[radius = 2.3cm];
    \draw[draw=white,fill = gray!10,thick] circle[radius = 2cm];

    \pgfmathsetmacro\uAAAangle{90}
    \coordinate (uAAA) at (\uAAAangle:2.2cm);
    \draw[decoration={text along path, text={|\bfseries\large|Internal Audit},text align={center}, raise=0.2cm}, decorate] (uAAA) arc (\uAAAangle:\uAAAangle-180:2.2);
    %%Label2
    \draw[decoration={text along path, text={|\bfseries\large|Economic Intelligence Unit},text align={center}, raise=0.2cm}, decorate] (\uAAAangle-180:2.2cm) arc (\uAAAangle-180:\uAAAangle-360:2.2);
\end{tikzpicture}

\end{document}

enter image description here

2

Ok, after the analysis, to localize the problem of your text alignments, here's a study for a solution concept, which would replace the decoration approach.

Observations: Though you establish an arc for a circular text-path, you don't seem to use it to flex text, so to say. Rather, you use a rectangle via \parbox. Looking at your result, a rectangle of the same size seems to fit all sectors. So let's look for a possible tikz-solution. Moreover, I didn't find ways to confine text to an arbitrarily shaped boundary, like a pie or segment presents.

Here we go: I show you the basic steps, of one way to do it, and from your code I think you can adapt it easily into your foreach loop. Basic ideas: place and rotate \nodes; to account for text color, use a split rectangular shape; position by polar coordinates, rotate each text node as needed.

P.S.: Perhaps you should include package babel, which handles hyphenation for you, once you indicate the language. // Certainly one will move the split options into the generic style nd.

example of implemented concept

\documentclass[10pt, border=3.14mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}% needed to draw two rectangles on top of each other

\begin{document}

\tikz [nd/.style={
        text width=0.64cm,% max. width of text; finetune as needed
        node font=\tiny,% font size of node text
        align=center,% centered node text
        anchor=north% this is "top middle" you were missing, so to say
        }
      ] {

    % --- to visualize the center ------------                      
    \node [fill=red] at (0,0) {x};      

    % --- placing the first node -------------
    \node [nd, rectangle split, rectangle split parts=2,% 2 stacked rectangles
           rotate=-90,% rotate the node and its text
           red% text color, will be your \dpt-col
           ] at (0:3cm)% using polar coordinates
    {
        0 Some text% this text will be in [red]
        \nodepart[black]{two}% reset text color to black, lower rectangle
        more text
        and even much more text% just type ahead without \\
    };

    % --- next node --------------
    % --- you need to calculate the required rotation angle for the node text yourself
    \node [nd, rectangle split, rectangle split parts=2, rotate=30,  red] at (120:3cm)
    {
        120 Some text
        \nodepart[blue]{two}
        more text
        and even 
    };

    % --- final node ---------------------------
    \node [nd, rectangle split, rectangle split parts=2, rotate=150,  red] at (-120:3cm)
    {
        -120 Some text
        \nodepart[green]{two}
        more text
        and even 
        and much much more text
    };

    % --- the 3 gray beams for reference ------------------
    \draw [draw=gray] (0,0) -- (0:4cm);
    \draw [draw=gray] (0,0) -- (120:4cm);
    \draw [draw=gray] (0,0) -- (-120:4cm);
}

\end{document}

MS-SPO
  • 11,519