summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXu Yuan <xu@informatik.hu-berlin.de>2011-10-01 12:56:51 +0200
committerXu Yuan <xu@informatik.hu-berlin.de>2011-10-01 12:56:51 +0200
commit59dd623790d8f70db0a340c71f9c27a2e3903b0c (patch)
treedae49e5e58d75659092b51d63bb848e1ade5ce32
parenteff2b05e919c9c439ae5fe503c45029146a082b4 (diff)
downloadpgf-pie-59dd623790d8f70db0a340c71f9c27a2e3903b0c.tar.gz
pgf-pie-59dd623790d8f70db0a340c71f9c27a2e3903b0c.tar.bz2
pgf-pie-59dd623790d8f70db0a340c71f9c27a2e3903b0c.zip
pos and radius
-rw-r--r--dev/demo/radius.tex4
-rw-r--r--dev/pgf-pie-manual.tex44
-rw-r--r--dev/pgf-pie.sty21
3 files changed, 47 insertions, 22 deletions
diff --git a/dev/demo/radius.tex b/dev/demo/radius.tex
new file mode 100644
index 0000000..7860315
--- /dev/null
+++ b/dev/demo/radius.tex
@@ -0,0 +1,4 @@
+\begin{tikzpicture}
+ \pie{10/A, 20/B, 30/C, 40/D}
+ \pie[pos={10,0}, radius=4]{10/A, 20/B, 30/C, 40/D}
+\end{tikzpicture} \ No newline at end of file
diff --git a/dev/pgf-pie-manual.tex b/dev/pgf-pie-manual.tex
index 12e91d2..85f07d1 100644
--- a/dev/pgf-pie-manual.tex
+++ b/dev/pgf-pie-manual.tex
@@ -37,27 +37,33 @@ keywordstyle=\color{blue}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\demo}[2][1]{
-\begin{minipage}{.49\linewidth}
-\centering
-\resizebox{#1\linewidth}{!}{
-\input{demo/#2}
-}
-\end{minipage}
-\hspace{0.01\linewidth}
-\begin{minipage}{.5\linewidth}
-\lstinputlisting{demo/#2}
-\end{minipage}
+ \begin{center}
+ \begin{tabular}{cc}
+ \begin{minipage}{.49\linewidth}
+ \centering
+ \resizebox{#1\linewidth}{!}{
+ \input{demo/#2}
+ }
+ \end{minipage}
+ &
+ \begin{minipage}{.45\linewidth}
+ \lstinputlisting{demo/#2}
+ \end{minipage}
+ \end{tabular}
+ \end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand{\example}[1]{
-\resizebox{\linewidth}{!}{
-\input{demo/#1}
-}
-\lstinputlisting{demo/#1}
+\newcommand{\example}[2][1]{
+ \begin{center}
+ \resizebox{#1\linewidth}{!}{
+ \input{demo/#2}
+ }
+ \end{center}
+ \lstinputlisting{demo/#2}
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -89,6 +95,12 @@ keywordstyle=\color{blue}
\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}
+
\section{Examples}
diff --git a/dev/pgf-pie.sty b/dev/pgf-pie.sty
index 84e543e..896ce73 100644
--- a/dev/pgf-pie.sty
+++ b/dev/pgf-pie.sty
@@ -21,22 +21,24 @@ chart by using PGF/Tikz package.]
% #5: explode
% #6: fill color
% #7: radius
-\newcommand{\pgfpie@slice}[7]{
+% #8: center
+\newcommand{\pgfpie@slice}[8]{
\pgfmathparse{0.5*#1+0.5*#2}
\let\midangle\pgfmathresult
+ \path (#8) -- ++(\midangle:#5) coordinate(O);
% slice
- \draw[thick,fill=#6] (\midangle:#5) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;
+ \draw[thick,fill=#6] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;
% outer label
- \node[label=\midangle:#4] at (\midangle:#7) {};
+ \path (O) -- ++ (\midangle:#7) node[label=\midangle:#4]{};
% inner label
\pgfmathparse{min((#2-#1-10)/110*(-0.3),0)}
\let\temp\pgfmathresult
\pgfmathparse{(max(\temp,-0.5) + 0.8)*#7}
\let\innerpos\pgfmathresult
- \node at (\midangle:\innerpos) {#3};
+ \path (O) -- ++(\midangle:\innerpos) node {#3};
}
\newcounter{pgfpie@angleBegin}
@@ -53,11 +55,17 @@ chart by using PGF/Tikz package.]
\def\setradius#1\pgfeov{\def\radius{#1}}
\pgfkeyslet{/radius/.@cmd}{\setradius}
+\def\setpos#1\pgfeov{\def\pos{#1}}
+\pgfkeyslet{/pos/.@cmd}{\setpos}
+
\newcommand{\pie}[2][]
{
- \pgfkeys{explode=0,
+ \pgfkeys{
+ explode=0,
colormap={blue!60, cyan!60, yellow!60, orange!60, red!60},
- radius=3}
+ radius=3,
+ pos={0,0}
+ }
\pgfkeys{#1}
\def\explodearray{{\explode}}
@@ -95,6 +103,7 @@ chart by using PGF/Tikz package.]
{\e}
{\thecolor}
{\radius}
+ {\pos}
}
}