沿扇区路径对齐文本

沿扇区路径对齐文本

我的组织中有 15 个部门,希望用 tikz 来表示所有部门,因此我将一个圆圈分成 15 个部分,希望标记每个部门的每个部门以及每个部门下的每个部门的单位。我现在想到了这一点:

%https://tex.stackexchange.com/questions/508078/speedometer-as-a-symbol-into-awesomebox
\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}

    \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}
    }]
    
        \draw[draw=white, fill = Cyan!70!ForestGreen!40!,thin] (114:5cm)-- (114:10cm) arc (114:90:10) -- (90:5cm) arc (90:114:5);% 15
        \draw[draw=white, fill = Cyan!70!Magenta!40!,thin] (138:5cm)-- (138:10cm) arc (138:114:10) -- (114:5cm) arc (114:138:5);% 14
        \draw[draw=white, fill = Cyan!70!ForestGreen!40!,thin] (162:5cm)-- (162:10cm) arc (162:138:10) -- (138:5cm) arc (138:162:5);% 13
        \draw[draw=white, fill = Cyan!40!YellowOrange!70!,thin] (186:5cm)-- (186:10cm) arc (186:162:10) -- (162:5cm) arc (162:186:5);% 12
        \draw[draw=white, fill = Magenta!70!ForestGreen!40!,thin] (210:5cm)-- (210:10cm) arc (210:186:10) -- (186:5cm) arc (186:210:5);% 11
        \draw[draw=white, fill = Cyan!70!ForestGreen!40!,thin] (234:5cm)-- (234:10cm) arc (234:210:10) -- (210:5cm) arc (210:234:5);% 10
        \draw[draw=white, fill = Cyan!40!ForestGreen!70!,thin] (258:5cm)-- (258:10cm) arc (258:234:10) -- (234:5cm) arc (234:258:5);% 09
        \draw[draw=white, fill = Cyan!70!ForestGreen!40!,thin] (282:5cm)-- (282:10cm) arc (282:258:10) -- (258:5cm) arc (258:282:5);% 08
        \draw[draw=white, fill = Cyan!70!,thin] (306:5cm)-- (306:10cm) arc (306:282:10) -- (282:5cm) arc (282:306:5);% 07
        \draw[draw=white, fill = Cyan!30!,thin] (330:5cm)-- (330:10cm) arc (330:306:10) -- (306:5cm) arc (306:330:5);% 06
        \draw[draw=white, fill = Cyan!130!,thin] (354:5cm)-- (354:10cm) arc (354:330:10) -- (330:5cm) arc (330:354:5);% 05
        \draw[draw=white, fill = ForestGreen!30!,thin] (378:5cm)-- (378:10cm) arc (378:354:10) -- (354:5cm) arc (354:378:5);% 04
        \draw[draw=white, fill = Cyan!70!YellowOrange!30!,thin] (402:5cm)-- (402:10cm) arc (402:378:10) -- (378:5cm) arc (378:402:5);% 03
        \draw[draw=white, fill = Cyan!30!YellowOrange!70!,thin] (426:5cm)-- (426:10cm) arc (426:402:10) -- (402:5cm) arc (402:426:5);% 02
        \draw[draw=white, fill = Cyan!30!ForestGreen!30!YellowOrange!30!,thin] (450:5cm)-- (450:10cm) arc (450:426:10) -- (426:5cm) arc (426:450:5);% 01
    
        % outer circle
        %\draw[line width=0.5 mm] circle[radius=4 cm];
        % outer circle
        \draw[draw=white,fill = gray!10,thick] circle[radius = 4.8cm];
        % outer circle
        \draw[draw=white,fill = gray!40,thick] circle[radius = 4.3cm];
        % outer circle
        \draw[draw=white,fill = gray!10,thick] circle[radius = 4cm];
    
    
        %Label1
        \draw[decoration={text along path,
            text={|\bfseries\large|Unit AAAAAAAAAAAAAA},text align={center}, raise=0.2cm}, decorate] (90:4.2cm) arc (90:45:4.2) -- (45:4.2cm) arc (45:0:4.2) -- (0:4.2cm) arc (0:-45:4.2) -- (-45:4.2cm) arc (-45:-90:4.2); 
        %%Label2
        %\draw[decoration={text along path,
            %text={|\bfseries\large|Unit BBBBBBBBBBBBBB},text align={center}, raise=0.2cm}, decorate] (135:4.2cm) arc (135:180:4.2) -- (180:4.2cm) arc (180:0:4.2) -- (0:4.2cm) arc (0:180:4.2) -- (180:4.2cm) arc (180:135:4.2);
    
    
    
    \end{tikzpicture}
