summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXu Yuan <xu@informatik.hu-berlin.de>2011-10-01 13:12:39 +0200
committerXu Yuan <xu@informatik.hu-berlin.de>2011-10-01 13:12:39 +0200
commitcd07b9439a4c22d77dd14d103760367cd3fe4737 (patch)
tree1ceec701d37dbb37679c65f5966b968e2a9ae300
parent59dd623790d8f70db0a340c71f9c27a2e3903b0c (diff)
downloadpgf-pie-cd07b9439a4c22d77dd14d103760367cd3fe4737.tar.gz
pgf-pie-cd07b9439a4c22d77dd14d103760367cd3fe4737.tar.bz2
pgf-pie-cd07b9439a4c22d77dd14d103760367cd3fe4737.zip
formate
-rw-r--r--dev/demo/color.tex2
-rw-r--r--dev/demo/first-pie.tex2
-rw-r--r--dev/pgf-pie-manual.tex10
-rw-r--r--dev/pgf-pie.sty87
4 files changed, 55 insertions, 46 deletions
diff --git a/dev/demo/color.tex b/dev/demo/color.tex
index 53416d1..974774a 100644
--- a/dev/demo/color.tex
+++ b/dev/demo/color.tex
@@ -1,4 +1,4 @@
\begin{tikzpicture}
- \pie[colormap={black!10, black!20, black!30, black!40}]
+ \pie[color={black!10, black!20, black!30, black!40}]
{10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}
diff --git a/dev/demo/first-pie.tex b/dev/demo/first-pie.tex
index 1f99130..e8c6376 100644
--- a/dev/demo/first-pie.tex
+++ b/dev/demo/first-pie.tex
@@ -1,3 +1,3 @@
\begin{tikzpicture}
\pie{10/A, 20/B, 30/C, 40/D}
-\end{tikzpicture}
+\end{tikzpicture} \ No newline at end of file
diff --git a/dev/pgf-pie-manual.tex b/dev/pgf-pie-manual.tex
index 85f07d1..f851bce 100644
--- a/dev/pgf-pie-manual.tex
+++ b/dev/pgf-pie-manual.tex
@@ -7,6 +7,7 @@
\usepackage{hyperref}
\usepackage{pgf-pie}
+\usetikzlibrary{shadows}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
@@ -92,15 +93,18 @@ keywordstyle=\color{blue}
\subsection{Explode}
\demo[0.6]{explode}
-\subsection{Color}
-\demo[0.6]{color}
-
\subsection{Radius, Position}
The size of chart can be set by \texttt{radius}, default is 3. The
center of chart can be set by \texttt{pos}, default is \texttt{\{0,0\}}.
\demo{radius}
+\subsection{Color}
+\demo[0.6]{color}
+
+\subsection{Style}
+\demo[0.6]{style}
+
\section{Examples}
diff --git a/dev/pgf-pie.sty b/dev/pgf-pie.sty
index 896ce73..717be85 100644
--- a/dev/pgf-pie.sty
+++ b/dev/pgf-pie.sty
@@ -1,17 +1,16 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start of pgf-pie.sty
-%
+%
% Some LaTeX macros for pie chart by using PGF/Tikz package.
% Home page of project: http://pgf-pie.googlecode.com/
% Author: Xu Yuan <xuyuan.cn@gmail.com>
-%
+%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pgf-pie}[2011/10/01 v0.1 Some LaTeX macros for pie
chart by using PGF/Tikz package.]
\RequirePackage{tikz}
-\usetikzlibrary{shadows}
% args:
% #1: begin angle
@@ -22,13 +21,14 @@ chart by using PGF/Tikz package.]
% #6: fill color
% #7: radius
% #8: center
-\newcommand{\pgfpie@slice}[8]{
+% #9: style
+\newcommand{\pgfpie@slice}[9]{
\pgfmathparse{0.5*#1+0.5*#2}
\let\midangle\pgfmathresult
\path (#8) -- ++(\midangle:#5) coordinate(O);
% slice
- \draw[thick,fill=#6] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;
+ \draw[fill=#6, #9] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;
% outer label
\path (O) -- ++ (\midangle:#7) node[label=\midangle:#4]{};
@@ -44,13 +44,13 @@ chart by using PGF/Tikz package.]
\newcounter{pgfpie@angleBegin}
\newcounter{pgfpie@angleEnd}
\newcounter{pgfpie@explodeLength}
-\newcounter{pgfpie@colormapLength}
+\newcounter{pgfpie@colorLength}
\def\setexplode#1\pgfeov{\def\explode{#1}}
\pgfkeyslet{/explode/.@cmd}{\setexplode}
-\def\setcolormap#1\pgfeov{\def\colormap{#1}}
-\pgfkeyslet{/colormap/.@cmd}{\setcolormap}
+\def\setcolor#1\pgfeov{\def\color{#1}}
+\pgfkeyslet{/color/.@cmd}{\setcolor}
\def\setradius#1\pgfeov{\def\radius{#1}}
\pgfkeyslet{/radius/.@cmd}{\setradius}
@@ -58,13 +58,17 @@ chart by using PGF/Tikz package.]
\def\setpos#1\pgfeov{\def\pos{#1}}
\pgfkeyslet{/pos/.@cmd}{\setpos}
+\def\setstyle#1\pgfeov{\def\style{#1}}
+\pgfkeyslet{/style/.@cmd}{\setstyle}
+
\newcommand{\pie}[2][]
{
\pgfkeys{
explode=0,
- colormap={blue!60, cyan!60, yellow!60, orange!60, red!60},
+ color={blue!60, cyan!60, yellow!60, orange!60, red!60},
radius=3,
- pos={0,0}
+ pos={0,0},
+ style={thick}
}
\pgfkeys{#1}
@@ -72,41 +76,42 @@ chart by using PGF/Tikz package.]
\setcounter{pgfpie@explodeLength}{0}
\foreach \e in \explode { \addtocounter{pgfpie@explodeLength}{1} }
- \setcounter{pgfpie@colormapLength}{0}
- \foreach \c in \colormap { \addtocounter{pgfpie@colormapLength}{1} }
+ \setcounter{pgfpie@colorLength}{0}
+ \foreach \c in \color { \addtocounter{pgfpie@colorLength}{1} }
\setcounter{pgfpie@angleEnd}{0}
-
- \foreach \p/\t [count=\i from 0] in {#2}
- {
- \setcounter{pgfpie@angleBegin}{\value{pgfpie@angleEnd}}
- \addtocounter{pgfpie@angleEnd}{\p}
-
- % find explode
- \pgfmathparse{\explodearray[int(mod(\i,\value{pgfpie@explodeLength}))]}
- \let\e\pgfmathresult
-
- % find color
- \pgfmathparse{int(mod(\i,\value{pgfpie@colormapLength}))}
- \let\ci\pgfmathresult
- \foreach \c [count=\j from 0] in \colormap {
- \ifnum \j=\ci
- \xdef\thecolor{\c}
- \breakforeach
- \fi
- }
-
- \pgfpie@slice{\thepgfpie@angleBegin/100*360}
- {\thepgfpie@angleEnd/100*360}
- {\p\%}{\t}
- {\e}
- {\thecolor}
- {\radius}
- {\pos}
+ \foreach \p/\t [count=\i from 0] in {#2}
+ {
+ \setcounter{pgfpie@angleBegin}{\value{pgfpie@angleEnd}}
+ \addtocounter{pgfpie@angleEnd}{\p}
+
+ % find explode
+ \pgfmathparse{\explodearray[int(mod(\i,\value{pgfpie@explodeLength}))]}
+ \let\e\pgfmathresult
+
+ % find color
+ \pgfmathparse{int(mod(\i,\value{pgfpie@colorLength}))}
+ \let\ci\pgfmathresult
+ \foreach \c [count=\j from 0] in \color {
+ \ifnum \j=\ci
+ \xdef\thecolor{\c}
+ \breakforeach
+ \fi
}
+
+ \pgfpie@slice{\thepgfpie@angleBegin/100*360}
+ {\thepgfpie@angleEnd/100*360}
+ {\p\%}
+ {\t}
+ {\e}
+ {\thecolor}
+ {\radius}
+ {\pos}
+ {\style}
+ }
}
%%% End of pgf-pie.sty
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%