I'm trying to create a macro that will take a list of pairs as an argument in order to draw a pie chart. I'm trying to make it so that portions of the pie are specified as a fraction less than 1. Here's a specific example of what I'm trying to accomplish:
\documentclass{article}
\usepackage{pgf,tikz}
\usepackage{ifthen}
\usetikzlibrary{calc}
\begin{document}
\newcounter{a} \newcounter{b}
\newcommand*{\piechart}[1]{
\begin{tikzpicture}[scale=\textwidth/2cm]
\setcounter{a}{0} \setcounter{b}{0}
\foreach \amt/\lbl in {#1}{
\setcounter{a}{\value{b}}
\addtocounter{b}{\amt}
\pgfmathsetmacro{\angleone}{\value{a}*360}
\pgfmathsetmacro{\angletwo}{\value{b}*360}
\pgfmathsetmacro{\midangle}{(\angleone+\angletwo)/2}
\draw[thick] (0,0) -- (\angleone:1) arc (\angleone:\angletwo:1) -- cycle;
\node at (\midangle:0.6) {\lbl};
}
\end{tikzpicture}
}
\piechart{{1/6}/label1, {1/6}/label2, {1/6}/label3, {1/2}/label4}
\end{document}
However, the output currently looks like the following:

I'm thinking that there's a problem either with my use of counters, or with how I specify fractional values surrounded by {} in the argument list.