\end{document}

产生这

我想要的是

我想要以下内容

  1. 我想写作Unit BBBBBBBBBBBBBBBBBB来面对相反的程度Unit AAAAAAAAAAAAAAA
  2. 我想写Dept-Adept-B...dept-O沿着每个部门和unit-1 unit-2每个部门。

就像这

编辑

我拜访了这里这里但无法将它们与我的情况联系起来。

再次编辑

我的部门名称如下:Goods,,,,,,,,,,,,,,,,,Gooder。每个部门下的单位不一定是两个,在某些情况下可能是一个,有的部门甚至可能没有单位,而Bike有的可能有两个以上。BikleAlbas siteaAdnine FryShirterAlbana taoOrger teaBlir shellOmini HO2TidyAdminAccount and WagesProcurement

答案1

以下是一个循环的尝试。您可以通过更改值foreach来修改第一个扇区的位置\Aorig

\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] \c in {Cyan!70!ForestGreen!40!, Cyan!70!Magenta!40!, Cyan!70!ForestGreen!40!, Cyan!40!YellowOrange!70!, Magenta!70!ForestGreen!40!, Cyan!70!ForestGreen!40!, Cyan!40!ForestGreen!70!, Cyan!70!ForestGreen!40!, Cyan!70!, Cyan!30!, Cyan!130!, ForestGreen!30!, Cyan!70!YellowOrange!30!, Cyan!30!YellowOrange!70!, Cyan!30!ForestGreen!30!YellowOrange!30!}
    {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:5cm)-- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10) -- (\Aorig-\xi*\Asector-\Asector:5cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:5);
      \draw[decoration={text along path,
        text={|\bfseries\large|{\parbox{4em}{\centering{\large\color{red} Dept \symbol{\numexpr64+\xi}}\\ Unit1\\ Unit 2}}},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){Dept \symbol{\numexpr64+\xi}\\ Unit 1\\ Unit2};
    }
    % inner circle
    \draw[draw=white,fill = gray!10,thick] circle[radius = 4.8cm];
    \draw[draw=white,fill = gray!40,thick] circle[radius = 4.3cm];
    \draw[draw=white,fill = gray!10,thick] circle[radius = 4cm];
    
    %Label1
    \draw[decoration={text along path, text={|\bfseries\large|Unit AAAAAAAAAAAAAA},text align={center}, raise=0.2cm}, decorate] (180:4.2cm) arc (180:0:4.2);
    %%Label2
    \draw[decoration={text along path, text={|\bfseries\large|Unit BBBBBBBBBBBBBB},text align={center}, raise=0.2cm}, decorate] (0:4.2cm) arc (0:-180:4.2);
  \end{tikzpicture}
\end{document}

在此处输入图片描述


编辑

为了确保单元 BBBBB 面向单元 AAAAA,您可以使用以下代码

\pgfmathsetmacro\uAAAangle{90}
\coordinate (uAAA) at (\uAAAangle:4.2cm);
        \draw[decoration={text along path, text={|\bfseries\large|Unit AAAAAAAAAAAAAA},text align={center}, raise=0.2cm}, decorate] (uAAA) arc (\uAAAangle:\uAAAangle-180:4.2);
        %%Label2
        \draw[decoration={text along path, text={|\bfseries\large|Unit BBBBBBBBBBBBBB},text align={center}, raise=0.2cm}, decorate] (\uAAAangle-180:4.2cm) arc (\uAAAangle-180:\uAAAangle-360:4.2);

