I want to create a pie chart with labels (one blank an one with percentage for the teacher, the mwe is the teachers version) so that my students have to fill the percentage in by themselves.
So far I created a pie chart using the code given in the answer here
and then I used labels from the code given in the answer here
Now I have this
The node in the violett part is the one I created manually and the other ones are implemented in the code, but I don't know what to change so that the automatic generated ones look like the one I created manually
My MWE
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\definecolor{rosso}{RGB}{220,57,18}
\definecolor{giallo}{RGB}{255,153,0}
\definecolor{blu}{RGB}{102,140,217}
\definecolor{verde}{RGB}{16,150,24}
\definecolor{viola}{RGB}{153,0,153}
\makeatletter
\tikzstyle{chart}=[
legend label/.style={font={\scriptsize},anchor=west,align=left},
legend box/.style={rectangle, draw, minimum size=5pt},
axis/.style={black,semithick,->},
axis label/.style={anchor=east,font={\tiny}},
]
\tikzstyle{pie chart}=[
chart,
slice/.style={line cap=round, line join=round, very thick,draw=white},
pie title/.style={font={\bf}},
slice type/.style 2 args={
##1/.style={fill=##2},
values of ##1/.style={}
}
]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\pie}[3][]{
\begin{scope}[#1]
\pgfmathsetmacro{\curA}{90}
\pgfmathsetmacro{\r}{1}
\def\c{(0,0)}
\node[pie title] at (90:1.3) {#2};
\foreach \v/\s in{#3}{
\pgfmathsetmacro{\deltaA}{\v/100*360}
\pgfmathsetmacro{\nextA}{\curA + \deltaA}
\pgfmathsetmacro{\midA}{(\curA+\nextA)/2}
\path[slice,\s] \c
-- +(\curA:\r)
arc (\curA:\nextA:\r)
-- cycle;
\pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) ,1)}
\begin{pgfonlayer}{foreground}
\draw[*-,thin] \c -- (\midA:\r) node[above,near end, pos=\d,pie values,values of \s]{$\v\%$};
\end{pgfonlayer}
\global\let\curA\nextA
}
\end{scope}
}
\newcommand{\legend}[2][]{
\begin{scope}[#1]
\path
\foreach \n/\s in {#2}
{
++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
}
;
\end{scope}
}
\begin{document}
\begin{tikzpicture}
[
pie chart,
slice type={comet}{blu},
slice type={legno}{rosso},
slice type={coltello}{giallo},
slice type={sedia}{viola},
slice type={caffe}{verde},
pie values/.style={font={\small}},
scale=2
]
\pie{Sommerjobs in Österreich}{52/comet,12/legno,20/sedia,16/coltello}
\legend[shift={(-1cm,-1cm)}]{{Eisverkäufer}/comet, {Schwimmbad}/legno, {Zettelverteiler}/coltello}
\legend[shift={(1cm,-1cm)}]{{Kellner}/sedia}
\draw [*-,thin] (0.6,-0.2) -- (0.7,-0.2 + 0.5ex) -- (2,0.5ex) node[above, near end]{20\%};
\end{tikzpicture}
\end{document}