4

I was using a template TikZcode to create the below diagram. enter image description here

here is the code:

\documentclass[border=2mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
%\newcommand{\cc}{c\nolinebreak\hspace{-.05em}\raisebox{.2ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.2ex}{\tiny\bf +}}

\newcommand{\vardonut}[1]{
\newcounter{num}
\foreach \content/\size/\colour in {#1}
    \stepcounter{num};
\foreach \content/\size/\colour [count=\i] in {#1}{
    \draw[white,very thick,top color=\colour!80!black, bottom color=\colour, shading angle={-90+360/\thenum/2+(\i-1)*360/\thenum}] 
    ({2*cos((\i-1)*360/\thenum)},{2*sin((\i-1)*360/\thenum)}) arc[radius = 2, start angle={(\i-1)*360/\thenum}, delta angle=360/\thenum] --
    ({(2+\size)*cos(\i*360/\thenum)},{(2+\size)*sin(\i*360/\thenum)}) arc[radius = {2+\size}, start angle={\i*360/\thenum}, delta angle=-360/\thenum] -- 
    cycle;
    \node[Black,font=\Large] at ({(\i-1)*360/\thenum+360/\thenum/2}:{\size/2+2}) {\content  };
 }
}

\begin{document}
\begin{tikzpicture}[every text node part/.style={align=center}]
    \vardonut{AAAAAA\small({bbbbbbb})/6/YellowOrange!50!, CCCCCCC/5/Salmon, DDDDDD/2/SkyBlue!50!, EEEEEE/2/Aquamarine,FFFFFF/5/Yellow, GGGGGG\textsuperscript{\textregistered} \small{Notes}/4/Magenta!50!, HHH/2/Apricot,  \large{III }/3/ForestGreen!50!,JJJJ/6/Cyan,\LaTeX/6/Yellow}

\end{tikzpicture}
\end{document}    

How can I change the textangle and direction from the centre to outer and make the text in 2 lines in case of using long text?

Shahram
  • 85

2 Answers2

2

The wheelchart package, which I wrote, can be used.

The outer radius is determined by the first variable, denoted by \WCvarA. Initially, \WCvarA is used for the key value. This initial setting is overruled by setting value=1.

Note that in the question, there is \small{Notes}. It is better to write {\small Notes}, as explained for example on \bfseries bolds more than intended.

enter image description here

\documentclass[border=6pt,dvipsnames]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\wheelchart[
  counterclockwise,
  data=,
  gap=0.02,
  radius={1}{\WCvarA},
  slices style={
    bottom color=\WCvarB,
    top color={\WCvarB!80!black},
    shading angle={\WCmidangle-90}
  },
  start angle=0,
  value=1,
  wheel data=\WCvarC,
  wheel data pos=0.5,
  wheel data style={rotate=\WCmidangle}
]{%
  6/YellowOrange!50!/AAA AAA\\{\small(bbbbbbb)},
  5/Salmon/CCCC\\CCC,
  2/SkyBlue!50!/DDD\\DDD,
  2/Aquamarine/EEE\\EEE,
  5/Yellow/FFF\\FFF,
  4/Magenta!50!/GGG\\GGG\textsuperscript{\textregistered}\\{\small Notes},
  2/Apricot/HHH,
  3/ForestGreen!50!/{\large III},
  6/Cyan/JJJJ,
  6/Yellow/\LaTeX%
}
\end{tikzpicture}
\end{document}
matexmatics
  • 4,819
1

Something like this?

\documentclass[border=2mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
%\newcommand{\cc}{c\nolinebreak\hspace{-.05em}\raisebox{.2ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.2ex}{\tiny\bf +}}

\newcommand{\vardonut}[1]{
\newcounter{num}
\foreach \content/\size/\colour in {#1}
    \stepcounter{num};
\foreach \content/\size/\colour [count=\i] in {#1}{
    \draw[white,very thick,top color=\colour!80!black, bottom color=\colour, shading angle={-90+360/\thenum/2+(\i-1)*360/\thenum}] 
    ({2*cos((\i-1)*360/\thenum)},{2*sin((\i-1)*360/\thenum)}) arc[radius = 2, start angle={(\i-1)*360/\thenum}, delta angle=360/\thenum] --
    ({(2+\size)*cos(\i*360/\thenum)},{(2+\size)*sin(\i*360/\thenum)}) arc[radius = {2+\size}, start angle={\i*360/\thenum}, delta angle=-360/\thenum] -- 
    cycle;
    \node[Black,font=\Large,rotate=(\i-1)*360/\thenum+360/\thenum/2,text
    width=0.8*\size cm,align=left,anchor=west] at
    ({(\i-1)*360/\thenum+360/\thenum/2}:{2}) {\content  };
 }
}

\begin{document}
\begin{tikzpicture}[every text node part/.style={align=center}]
    \vardonut{AAA AAA\small({bbbbbbb})/6/YellowOrange!50!, CCCC CCC/5/Salmon,
    DDD DDD/2/SkyBlue!50!, EEE EEE/2/Aquamarine,FFFFFF/5/Yellow, GGG GGG\textsuperscript{\textregistered} \small{Notes}/4/Magenta!50!, HHH/2/Apricot,  \large{III }/3/ForestGreen!50!,JJJJ/6/Cyan,\LaTeX/6/Yellow}

\end{tikzpicture}
\end{document}    

enter image description here