编辑2

您可以在循环中使用额外的参数指定单位的名称(我不知道您是否需要更改部门标签):

\foreach[count=\xi] \c/\uI/\uII in {Cyan!70!ForestGreen!40!/U A 1/U A 2,
      Cyan!70!Magenta!40!/U B 1/U B 2,
      Cyan!70!ForestGreen!40!/U C 1/U C 2,
      Cyan!40!YellowOrange!70!/U D 1/U D 2,
      Magenta!70!ForestGreen!40!/U E 1/U E 2,
      Cyan!70!ForestGreen!40!/U F 1/U F 2,
      Cyan!40!ForestGreen!70!/U G 1/U G 2,
      Cyan!70!ForestGreen!40!/U H 1/U H 2,
      Cyan!70!/U I 1/U I 2,
      Cyan!30!/U J 1/U J 2,
      Cyan!130!/U K 1/U K 2,
      ForestGreen!30!/U L 1/U L 2,
      Cyan!70!YellowOrange!30!/U M 1/U M 2,
      Cyan!30!YellowOrange!70!/U N 1/U N 2,
      Cyan!30!ForestGreen!30!YellowOrange!30!/U O 1/U O 2}
    {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:5cm)-- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10) -- (\Aorig-\xi*\Asector-\Asector:5cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:5);
      \draw[decoration={text along path,
        text={|\bfseries\large|{\parbox{4em}{\centering{\large\color{red} Dept \symbol{\numexpr64+\xi}}\\ \uI\\ \uII}}},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){Dept \symbol{\numexpr64+\xi}\\ \uI\\ \uII};
    }

编辑3

考虑到先前的编辑和最后的 OP 愿望:

\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 {%
      Goods/Cyan!70!ForestGreen!40!/U A 1\\U A 2,
      Gooder/Cyan!70!Magenta!40!/U B 1,
      Bike/Cyan!70!ForestGreen!40!/,
      Bikle/Cyan!40!YellowOrange!70!/U D 1\\U D 2,
      Albas sitea/Magenta!70!ForestGreen!40!/U E 1,
      Adnine Fry/Cyan!70!ForestGreen!40!/,
      Shirter/Cyan!40!ForestGreen!70!/U G 1\\U G 2,
      Albana tao/Cyan!70!ForestGreen!40!/U H 1,
      Orger tea/Cyan!70!/,
      Blir shell/Cyan!30!/U J 1\\U J 2,
      Omini HO2/Cyan!130!/U K 1,
      Tidy/ForestGreen!30!/,
      Admin/Cyan!70!YellowOrange!30!/U M 1\\U M 2,
      Account and Wages/Cyan!30!YellowOrange!70!/U N 1,
      Procurement/Cyan!30!ForestGreen!30!YellowOrange!30!/}
    {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:5cm)-- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10) -- (\Aorig-\xi*\Asector-\Asector:5cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:5);
      \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 = 4.8cm];
    \draw[draw=white,fill = gray!40,thick] circle[radius = 4.3cm];
    \draw[draw=white,fill = gray!10,thick] circle[radius = 4cm];
    
    \pgfmathsetmacro\uAAAangle{90}
    \coordinate (uAAA) at (\uAAAangle:4.2cm);
    \draw[decoration={text along path, text={|\bfseries\large|Unit AAAAAAAAAAAAAA},text align={center}, raise=0.2cm}, decorate] (uAAA) arc (\uAAAangle:\uAAAangle-180:4.2);
    %%Label2
    \draw[decoration={text along path, text={|\bfseries\large|Unit BBBBBBBBBBBBBB},text align={center}, raise=0.2cm}, decorate] (\uAAAangle-180:4.2cm) arc (\uAAAangle-180:\uAAAangle-360:4.2);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容