From 26c5d5cefe7561ea676a1f2ae9a2853695b80f3d Mon Sep 17 00:00:00 2001 From: Xu Yuan Date: Sat, 1 Oct 2011 21:23:26 +0200 Subject: rotate --- dev/demo/radius.tex | 7 +++++-- dev/pgf-pie-manual.tex | 24 ++++++++---------------- dev/pgf-pie.sty | 12 ++++++++---- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/dev/demo/radius.tex b/dev/demo/radius.tex index 7860315..944e218 100644 --- a/dev/demo/radius.tex +++ b/dev/demo/radius.tex @@ -1,4 +1,7 @@ \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} + \pie{10/, 20/, 30/, 40/} + + \pie[pos={8,0}, rotate=180]{10/, 20/, 30/, 40/} + + \pie[pos={17,0}, radius=4]{10/, 20/, 30/, 40/} \end{tikzpicture} \ No newline at end of file diff --git a/dev/pgf-pie-manual.tex b/dev/pgf-pie-manual.tex index 4138749..4d19ce7 100644 --- a/dev/pgf-pie-manual.tex +++ b/dev/pgf-pie-manual.tex @@ -90,9 +90,12 @@ keywordstyle=\color{blue} \subsection{First Pie} \demo[0.6]{first-pie} -\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\}}. +\subsection{Position, Rotation, Size} + +The center of chart can be set by \texttt{pos}, default is +\texttt{\{0,0\}}. The chart can be rotated by setting \texttt{rotate} +(in degrees). The size of chart can be set by \texttt{radius}, default +is 3. \demo{radius} @@ -126,19 +129,8 @@ it is 100 by default. It can be calculated automatically when \section{Examples} -\subsection{Population of the world} -\example{population} - -% \pie{20/, 4/, 11/, 49/, 16/} - -% \pie{20/type A, 4/type B, 11/type C, 49/type D, 16/other} - -% \pie[explode={0, 0.01, 0},]{20/type A, 4/type B, 11/type C, 49/type D, 16/other} - -% \pie[explode={0, 0.01}, colormap=black!10]{20/type A, 4/type B, -% 11/type C, 49/type D, 16/other} - -% \pie{10/, 10/, 10/, 10/, 10/, 10/, 10/, 10/, 10/, 10/ } +% \subsection{Population of the world} +% \example{population} % \section{Acknowledgements} % Many people contributed to \texttt{pgf-pie} by reporting problems, diff --git a/dev/pgf-pie.sty b/dev/pgf-pie.sty index bcaf112..cb982b8 100644 --- a/dev/pgf-pie.sty +++ b/dev/pgf-pie.sty @@ -24,7 +24,7 @@ chart by using PGF/Tikz package.] % #8: center % #9: style \newcommand{\pgfpie@slice}[9]{ - \pgfmathparse{0.5*#1+0.5*#2} + \pgfmathparse{0.5*(#1)+0.5*(#2)} \let\midangle\pgfmathresult \path (#8) -- ++(\midangle:#5) coordinate(O); @@ -39,7 +39,7 @@ chart by using PGF/Tikz package.] \path (O) -- ++ (\midangle:\radius) node[inner sep=0, \text=\midangle:#4]{}; % inner label - \pgfmathparse{min((#2-#1-10)/110*(-0.3),0)} + \pgfmathparse{min(((#2)-(#1)-10)/110*(-0.3),0)} \let\temp\pgfmathresult \pgfmathparse{(max(\temp,-0.5) + 0.8)*#7} \let\innerpos\pgfmathresult @@ -78,6 +78,9 @@ chart by using PGF/Tikz package.] \def\setsum#1\pgfeov{\xdef\sum{#1}} \pgfkeyslet{/sum/.@cmd}{\setsum} +\def\setrotate#1\pgfeov{\xdef\rotate{#1}} +\pgfkeyslet{/rotate/.@cmd}{\setrotate} + \newcommand{\pie}[2][] { \pgfkeys{ @@ -90,6 +93,7 @@ chart by using PGF/Tikz package.] after number=\%, text=label, sum=100, + rotate=0, } \pgfkeys{#1} @@ -139,8 +143,8 @@ chart by using PGF/Tikz package.] \fi } - \pgfpie@slice{\thepgfpie@angleBegin/\sum*360} - {\thepgfpie@angleEnd/\sum*360} + \pgfpie@slice{\thepgfpie@angleBegin/\sum*360+\rotate} + {\thepgfpie@angleEnd/\sum*360+\rotate} {\beforenumber \p \afternumber} {\t} {\theexplode} -- cgit v1.2.3