1

I took code previously posted here: Is there a way to make "sunburst charts" (multi-level pie charts) in LaTeX?

And I wanted to modify this for genealogy purposes. I have the setup I would like, but I am not sure how to modify the function such that I can have two lines of text for each arctext piece.

Can anyone help me to understand the function such that I can modify it for displaying two lines?

I think the "height" of the boxes is already coded and I can play with the function to adjust it for the size text accordingly.

Thanks.

\documentclass[border=5pt]{standalone}
\usepackage{xcolor}
\definecolor{orange1}{HTML}{F1753A}
\definecolor{orange2}{HTML}{F7A13E}
\definecolor{orange3}{HTML}{FC6300} 
\definecolor{root}{HTML}{B2B2B2}
\usepackage{tikz}
\usepackage{pgfmath}
\usetikzlibrary{decorations.text, arrows.meta,calc,shadows.blur,shadings}
\renewcommand*\familydefault{\sfdefault} % Set font to serif family

% arctext from Andrew code with modifications:
%Variables: 1: ID, 2:Style 3:box height 4: Radious 5:start-angl 6:end-angl 7:text {format along path} 
\def\arctext[#1][#2][#3](#4)(#5)(#6)#7{

\draw[
color=white,
thick,
line width=1.3pt,
fill=#2
]
(#5:#4cm+#3) coordinate (above #1) arc (#5:#6:#4cm+#3)
-- (#6:#4) coordinate (right #1) -- (#6:#4cm-#3) coordinate (below right #1) 
arc (#6:#5:#4cm-#3) coordinate (below #1)
-- (#5:#4) coordinate (left #1) -- cycle;
\def\a#1{#4cm+#3}
\def\b#1{#4cm-#3}
\path[
decoration={
    raise = -0.5ex, % Controls relavite text height position.
    text  along path,
    text = {#7},
    text align = center,        
},
decorate
]
(#5:#4) arc (#5:#6:#4);
}

%arcarrow, this is mine, for beerware purpose...
%Function: Draw an arrow from arctex coordinate specific nodes to another 
%Arrow start at the start of arctext box and could be shifted to change the position
%to avoid go over another box.
%Var: 1:Start coordinate 2:End coordinate 3:angle to shift from acrtext box  
\def\arcarrow[#1](#2)(#3)[#4]{
\draw[thick,-,>=latex,color=#1,line width=1pt,shorten >=-2pt, shorten <=-2pt] 
    let \p1 = (#2), \p2 = (#3), % To access cartesian coordinates x, and y.
        \n1 = {veclen(\x1,\y1)}, % Distance from the origin
        \n2 = {veclen(\x2,\y2)}, % Distance from the origin
        \n3 = {atan2(\y1,\x1)} % Angle where acrtext starts.
    in (\n3-#4: \n1) -- (\n3-#4: \n2); % Draw the arrow.
}

\begin{document}
\begin{tikzpicture}[
    % Environment Cfg
    font=\sf    \scriptsize,
    % Styles
    myarrow/.style={
        thick,
        -latex,
    },
    Center/.style ={
        circle,
        fill=white,
        text=root,
        align=center,
        font =\footnotesize,
        inner sep=1pt,          
    },
]

% Drawing the center
\node[Center](ROOT) at (0,0) {Test \\ Boy};

% Drawing the Tex Arcs

% \Arctext[ID][box-style][box-height](radious)(start-angl)(end-angl){|text-styles| Text}
% Node 1:  Father 
\arctext[N1][orange1][15pt](1.5)(180)(0){|\footnotesize\bf\color{white}| John Boy  B. 12 Jun 2016};

%Sub 1: Grandfather
\arctext[N1S1][orange1][13pt](2.5)(180)(90){|\footnotesize\bf\color{white}| Sub1};

    %Sub 1-Sub 1: Great Grandfather
    \arctext[N1S1S1][orange1][8pt](3.25)(180)(135){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N1S1S1S1][orange1][8pt](3.8)(180)(157.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N1S1S1S2][orange1][8pt](3.8)(157.5)(135){|\footnotesize\bf\color{white}| Sub1-Sub2}        

    %Sub 1-Sub 2: Great Grandmother
    \arctext[N1S1S2][orange1][8pt](3.25)(135)(90){|\footnotesize\bf\color{white}| Sub1-Sub2}

        %Sub 1-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N1S1S2S1][orange1][8pt](3.8)(135)(112.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N1S1S2S2][orange1][8pt](3.8)(112.5)(90){|\footnotesize\bf\color{white}| Sub1-Sub2} 


%Sub 2: Grandmother
\arctext[N1S2][orange1][13pt](2.5)(90)(0){|\footnotesize\bf\color{white}| Sub2};

        %Sub 2-Sub 1: Great Grandfather
    \arctext[N1S2S1][orange1][8pt](3.25)(90)(45){|\footnotesize\bf\color{white}| Sub2-Sub1};

        %Sub 2-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N1S2S1S1][orange1][8pt](3.8)(90)(67.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 2-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N1S2S1S2][orange1][8pt](3.8)(67.5)(45){|\footnotesize\bf\color{white}| Sub1-Sub2}  

    %Sub 2-Sub 2: Great Grandmother
            \arctext[N1S2S2][orange1][8pt](3.25)(45)(0){|\footnotesize\bf\color{white}| Sub2-Sub2};

        %Sub 2-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N1S2S2S1][orange1][8pt](3.8)(45)(22.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 2-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N1S2S2S2][orange1][8pt](3.8)(22.5)(0){|\footnotesize\bf\color{white}| Sub1-Sub2}   

\arctext[N2][orange2][15pt](1.5)(180)(360){|\footnotesize\bf\color{white}| John Boy B. 12 Jun 2016};

%Sub 1: Grandfather
\arctext[N2S1][orange2][13pt](2.5)(180)(270){|\footnotesize\bf\color{white}| Sub1};

    %Sub 1-Sub 1: Great Grandfather
    \arctext[N2S1S1][orange2][8pt](3.25)(180)(225){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N2S1S1S1][orange2][8pt](3.8)(180)(202.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N2S1S1S2][orange2][8pt](3.8)(202.5)(225){|\footnotesize\bf\color{white}| Sub1-Sub2}        

    %Sub 1-Sub 2: Great Grandmother
    \arctext[N2S1S2][orange2][8pt](3.25)(225)(270){|\footnotesize\bf\color{white}| Sub1-Sub2}

        %Sub 1-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N2S1S2S1][orange2][8pt](3.8)(225)(247.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 1-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N2S1S2S2][orange2][8pt](3.8)(247.5)(270){|\footnotesize\bf\color{white}| Sub1-Sub2}    


%Sub 2: Grandmother
\arctext[N2S2][orange2][13pt](2.5)(270)(360){|\footnotesize\bf\color{white}| Sub2};

        %Sub 2-Sub 1: Great Grandfather
    \arctext[N2S2S1][orange2][8pt](3.25)(270)(315){|\footnotesize\bf\color{white}| Sub2-Sub1};

        %Sub 2-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N2S2S1S1][orange2][8pt](3.8)(270)(292.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 2-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N2S2S1S2][orange2][8pt](3.8)(292.5)(315){|\footnotesize\bf\color{white}| Sub1-Sub2}    

    %Sub 2-Sub 2: Great Grandmother
            \arctext[N2S2S2][orange2][8pt](3.25)(315)(360){|\footnotesize\bf\color{white}| Sub2-Sub2};

        %Sub 2-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N2S2S2S1][orange2][8pt](3.8)(315)(337.5){|\footnotesize\bf\color{white}| Sub1-Sub1};

        %Sub 2-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N2S2S2S2][orange2][8pt](3.8)(337.5)(360){|\footnotesize\bf\color{white}| Sub1-Sub2}    

\end{tikzpicture}


\end{document}

Example from Code

Dakota
  • 45

2 Answers2

4

You can add an eighth argument to the \arctext macro, and then in the definition of it add a second \path with the text along path decoration. Modify the raise value, so they are placed one above the other, and possibly reduce the font size. Then instead of just \arctext...{one line of text}, use \arctext...{first line}{second line}.

Unrelated: I changed \sf and \bf to \sffamily and \bfseries respectively, as the shorter forms have been deprecated since the early 90s.

enter image description here

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\definecolor{orange1}{HTML}{F1753A}
\definecolor{orange2}{HTML}{F7A13E}
\definecolor{orange3}{HTML}{FC6300} 
\definecolor{root}{HTML}{B2B2B2}

\renewcommand*\familydefault{\sfdefault} % Set font to serif family

% arctext from Andrew code with modifications:
%Variables: 1: ID, 2:Style 3:box height 4: Radious 5:start-angl 6:end-angl 7:text {format along path} 
\def\arctext[#1][#2][#3](#4)(#5)(#6)#7#8{% <-- added #8 here

\draw[
color=white,
thick,
line width=1.3pt,
fill=#2
]
(#5:#4cm+#3) coordinate (above #1) arc (#5:#6:#4cm+#3)
-- (#6:#4) coordinate (right #1) -- (#6:#4cm-#3) coordinate (below right #1) 
arc (#6:#5:#4cm-#3) coordinate (below #1)
-- (#5:#4) coordinate (left #1) -- cycle;
\def\a#1{#4cm+#3}
\def\b#1{#4cm-#3}
\path[
decoration={
    raise = 0.1ex, % Controls relative text height position. <--- CHANGED
    text along path,
    text = {#7},
    text align = center,
    text color=white,
},
decorate
]
(#5:#4) arc (#5:#6:#4);

% added second path
\path[
decoration={
    raise = -0.9ex, % different value
    text along path,
    text = {#8}, % <-- #8 instead of #7
    text align = center,
    text color=white,
},
decorate
]
(#5:#4) arc (#5:#6:#4);
}

%arcarrow, this is mine, for beerware purpose...
%Function: Draw an arrow from arctex coordinate specific nodes to another 
%Arrow start at the start of arctext box and could be shifted to change the position
%to avoid go over another box.
%Var: 1:Start coordinate 2:End coordinate 3:angle to shift from acrtext box  
\def\arcarrow[#1](#2)(#3)[#4]{
\draw[thick,-,>=latex,color=#1,line width=1pt,shorten >=-2pt, shorten <=-2pt] 
    let \p1 = (#2), \p2 = (#3), % To access cartesian coordinates x, and y.
        \n1 = {veclen(\x1,\y1)}, % Distance from the origin
        \n2 = {veclen(\x2,\y2)}, % Distance from the origin
        \n3 = {atan2(\y1,\x1)} % Angle where acrtext starts.
    in (\n3-#4: \n1) -- (\n3-#4: \n2); % Draw the arrow.
}

\begin{document}
\begin{tikzpicture}[
    % Environment Cfg
    font=\sffamily\scriptsize,
    % Styles
    myarrow/.style={
        thick,
        -latex,
    },
    Center/.style ={
        circle,
        fill=white,
        text=root,
        align=center,
        font =\footnotesize,
        inner sep=1pt,          
    },
]

% Drawing the center
\node[Center](ROOT) at (0,0) {Test \\ Boy};

% Drawing the Tex Arcs

% \Arctext[ID][box-style][box-height](radious)(start-angl)(end-angl){|text-styles| Text}
% Node 1:  Father 
\arctext[N1][orange1][15pt](1.5)(180)(0){|\tiny\bfseries| John Boy  B. 12 Jun 2016}{|\tiny| foo bar baz};

%Sub 1: Grandfather
\arctext[N1S1][orange1][13pt](2.5)(180)(90){|\tiny\bfseries| Sub1}{|\tiny| foo bar baz};

    %Sub 1-Sub 1: Great Grandfather
    \arctext[N1S1S1][orange1][8pt](3.25)(180)(135){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N1S1S1S1][orange1][8pt](3.8)(180)(157.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N1S1S1S2][orange1][8pt](3.8)(157.5)(135){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}        

    %Sub 1-Sub 2: Great Grandmother
    \arctext[N1S1S2][orange1][8pt](3.25)(135)(90){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}

        %Sub 1-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N1S1S2S1][orange1][8pt](3.8)(135)(112.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N1S1S2S2][orange1][8pt](3.8)(112.5)(90){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}


%Sub 2: Grandmother
\arctext[N1S2][orange1][13pt](2.5)(90)(0){|\tiny\bfseries| Sub2}{|\tiny| foo bar baz};

        %Sub 2-Sub 1: Great Grandfather
    \arctext[N1S2S1][orange1][8pt](3.25)(90)(45){|\tiny\bfseries| Sub2-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N1S2S1S1][orange1][8pt](3.8)(90)(67.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N1S2S1S2][orange1][8pt](3.8)(67.5)(45){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}

    %Sub 2-Sub 2: Great Grandmother
            \arctext[N1S2S2][orange1][8pt](3.25)(45)(0){|\tiny\bfseries| Sub2-Sub2}{|\tiny| foo bar baz};

        %Sub 2-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N1S2S2S1][orange1][8pt](3.8)(45)(22.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N1S2S2S2][orange1][8pt](3.8)(22.5)(0){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz} 

\arctext[N2][orange2][15pt](1.5)(180)(360){|\tiny\bfseries| John Boy B. 12 Jun 2016}{|\tiny| foo bar baz};

%Sub 1: Grandfather
\arctext[N2S1][orange2][13pt](2.5)(180)(270){|\tiny\bfseries| Sub1}{|\tiny| foo bar baz};

    %Sub 1-Sub 1: Great Grandfather
    \arctext[N2S1S1][orange2][8pt](3.25)(180)(225){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N2S1S1S1][orange2][8pt](3.8)(180)(202.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N2S1S1S2][orange2][8pt](3.8)(202.5)(225){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}        

    %Sub 1-Sub 2: Great Grandmother
    \arctext[N2S1S2][orange2][8pt](3.25)(225)(270){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}

        %Sub 1-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N2S1S2S1][orange2][8pt](3.8)(225)(247.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 1-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N2S1S2S2][orange2][8pt](3.8)(247.5)(270){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}    


%Sub 2: Grandmother
\arctext[N2S2][orange2][13pt](2.5)(270)(360){|\tiny\bfseries| Sub2}{|\tiny| foo bar baz};

        %Sub 2-Sub 1: Great Grandfather
    \arctext[N2S2S1][orange2][8pt](3.25)(270)(315){|\tiny\bfseries| Sub2-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 1-Sub 1: Great-Great Grandfather
        \arctext[N2S2S1S1][orange2][8pt](3.8)(270)(292.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 1-Sub 2: Great-Great Grandmother
        \arctext[N2S2S1S2][orange2][8pt](3.8)(292.5)(315){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}    

    %Sub 2-Sub 2: Great Grandmother
            \arctext[N2S2S2][orange2][8pt](3.25)(315)(360){|\tiny\bfseries| Sub2-Sub2}{|\tiny| foo bar baz};

        %Sub 2-Sub 2-Sub 1: Great-Great Grandfather
        \arctext[N2S2S2S1][orange2][8pt](3.8)(315)(337.5){|\tiny\bfseries| Sub1-Sub1}{|\tiny| foo bar baz};

        %Sub 2-Sub 2-Sub 2: Great-Great Grandmother
        \arctext[N2S2S2S2][orange2][8pt](3.8)(337.5)(360){|\tiny\bfseries| Sub1-Sub2}{|\tiny| foo bar baz}    

\end{tikzpicture}


\end{document}
Torbjørn T.
  • 206,688
1

The answer below uses the wheelchart package, which I wrote.

The text in the arcs is given by the first and second variable, which are denoted by \WCvarA and \WCvarB. These are used in the key arc data. Here, \\ can be used to split the text over multiple lines.

The direction of this text depends on the angle of the middle of the arc given by \WCmidangle which is used in the key arc data dir.

This text is centered in the arc with the key arc data pos=0.5.

The gaps between the slices are obtained with the keys gap and gap radius.

enter image description here

\documentclass[border=6pt]{standalone}
\usepackage{listofitems}
\usepackage{wheelchart}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\sffamily
\readlist\WCcolors{orange!75,orange}
\pgfkeys{
  /wheelchart,
  arc data=\WCvarA\\\WCvarB,
  arc data dir={\WCmidangle<180?1:-1},
  arc data expand=f,
  arc data pos=0.5,
  arc data style={text color=white},
  data=,
  gap,
  gap radius,
  slices style=\WCcolors[\fpeval{\WCmidangle<180?2:1}],
  start angle=0,
  value=1
}
\wheelchart[
  middle=Test\\Boy,
  middle style=darkgray,
  radius={1}{2}
]{%
  John Boy A. 12 Jun 2016/Text A,
  John Boy B. 23 Sep 2023/Text B%
}
\wheelchart{%
  Sub1/Text1,
  Sub2/Text2,
  Sub3/Text3,
  Sub4/Text4%
}
\end{tikzpicture}
\end{document}
matexmatics
  • 4,819