texlive[42821] Master/texmf-dist: sparklines (31dec16)
commits+karl at tug.org
commits+karl at tug.org
Sat Dec 31 22:26:18 CET 2016
Revision: 42821
http://tug.org/svn/texlive?view=revision&revision=42821
Author: karl
Date: 2016-12-31 22:26:18 +0100 (Sat, 31 Dec 2016)
Log Message:
-----------
sparklines (31dec16)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.pdf
trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.tex
trunk/Master/texmf-dist/tex/latex/sparklines/sparklines.sty
Modified: trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.tex 2016-12-31 21:26:04 UTC (rev 42820)
+++ trunk/Master/texmf-dist/doc/latex/sparklines/sparklines.tex 2016-12-31 21:26:18 UTC (rev 42821)
@@ -15,7 +15,7 @@
\title{Sparklines}
\author{Andreas Loeffler \and Dan Luecking}
-\date{updated 19.~October 2014 (version 1.6)}\maketitle
+\date{Updated 27~December 2016 (version 1.7)}\maketitle
\section{What are sparklines?}
@@ -131,7 +131,7 @@
\end{sparkline}.
This was created by the code:
\begin{verbatim}
- \begin{sparkline}{4}
+ \begin{sparkline}{5}
\sparkspike .083 .18
\sparkspike .25 .55
\sparkspike .417 1
@@ -149,6 +149,34 @@
each bar is the value of the length \verb$\sparkspikewidth$, which the
user may change (with \verb$\setlength$). The default is \texttt{2pt}.
+You can combine bars and lines:
+\begin{sparkline}{5}
+ \sparkspike .083 .18
+ \sparkspike .25 .55
+ \sparkspike .417 1
+ \sparkspike .583 .62
+ \sparkspike .75 .42
+ \sparkspike .917 .5
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \sparkdot 1 0.2 blue
+\end{sparkline}\space. This was created with
+\begin{verbatim}
+\begin{sparkline}{5}
+ \sparkspike .083 .18
+ \sparkspike .25 .55
+ \sparkspike .417 1
+ \sparkspike .583 .62
+ \sparkspike .75 .42
+ \sparkspike .917 .5
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \sparkdot 1 0.2 blue
+\end{sparkline}\space.
+\end{verbatim}
+
+
+
\paragraph{Colors} In case you want to change colors use
\begin{verbatim}
\definecolor{sparkrectanglecolor}{gray}{0.9}
@@ -165,24 +193,111 @@
\sparkspike .483 .62
\sparkspike .65 .42
\sparkspike .817 .5
-\sparkbottomline 0.9
+\sparkbottomline[0.9]
\end{sparkline}.
The code used was
\begin{verbatim}
\begin{sparkline}{5}
- \definecolor{sparkbottomlinecolor}{gray}{0.9}
+ \definecolor{sparkbottomlinecolor}{gray}{0.9}
\sparkspike .15 .55
\sparkspike .317 1
\sparkspike .483 .62
\sparkspike .65 .42
\sparkspike .817 .5
- \sparkbottomline 0.9
+ \sparkbottomline[0.9]
\end{sparkline}.
\end{verbatim}
Changing the color of the bottom line is quite easy using the command
+like
+\begin{verbatim}
+\definecolor{sparkbottomlinecolor}{named}{red}
+\end{verbatim}. You can change the thickness of the bottom line using
+command like
+\begin{verbatim}
+\setlength\sparkbottomlinethickness{1pt}
+\end{verbatim}
+The optional argument of \verb|\sparkbottomline| is the length of the
+bottom line (by default~1).
+
+If you need to set both start and end of the bottomline, use
+\verb|\sparkbottomlinex| command, which has two obligatory arguments:
+the start and the end, for example,
+\definecolor{sparkbottomlinecolor}{named}{blue}%
+ \begin{sparkline}{5}
+ \sparkspike .15 .55
+ \sparkspike .317 1
+ \sparkspike .483 .62
+ \sparkspike .65 .42
+ \sparkspike .817 .5
+ \sparkbottomlinex 0.3 0.8
+ \end{sparkline}. This was created with the code
+\begin{verbatim}
+ \begin{sparkline}{5}
+ \sparkspike .15 .55
+ \sparkspike .317 1
+ \sparkspike .483 .62
+ \sparkspike .65 .42
+ \sparkspike .817 .5
+ \sparkbottomlinex 0.3 0.8
+ \end{sparkline}
+\end{verbatim}
+
+\paragraph{Clipping}
+
+Sometimes you may have sparklines outside the drawing region, for
+example,
+ \begin{sparkline}{10}
+ \sparkrectangle 0.3 0.8
+ \sparkdot 0.5 0.62 blue
+ \sparkdot 1 0.2 red
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 2.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \end{sparkline}. You may want to clip them. The starred version
+ \verb|sparkline*| creates \emph{clipped} sparklines: the graphics
+ outside the rectangle (0,0) -- (1,1) plus a thin border of the width
+ \verb|\sparklineclipsep| is clipped:
+ \begin{sparkline*}{10}
+ \sparkrectangle 0.3 0.8
+ \sparkdot 0.5 0.62 blue
+ \sparkdot 1 0.2 red
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 2.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \end{sparkline*}. The first sparkline was created with
+\begin{verbatim}
+ \begin{sparkline}{10}
+ \sparkrectangle 0.3 0.8
+ \sparkdot 0.5 0.62 blue
+ \sparkdot 1 0.2 red
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 2.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \end{sparkline}.
+\end{verbatim}
+The second sparkline was created with
+\begin{verbatim}
+ \begin{sparkline*}{10}
+ \sparkrectangle 0.3 0.8
+ \sparkdot 0.5 0.62 blue
+ \sparkdot 1 0.2 red
+ \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 2.52 0.5 0.62
+ 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 /
+ \end{sparkline*}.
+\end{verbatim}
+
+The clipping separation is set to 2~pt. You can change it with
+\begin{verbatim}
+\setlength\sparklineclipsep{...}.
+\end{verbatim}
+
+
\section*{Version history}
\begin{description}
+
+ \item[] Dev 26, 2016
+
+ version 1.7: Boris Veytsman (borisv at lk.net). Added clipping,
+ extensible bottom lines, some bug fixes.
+
\item[] Oct 19, 2014
version 1.6: Emiel van Miltenburg (emiel.van.miltenburg at vu.nl) - Adding a bottom line (the x-axis, this is useful to visually separate different bar charts that are next to each other) and changing the color of the bottom line.
Modified: trunk/Master/texmf-dist/tex/latex/sparklines/sparklines.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/sparklines/sparklines.sty 2016-12-31 21:26:04 UTC (rev 42820)
+++ trunk/Master/texmf-dist/tex/latex/sparklines/sparklines.sty 2016-12-31 21:26:18 UTC (rev 42821)
@@ -1,4 +1,4 @@
-%%% sparklines.sty Version 1.6
+%%% sparklines.sty Version 1.7
%%%
%%% What Are Sparklines?
%%% Sparklines are intense, simple, wordlike graphics (so named by Edward Tufte).
@@ -16,25 +16,45 @@
%%% al at wacc.de
%%%
%%% MODIFICATION HISTORY:
+%%%
+%%% Dec 26 2016:
+%%% version 1.7: Boris Veytsman (borisv at lk.net): Adding optional clipping,
+%%% extensible bottom lines, some bug fixing.
+%%%
%%% Oct 19, 2014
-%%% version 1.6: Emiel van Miltenburg (emiel.van.miltenburg at vu.nl) - Adding a bottom line (the x-axis, this is useful to visually separate different bar charts that are next to each other) and changing the color of the bottom line.
+%%% version 1.6: Emiel van Miltenburg (emiel.van.miltenburg at vu.nl) -
+%%% Adding a bottom line (the x-axis, this is useful to visually
+%%% separate different bar charts that are next to each other) and
+%%% changing the color of the bottom line.
+%%%
%%% Nov 21, 2009
-%%% version 1.5: Benno Puetz (puetz at mpipsykl.mpg.de) made change of colors possible.
+%%% version 1.5: Benno Puetz (puetz at mpipsykl.mpg.de) made change of
+%%% colors possible.
+%%%
%%% Apr 20, 2009
-%%% version 1.4: Alexander Kowalski (Alexander.Kowarik at statistik.gv.at) found an error concerning spark-rectangles
+%%% version 1.4: Alexander Kowalski
+%%% (Alexander.Kowarik at statistik.gv.at) found an error concerning
+%%% spark-rectangles
+%%%
%%% Mar 21, 2007
%%% version 1.3: Dan Luecking (luecking at uark.edu) added user-changeable
%%% parameters, and expanded documentation
+%%%
%%% Mar 19, 2007
-%%% version 1.2: Harlan Harris (harlan at harris.name) added positive-value-only bars
+%%% version 1.2: Harlan Harris (harlan at harris.name) added
+%%% positive-value-only bars
+%%%
%%% Apr 21, 2005
-%%% version 1.1: bug removed thanks to Mathias Hofmann <mathias.hofmann at web.de>
+%%% version 1.1: bug removed thanks to Mathias Hofmann
+%%% <mathias.hofmann at web.de>
+%%%
%%% Dec 12, 2004
%%% version 1.0: first version of sparklines
+%%%
\ProvidesPackage{sparklines}
- [2014/10/19 v1.6 Sparklines (see more about sparklines at www.EdwardTufte.com)]
- \typeout {Package: `sparklines' 1.6bp \space 2014/10/19}
+ [2016/12/26 v1.7 Sparklines (see more about sparklines at www.EdwardTufte.com)]
+ \typeout {Package: `sparklines' 1.7bp \space 2016/12/26}
\RequirePackage{pgf}
% We define the colors of two features: the background rectangle and
@@ -48,24 +68,43 @@
% \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.
+% \sparkbottomlinewidth -- width of the bottom line
% Defaults equal old hard-coded values.
\newlength\sparklinethickness
\newlength\sparkdotwidth
\newlength\sparkspikewidth
+\newlength\sparkbottomlinethickness
+\newlength\sparklineclipsep
\setlength\sparklinethickness{0.2pt}
\setlength\sparkdotwidth{1.2pt}
\setlength\sparkspikewidth{2pt}
+\setlength\sparkbottomlinethickness{2pt}
+\setlength\sparklineclipsep{2pt}
\providecommand{\sparklineheight}{1.75}
% defines sparkline environment
% Replace hard coded line thickness and picture height with above
% defined parameters.
-\newenvironment{sparkline}[1]{\pgfpicture{0ex}{0ex}{#1 ex}{\sparklineheight ex}
+\newenvironment{sparkline}[1]{\pgfpicture{0ex}{0ex}{#1
+ ex}{\sparklineheight ex}
\pgfsetlinewidth{\sparklinethickness}
\pgfsetxvec{\pgfpoint{#1 ex}{0pt}}
\pgfsetyvec{\pgfpoint{0pt}{\sparklineheight ex}}
} {\pgfstroke \endpgfpicture}
+\newenvironment{sparkline*}[1]{\pgfpicture{0ex}{0ex}{#1
+ ex}{\sparklineheight ex}
+ \pgfpathrectanglecorners%
+ {\pgfpoint{-\sparklineclipsep}{-\sparklineclipsep}}%
+ {\pgfpointadd{\pgfpoint{#1 ex}{\sparklineheight ex}}%
+ {\pgfpoint{\sparklineclipsep}{\sparklineclipsep}}}
+ \pgfusepath{clip}
+ \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 {%
@@ -82,7 +121,13 @@
\pgfrect[fill]{\pgfxy(0, #1)}{\pgfxy(1, #2-#1)}}}%
% defines sparkbottomline
-\newcommand{\sparkbottomline}[1][1]{\color{sparkbottomlinecolor}\pgfline{\pgfxy(0,0)}{\pgfxy(#1,0)}\color{sparklinecolor}}
+\newcommand{\sparkbottomline}[1][1]{\pgfsetlinewidth{\sparkbottomlinethickness}%
+ \color{sparkbottomlinecolor}%
+ \pgfline{\pgfxy(0,0)}{\pgfxy(#1,0)}\color{sparklinecolor}}
+% defines sparkbottomlinex
+\def\sparkbottomlinex #1 #2 {\pgfsetlinewidth{\sparkbottomlinethickness}%
+ \color{sparkbottomlinecolor}
+ \pgfline{\pgfxy(#1,0)}{\pgfxy(#2,0)}\color{sparklinecolor}}
% defines sparkline-plot
% Replace \@shouldIstop hack with equivalent \@ifnextchar code.
@@ -90,6 +135,7 @@
\pgfmoveto{\pgfxy(#1,#2)} %
\@SPARK}
\def\@SPARK#1 #2 {%
+ \pgfsetlinewidth{\sparklinethickness}%
\pgfsetstrokecolor{sparklinecolor}%
\pgflineto{\pgfxy(#1,#2)} %
\@ifnextchar/{\pgfstroke\ignorespaces}{\@SPARK}}
More information about the tex-live-commits
mailing list