Created
January 8, 2016 21:56
-
-
Save anonymous/1c1f9bf15aff955ec31a to your computer and use it in GitHub Desktop.
Mmh… Delicious cake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[tikz]{standalone} | |
\begin{document} | |
\def\angle{0} | |
\def\radius{3} | |
\newcount\ind \ind=-1 | |
\begin{tikzpicture} | |
\foreach \percent/\name/\color in { | |
46.6/Chrome/blue, | |
24.6/Internet Explorer/red, | |
20.4/Firefox/green, | |
5.1/Safari/purple, | |
1.3/Opera/orange, | |
2.0/Other/yellow% | |
} { | |
\ifx\percent\empty\else % If \percent is empty, do nothing | |
\global\advance\ind by 1 % Advance list index | |
% Draw angle and set labels | |
\draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius) arc (\angle:\angle+\percent*3.6:\radius) -- cycle; | |
\node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\%}; | |
\node[pin=\angle+0.5*\percent*3.6:\name] at (\angle+0.5*\percent*3.6:\radius) {}; | |
\pgfmathparse{\angle+\percent*3.6} % Advance angle | |
\xdef\angle{\pgfmathresult} % and store in \angle | |
\fi | |
}; | |
\end{tikzpicture} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment