summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2007-11-16 10:40:50 +0000
committerNorbert Preining <preining@logic.at>2007-11-16 10:40:50 +0000
commitd63db66c42ec0eacc205e6e108b265f2d968e6c4 (patch)
treeafa267d203724d3ce68b02e13690bf589f8782ba /Master/texmf-dist/tex
parentb2a0b2180457ec23b60a4052f22e641beb03fa4b (diff)
update sparklines 1.3 from ctan
git-svn-id: svn://tug.org/texlive/trunk@5441 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/sparklines/sparklines.sty87
1 files changed, 60 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/latex/sparklines/sparklines.sty b/Master/texmf-dist/tex/latex/sparklines/sparklines.sty
index 6a7307bd138..e81202b098c 100644
--- a/Master/texmf-dist/tex/latex/sparklines/sparklines.sty
+++ b/Master/texmf-dist/tex/latex/sparklines/sparklines.sty
@@ -1,4 +1,4 @@
-%%% sparklines.sty Version 1.0
+%%% sparklines.sty Version 1.3
%%%
%%% What Are Sparklines?
%%% Sparklines are intense, simple, wordlike graphics (so named by Edward Tufte).
@@ -6,8 +6,6 @@
%%% release of a chapter on sparklines, see www.edwardtufte.com. A PHP
%%% implementation can be found at http://sparkline.sourceforge.net/.
%%%
-%%% Notice that the package does NOT run with pictex!
-%%%
%%% Copyright 2005 Andreas Loeffler
%%% ========================================================================
%%% LICENCE:
@@ -18,47 +16,82 @@
%%% al@wacc.de
%%%
%%% MODIFICATION HISTORY:
+%%% Mar 21, 2007
+%%% version 1.3: Dan Luecking (luecking@uark.edu) added user-changeable
+%%% parameters, and expanded documentation
+%%% Mar 19, 2007
+%%% version 1.2: Harlan Harris (harlan@harris.name) added positive-value-only bars
%%% Apr 21, 2005
%%% version 1.1: bug removed thanks to Mathias Hofmann <mathias.hofmann@web.de>
%%% Dec 12, 2004
%%% version 1.0: first version of sparklines
-\RequirePackage{pgf} \ProvidesPackage{sparklines}
- [2005/01/01 v1.0 Sparklines (see more on sparklines at www.EdwardTufte.com)]
+\ProvidesPackage{sparklines}
+ [2005/01/01 v1.3 Sparklines (see more on sparklines at www.EdwardTufte.com)]
+\RequirePackage{pgf}
+
+% We define the colors of two features: the background rectangle and
+% the spikes in a bar graph
+\definecolor{sparkrectanglecolor}{gray}{0.9}
+\definecolor{sparkspikecolor}{named}{black}
+
+% We define parameters for changing the sizes. These are
+% \sparklinethickness -- thickness of the line drawn by \spark,
+% \sparkdotwidth -- diameter of the dot drawn by \sparkdot,
+% \sparkspikewidth -- width of bar drawn in \sparkspike,
+% \sparklineheight -- macro, number of ex for the height of picture.
+% Defaults equal old hard-coded values.
+\newlength\sparklinethickness
+\newlength\sparkdotwidth
+\newlength\sparkspikewidth
+\setlength\sparklinethickness{0.2pt}
+\setlength\sparkdotwidth{1.2pt}
+\setlength\sparkspikewidth{2pt}
+\providecommand{\sparklineheight}{1.75}
% defines sparkline environment
-\newenvironment{sparkline}[1]{\begin{pgfpicture}{0ex}{0ex}{#1 ex}{1.75ex}
- \pgfsetlinewidth{0.2pt} %line width of 0.2 pt
- \pgfsetxvec{\pgfpoint{#1 ex}{0pt}} % says that on unit on the x axes is #1 times the size of x
- \pgfsetyvec{\pgfpoint{0pt}{1.75ex}} % says that on unit on the y axes is 1.75 times the size of x
- } {\pgfstroke \end{pgfpicture} }
+% Replace hard coded line thickness and picture height with above
+% defined parameters.
+\newenvironment{sparkline}[1]{\pgfpicture{0ex}{0ex}{#1 ex}{\sparklineheight ex}
+ \pgfsetlinewidth{\sparklinethickness}
+ \pgfsetxvec{\pgfpoint{#1 ex}{0pt}}
+ \pgfsetyvec{\pgfpoint{0pt}{\sparklineheight ex}}
+} {\pgfstroke \endpgfpicture}
% defines sparkdot with color
+% Replace hard-coded diameter with previously defined parameter.
\def\sparkdot #1 #2 #3 {%
- {\pgfmoveto{\pgforigin}\color{#3}\pgfcircle[fill]{\pgfxy(#1,#2)}{1.2pt}}%
+ {\pgfmoveto{\pgforigin}\color{#3}\pgfcircle[fill]{\pgfxy(#1,#2)}{\sparkdotwidth}}%
}
-% definies sparkrectangle
+% defines sparkrectangle
+% Replace hard-coded rgb value with with previously defined color value.
\def\sparkrectangle #1 #2 {%
- {\pgfmoveto{\pgforigin}\color[rgb]{0.9,0.9,0.9} \pgfrect[fill]{\pgfxy(0, #1)}{\pgfxy(1, #2)}}}
-
-% taken from pictex
-\def\@shouldIstop#1#2{%
- \def\first{#1}%
- \def\second{#2}%
- \futurelet\nextchar\@testnext}
-\def\@testnext{%
- \ifx \nextchar /
- \let\next=\first
- \else
- \let\next=\second
- \fi
- \next}
+ {\pgfmoveto{\pgforigin}\color{sparkrectanglecolor}
+ \pgfrect[fill]{\pgfxy(0, #1)}{\pgfxy(1, #2)}}}
% defines sparkline-plot
+% Replace \@shouldIstop hack with equivalent \@ifnextchar code.
\def\spark #1 #2 {%
\pgfmoveto{\pgfxy(#1,#2)} %
\@SPARK}
\def\@SPARK#1 #2 {%
\pgflineto{\pgfxy(#1,#2)} %
- \@shouldIstop{\pgfstroke\ignorespaces}{\@SPARK}}
+ \@ifnextchar/{\pgfstroke\ignorespaces}{\@SPARK}}
+
+% defines sparkspike
+% Redefine \sparkspike with code that actually detects the color
+% change. The old version had black hard-coded, but even changing that
+% made no difference in the output. The combination of setting stroke
+% color and \pgfusepath{stroke} made it work. In place of hard-coded
+% width and are now previously defined parameters.
+\def\sparkspike #1 #2 {%
+ {%
+ \pgfmoveto{\pgforigin}%
+ \pgfsetlinewidth{\sparkspikewidth}%
+ \pgfsetstrokecolor{sparkspikecolor}%
+ \pgfmoveto{\pgfxy(#1, 0)}%
+ \pgflineto{\pgfxy(#1, #2)}
+ \pgfusepath{stroke}}%
+}
+\endinput