# Insert text in a pie chart

I try to insert text in nodes and need help. How to fix the placement of each text ? Thanks

\documentclass[border=10pt]{standalone}%{article}
%\usepackage[papers=30cm,paperwidth=35cm,margin=1in,heightrounded]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\thispagestyle{empty}
\fbox{\begin{tikzpicture}[scale=0.2] % pour rester dans la page
% center
\path  (0,0) coordinate(A);
% circles
\foreach \rr in {12,...,25}{
\draw  (A) circle (\rr);
}
\def\pp{4} % nb of slices
% Assume the percentage is 20,10,20,10 respectively for the 4 slice
\foreach \aa in {0,20,30,50,60}{
\draw ($(A)+({\aa*36/10}:12)$) --  ($(A)+({\aa*36/10}:25)$);
}
Insert text
\draw ($(A)+(0/\pp*360+60.5:18)$) node[rotate=(100/\pp*60)]{\textcolor{blue}{long text1}};
\draw ($(A)+(0/\pp*360+50.5:21.5)$) node[rotate=(120/\pp*70)]{long text };
\draw ($(A)+(0/\pp*360+40.5:21.5)$) node[rotate=(120/\pp*70)]{\textcolor{red}{long text}};
\draw ($(A)+(0/\pp*360+30.5:21.5)$) node[rotate=(120/\pp*70)]{\textcolor{yellow}{long text}};
\draw ($(A)+(0/\pp*360+20.5:21.5)$) node[rotate=(120/\pp*70)]{\textcolor{blue}{long text}};

\end{tikzpicture}}
\end{document}


-
I added the resulting picture. It is obvious that the text is not correctly placed, but it is less obvious where it should be... –  JLDiaz May 15 at 21:25
It should be in the same slice in which the words appear but in the different rows. –  heidi May 15 at 21:27
Then use different distances to the center. The distance is the part after the colon, which is 21.5 for all your nodes in your case (except for the blue rotated one). I guess you may be interested too in make the text follow the circle, but this requires the use of decorations, and the syntax is clumsy (see tex.stackexchange.com/questions/22314/…) –  JLDiaz May 15 at 21:29
yes but I don't know how. I really need help. –  heidi May 15 at 21:36
@heidi Please review the answers you got to your other questions. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Jubobs May 15 at 22:11

I coded a macro (\curvedtext) which can help you to get the job done. The macro draws the text "curved" following the appropriate arc. It receives four arguments:

1. The angle at which the center of the text has to be located
2. The distance from the center of the circle to the center of the text
3. The color of the text
4. The text

See the following example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.text}
\begin{document}

\def\curvedtext#1#2#3#4{%
\path[decorate, decoration={text along path, text align=center, text={|\color{#3}\small|#4}}]
($(A)+(#1+20:#2)$) arc (#1+20:#1-20:#2);
}

\fbox{\begin{tikzpicture}[scale=0.2] % pour rester dans la page
% center
\path  (0,0) coordinate(A);
% circles
\foreach \rr in {12,...,25}{
\draw  (A) circle (\rr);
}
\def\pp{4} % nb of slices
% Assume the percentage is 20,10,20,10 respectively for the 4 slice
\foreach \aa in {0,20,30,50,60}{
\draw ($(A)+({\aa*36/10}:12)$) --  ($(A)+({\aa*36/10}:25)$);
}

\curvedtext{50.5}{21}{blue}{long text};
\curvedtext{40.5}{20}{red}{longer text};
\curvedtext{30.5}{19}{green!60!black}{even longer text};
\end{tikzpicture}}
\end{document}


Result:

-
Is any way to start the text closer to left ray ? –  heidi May 15 at 22:46
Thank you very much. Everything is fine now. –  heidi May 15 at 22:55
@heidi Here the accept way of saying thank you is to accept an answer by clicking on the check mark below the answers score. In all of your previous questions, you never accepted an answer. –  Sergio Parreiras May 17 at 4:07