| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2025 Alan J. Cain |
| 4 |
% |
| 5 |
% This file may be distributed and/or modified under the conditions of the LaTeX Project Public Licence, either version |
| 6 |
% 1.3c of this licence or (at your option) any later version. The latest version of this licence is in: |
| 7 |
% |
| 8 |
% http://www.latex-project.org/lppl.txt |
| 9 |
% |
| 10 |
% and version 1.3c or later is part of all distributions of LaTeX version 2008-05-04 or later. |
| 11 |
% |
| 12 |
% \fi |
| 13 |
% |
| 14 |
% \iffalse |
| 15 |
%<*driver> |
| 16 |
\PassOptionsToPackage{inline}{enumitem} |
| 17 |
\documentclass{l3doc} |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
% Make space for larger numbers in contents |
| 22 |
|
| 23 |
\makeatletter |
| 24 |
\ExplSyntaxOn |
| 25 |
|
| 26 |
\cs_gset:Npn \l@subsection { \@dottedtocline{2}{2.5em}{2.8em} } |
| 27 |
\cs_gset:Npn \l@subsubsection { \@dottedtocline{3}{5.3em}{4em} } |
| 28 |
|
| 29 |
\ExplSyntaxOff |
| 30 |
\makeatother |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
% Link formatting |
| 35 |
|
| 36 |
\usepackage{xcolor} |
| 37 |
|
| 38 |
\definecolor{linkcolor}{rgb}{0.0,0.4,0.7} |
| 39 |
\colorlet{citecolor}{linkcolor} |
| 40 |
\colorlet{urlcolor}{linkcolor} |
| 41 |
|
| 42 |
\hypersetup{ |
| 43 |
linkcolor=linkcolor,% |
| 44 |
citecolor=citecolor,% |
| 45 |
urlcolor=urlcolor,% |
| 46 |
} |
| 47 |
|
| 48 |
\newcommand*\fullref[2]{% |
| 49 |
\hyperref[#2]{#1\penalty 200\ \ref*{#2}}% |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
% Use siunitx for typesetting dimensions |
| 55 |
|
| 56 |
\usepackage{siunitx} |
| 57 |
\sisetup{ |
| 58 |
mode=match, |
| 59 |
} |
| 60 |
\DeclareSIUnit\point{pt} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
% Listings and grammars |
| 65 |
|
| 66 |
\usepackage{listings} |
| 67 |
\lstset{ |
| 68 |
language=[LaTeX]TeX, |
| 69 |
basicstyle=\small\ttfamily, |
| 70 |
basewidth=0.5em, |
| 71 |
numbers=left, |
| 72 |
numberstyle=\scriptsize\sffamily, |
| 73 |
} |
| 74 |
|
| 75 |
\usepackage{simplebnf} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
% Macros for describing keys |
| 80 |
|
| 81 |
\newlist{optionlist}{description}{1} |
| 82 |
\setlist[optionlist]{ |
| 83 |
leftmargin=3em, |
| 84 |
style=unboxed, |
| 85 |
labelsep=1em, |
| 86 |
font=\descriptionitemcolon, |
| 87 |
nosep, |
| 88 |
} |
| 89 |
\newcommand*{\descriptionitemcolon}[1]{\kern 1em #1:} |
| 90 |
|
| 91 |
|
| 92 |
\newcommand*\key[1]{\texttt{#1}} |
| 93 |
\newcommand*\val[1]{\texttt{#1}} |
| 94 |
\newcommand*\keyval[2]{\texttt{#1=#2}} |
| 95 |
|
| 96 |
\usepackage{xcolor} |
| 97 |
\definecolor{keycolor}{rgb}{0.8,0.0,0.0} |
| 98 |
\definecolor{keyvaluecolor}{rgb}{0.0,0.65,0.0} |
| 99 |
|
| 100 |
\ExplSyntaxOn |
| 101 |
|
| 102 |
\NewDocumentEnvironment{describekey}{ m m m }{ |
| 103 |
\group_begin: |
| 104 |
\group_begin: |
| 105 |
\noindent{\textcolor{keycolor}{\texttt{#1}}} |
| 106 |
\str_if_empty:nF{#2} |
| 107 |
{ |
| 108 |
\skip_set:Nn{\parfillskip}{0pt} |
| 109 |
\str_case:nnF{#2} |
| 110 |
{ |
| 111 |
{style} |
| 112 |
{ |
| 113 |
\hfil |
| 114 |
(style,~initially~#3) |
| 115 |
} |
| 116 |
} |
| 117 |
{ |
| 118 |
\textcolor{keyvaluecolor}{\texttt{=}\meta{#2}} |
| 119 |
\str_if_empty:nF{#3} |
| 120 |
{ |
| 121 |
\hfil |
| 122 |
(default\nobreakspace\texttt{#3}) |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
\par |
| 127 |
\group_end: |
| 128 |
\nobreak |
| 129 |
\skip_add:Nn{\leftskip}{\parindent} |
| 130 |
\noindent\ignorespaces |
| 131 |
}{ |
| 132 |
\par |
| 133 |
\group_end: |
| 134 |
} |
| 135 |
|
| 136 |
\ExplSyntaxOff |
| 137 |
|
| 138 |
|
| 139 |
\newcommand*\mcode[1]{\texttt{#1}} |
| 140 |
\newcommand*\param[1]{\texttt{\##1}} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
% Other macros |
| 145 |
|
| 146 |
\newcommand*\TikZ{\texorpdfstring{Ti\textit{k}Z}{TikZ}} |
| 147 |
\newcommand*\ISO{\textsc{iso}} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
% Timechart |
| 152 |
|
| 153 |
\usepackage{timechart} |
| 154 |
|
| 155 |
\input{timechart-example1-setup.tex} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
\begin{document} |
| 160 |
\DocInput{timechart.dtx} |
| 161 |
\end{document} |
| 162 |
%</driver> |
| 163 |
% \fi |
| 164 |
% |
| 165 |
% |
| 166 |
% |
| 167 |
% \GetFileInfo{timechart.sty} |
| 168 |
% |
| 169 |
% |
| 170 |
% |
| 171 |
% \title{^^A |
| 172 |
% \pkg{timechart} ^^A |
| 173 |
% --- A package for drawing chronological charts^^A |
| 174 |
% \thanks{This file describes \fileversion, last revised \filedate.}^^A |
| 175 |
% } |
| 176 |
% |
| 177 |
% \author{^^A |
| 178 |
% Alan J. Cain^^A |
| 179 |
% } |
| 180 |
% |
| 181 |
% \date{Released \filedate} |
| 182 |
% |
| 183 |
% \maketitle |
| 184 |
% |
| 185 |
% |
| 186 |
% |
| 187 |
% \begin{abstract} |
| 188 |
% This package provides for the easy creation of chronological charts which show visually the relative historical |
| 189 |
% positions of people and events. Each event or period can be specified by a single line of \LaTeX\ code comprising |
| 190 |
% (possibly uncertain) start and finish dates and a label, and the package takes care of indicating the uncertainties |
| 191 |
% and whether intervals extend beyond the specified bounds of the chart. |
| 192 |
% \end{abstract} |
| 193 |
% |
| 194 |
% |
| 195 |
% |
| 196 |
% \tableofcontents |
| 197 |
% |
| 198 |
% |
| 199 |
% |
| 200 |
% \begin{documentation} |
| 201 |
% |
| 202 |
% \setcounter{secnumdepth}{2} |
| 203 |
% |
| 204 |
% |
| 205 |
% \section{Introduction} |
| 206 |
% |
| 207 |
% The \pkg{timechart} package provides a system for the easy creation of chronological charts --- of the type pioneered |
| 208 |
% by Joseph Priestley (1733--1804) in his `Chart of Biography' and more famously in his `New Chart of |
| 209 |
% History'\footnote{\textsc{url}:~\url{https://commons.wikimedia.org/wiki/File:A_New_Chart_of_History_color.jpg}} --- |
| 210 |
% which can show visually the relative historical positions of people and events. An example of what \pkg{timechart} can |
| 211 |
% be used to produce is shown in \fullref{Figure}{fig:example1} on page~\pageref{fig:example1}. |
| 212 |
% |
| 213 |
% \begin{figure}[p] |
| 214 |
% \centering |
| 215 |
% \input{timechart-example1-timechart.tex} |
| 216 |
% \caption{Timechart showing the lifetimes of Roman emperors from \timechartmakebeforeyear{50} to |
| 217 |
% \timechartmakeafteryear{500}. Marks on each lifetime indicate the beginning (and, where relevant, the end) of that |
| 218 |
% emperor's reign. Colours generally indicate dynasties, with shades of green indicating periods when the imperial |
| 219 |
% power shifted between many short-reigning emperors.} |
| 220 |
% \label{fig:example1} |
| 221 |
% \end{figure} |
| 222 |
% |
| 223 |
% Essentially (and this was a design requirement), \emph{only one line} of \LaTeX\ code is required for each interval |
| 224 |
% (which, in the case of \fullref{Figure}{fig:example1}, are mostly lifetimes). The \pkg{timechart} package takes care |
| 225 |
% of indicating ranges of possible dates by suitable fading from or to transparency. It also handles indicators to show |
| 226 |
% that intervals continue outside the specified scope of the chart. |
| 227 |
% |
| 228 |
% \pkg{timechart} was developed from, and replaced, a set of macros used to create the chronological charts in the |
| 229 |
% author's book \textit{Form \& Number: A History of Mathematical Beauty}, which is available on the Internet Archive |
| 230 |
% under a Creative Commons licence.\footnote{\textsc{url}: |
| 231 |
% \url{https://archive.org/details/cain_formandnumber_ebook_large}} |
| 232 |
% |
| 233 |
% |
| 234 |
% |
| 235 |
% \paragraph*{Licence.} \noindent\pkg{timechart} is released under the \LaTeX\ Project Public Licence v1.3c or |
| 236 |
% later.\footnote{\textsc{url}: \url{https://www.latex-project.org/lppl.txt}} |
| 237 |
% |
| 238 |
% |
| 239 |
% |
| 240 |
% \paragraph*{Acknowledgements.} The author thanks Tânia Paulista for reading and commenting on an earlier draft of the |
| 241 |
% documentation. |
| 242 |
% |
| 243 |
% |
| 244 |
% |
| 245 |
% \section{Requirements} |
| 246 |
% |
| 247 |
% \pkg{timechart} requires PGF/\TikZ\ and a \LaTeX\ kernel with \pkg{expl3} support (any kernel version since 2020-02-02 |
| 248 |
% should suffice). |
| 249 |
% |
| 250 |
% |
| 251 |
% |
| 252 |
% \section{Installation} |
| 253 |
% |
| 254 |
% To install manually, run \texttt{tex timechart.ins} and copy the file \file{timechart.sty} to somewhere \LaTeX\ can |
| 255 |
% find it. |
| 256 |
% |
| 257 |
% |
| 258 |
% |
| 259 |
% \section{Getting started} |
| 260 |
% |
| 261 |
% The \pkg{timechart} package is loaded as usual via \cs{usepackage}\texttt{\{timechart\}}. There are no package |
| 262 |
% options. |
| 263 |
% |
| 264 |
% The small example in \fullref{Section}{sec:example} illustrates the basic principles of \pkg{timechart}. |
| 265 |
% \fullref{Section}{sec:full-example} shows the full code used to produce the large example in \fullref{Figure}{fig:example1}. |
| 266 |
% |
| 267 |
% |
| 268 |
% |
| 269 |
% |
| 270 |
% |
| 271 |
% \section{Example} |
| 272 |
% \label{sec:example} |
| 273 |
% |
| 274 |
% This section illustrates how to create the small chart shown in \fullref{Figure}{fig:example2-v2} on |
| 275 |
% page~\pageref{fig:example2-v2}. |
| 276 |
% |
| 277 |
% The basic environment is \env{timechart}, which includes the specification of the start and finish years. The start |
| 278 |
% year \timechartmakebeforeyear{50} is specified as \mcode{-50}, the finish year \timechartmakeafteryear{75} as |
| 279 |
% \mcode{75}. Each interval in the chart is specified using the \cs{timechartinterval} command, which takes three |
| 280 |
% mandatory parameters: a start year, a finish year, and a label. The following code produces the flawed preliminary |
| 281 |
% version shown in \fullref{Figure}{fig:example2-v1}. |
| 282 |
% |
| 283 |
% \lstinputlisting{timechart-example2-v1.tex} |
| 284 |
% |
| 285 |
% \begin{figure}[ht] |
| 286 |
% \centering |
| 287 |
% \input{timechart-example2-v1.tex} |
| 288 |
% \medskip |
| 289 |
% \caption{Flawed preliminary version of a chart showing the lifetimes of Roman emperors of the Julio-Claudian |
| 290 |
% dynasty. (The final version is shown in \fullref{Figure}{fig:example2-v2}.)} |
| 291 |
% \label{fig:example2-v1} |
| 292 |
% \end{figure} |
| 293 |
% |
| 294 |
% This first attempt result illustrates some of the principles of \pkg{timechart}. Each interval has been placed on its |
| 295 |
% own line. More precisely, the \(y\) coordinate of the first interval is \(0\) and each use of \cs{timechartinterval} |
| 296 |
% increments the `current \(y\) coordinate' by a specified amount. (Various commands are available to set the \(y\) |
| 297 |
% coordinate manually or to reset it automatically when it passes certain bounds; see |
| 298 |
% \fullref{Subsection}{subsec:positioning}.) Horizontally, the chart starts and finishes at the specified years. The topmost |
| 299 |
% interval, indicating Augustus' life, has been truncated with an indicator that it begins before the specified start |
| 300 |
% year of the chart. Vertically, the chart has been sized to fit around the specified intervals. |
| 301 |
% |
| 302 |
% But this version is hardly satisfactory, for many reasons. The chart finishes between two minor ticks on the axis, |
| 303 |
% because the intervals between major and minor ticks default respectively to 10 years and 50 years. The black intervals |
| 304 |
% and text do not contrast well with the black axis and grid. The serif font is perhaps not best suited to label the |
| 305 |
% intervals. And the label `Augustus' has been lost, since labels are by default placed on the left of intervals. To |
| 306 |
% rectify these problems, some changes are necessary, all of which can be made using key-value syntax in an optional |
| 307 |
% parameter to the \env{timechart} environment or the \cs{timechartinterval} command: |
| 308 |
% \begin{enumerate} |
| 309 |
% \item Set the intervals between major and minor ticks to 5 years and 25 years respectively, by setting |
| 310 |
% \keyval{minor tick interval}{5} and \keyval{major tick interval}{25}. |
| 311 |
% \item Change the colour of the grid to light grey by appending \keyval{draw}{lightgray} to the \key{grid} style |
| 312 |
% \item Change the colour of the axis to grey by appending \keyval{draw}{gray} to the \key{axis line}, \key{minor |
| 313 |
% tick}, and \key{major tick} styles. |
| 314 |
% \item Change the font used for interval labels to small san-serif by appending \keyval{node |
| 315 |
% font}{\cs{sffamily}\cs{small}} to the \key{interval label} style |
| 316 |
% \item Change the colour of the intervals by defining a style \key{julioclaudian} that sets \keyval{interval bar |
| 317 |
% color}{red!80!black} and applying it to each interval via its optional argument. (While \key{interval bar |
| 318 |
% color} could be set locally for each interval, it is better to define a style that corresponds to the |
| 319 |
% semantic meaning of the colour: in this case, a single dynasty.) |
| 320 |
% \item Use the \key{right} key to place some labels on the right |
| 321 |
% \end{enumerate} |
| 322 |
% |
| 323 |
% The result is the following code, which produces \fullref{Figure}{fig:example2-v2}. |
| 324 |
% |
| 325 |
% \lstinputlisting{timechart-example2-v2.tex} |
| 326 |
% |
| 327 |
% \begin{figure}[ht] |
| 328 |
% \centering |
| 329 |
% \input{timechart-example2-v2.tex} |
| 330 |
% \caption{Chart showing the lifetimes of Roman emperors of the Julio-Claudian dynasty.} |
| 331 |
% \label{fig:example2-v2} |
| 332 |
% \end{figure} |
| 333 |
% |
| 334 |
% |
| 335 |
% |
| 336 |
% \section{Configuration} |
| 337 |
% |
| 338 |
% All \pkg{timechart} configuration, global or local, is via PGF keys, so some familiarity with their use is beneficial; |
| 339 |
% see the PGF/\TikZ\ manual. |
| 340 |
% |
| 341 |
% Configuration keys for \pkg{timechart} are contained in \key{/timechart/} in the PGF keys hierarchy. The |
| 342 |
% \meta{options} passed to the \env{timechart} environment or any of the commands \cs{timechartinterval}, |
| 343 |
% \cs{timecharttext}, or \cs{timechartspace} are processed within \key{/timechart/} (since \key{/timechart/.cd} is |
| 344 |
% executed before keys are processed). |
| 345 |
% |
| 346 |
% The user may wish to define PGF styles for different kinds of interval within a chart. For example, one could |
| 347 |
% define styles \key{science} and \key{art} that set a particular colour for the interval, and write |
| 348 |
% \cs{timechartinterval}\key{[science]}\marg{birth}\marg{death}\marg{name} or |
| 349 |
% \cs{timechartinterval}\key{[art]}\marg{birth}\marg{death}\marg{name} to distinguish visually the lifetimes of |
| 350 |
% various scientists and artists. |
| 351 |
% |
| 352 |
% |
| 353 |
% |
| 354 |
% \section{Specifying dates and date ranges} |
| 355 |
% \label{sec:dates-and-ranges} |
| 356 |
% |
| 357 |
% Using \pkg{timechart} requires specification of dates and date ranges for the start and finish of each interval, both |
| 358 |
% of which may be uncertain. |
| 359 |
% |
| 360 |
% The basic specification of a date uses \ISO~8601 format \mcode{YYYY-MM-DD}. This format specifies a date with |
| 361 |
% day-level precision; use \mcode{YYYY-MM} and \mcode{YYYY} for month- and year-level precision. If the date is prefixed |
| 362 |
% by \mcode{-}, it is treated as the corresponding date before the epoch. (This is a difference with \ISO~8601, in which |
| 363 |
% \texttt{0} represents \timechartmakebeforeyear{1}, \texttt{-1} represents \timechartmakebeforeyear{2}, and so on.) So |
| 364 |
% (assuming that one is using \textsc{bce}/\textsc{ce}) one uses \mcode{-100} to indicate \timechartmakebeforeyear{100} |
| 365 |
% and \mcode{100} to indicate \timechartmakeafteryear{100}. (The era indicators `\textsc{bce}' and `\textsc{ce}' appear |
| 366 |
% on the axis. Alternative era indicators --- or a different epoch --- can be specified; see |
| 367 |
% \fullref{Section}{sec:era-indicators}.) |
| 368 |
% |
| 369 |
% A date can be prefixed with a \mcode{c} to indicate `circa', such as \mcode{c-100} for `circa |
| 370 |
% \timechartmakebeforeyear{100}' and \mcode{c100} for `circa \timechartmakeafteryear{100}'. When an interval is drawn in |
| 371 |
% a chart, `circa' will be indicated by automatically creating (or extending) a range according to the value of the key |
| 372 |
% \key{circa uncertainty} (see \fullref{Subsection}{subsec:intervals}). |
| 373 |
% |
| 374 |
% A date range comprises two dates (each with or without \mcode{c}) separated by a slash \mcode{/}, with the first date |
| 375 |
% being earlier (or equal to) the second date. (The slash indicates a range of dates per \ISO~8601.) A date |
| 376 |
% range can be used to indicate a broader uncertainty than the default `circa', or to indicate a definite range within |
| 377 |
% which an interval starts or ends. |
| 378 |
% |
| 379 |
% \begin{description} |
| 380 |
% \item[Examples of correctly formatted dates and date ranges:] \mcode{-50}, \mcode{100}, \mcode{c-50}, |
| 381 |
% \mcode{c100}, \mcode{-50/100}, \mcode{c-50 / +100}, \mcode{-50/c100}, \mcode{c-50/c100}, \mcode{-585-05-28}, |
| 382 |
% \mcode{1947-12-01}, \mcode{1989-11}. |
| 383 |
% |
| 384 |
% \item[Examples of incorrectly formatted date and date ranges:] \mcode{100?}, \mcode{100CE}, \mcode{100BCE}, |
| 385 |
% \mcode{-50-100}, \mcode{100/-50}. |
| 386 |
% \end{description} |
| 387 |
% |
| 388 |
% \noindent That is, the syntax for dates and date ranges is per the following (not-quite-formal) grammar: |
| 389 |
% |
| 390 |
% \smallskip |
| 391 |
% |
| 392 |
% \begin{bnf} |
| 393 |
% \meta{cdate-or-crange} ::= \meta{cdate} |
| 394 |
% | \meta{crange} ;; |
| 395 |
% \meta{cdate} ::= \meta{date} |
| 396 |
% | \mcode{c}\meta{date} ;; |
| 397 |
% \meta{date} ::= \meta{pdate} |
| 398 |
% | \mcode{-}\meta{pdate} ;; |
| 399 |
% \meta{pdate} ::= \meta{year}\mcode{-}\meta{month}\mcode{-}\meta{day} |
| 400 |
% | \meta{year}\mcode{-}\meta{month} |
| 401 |
% | \meta{year} ;; |
| 402 |
% \meta{crange} ::= \meta{\(\text{date}_1\)}\mcode{/}\meta{\(\text{date}_2\)} |
| 403 |
% | \mcode{c}\meta{\(\text{date}_1\)}\mcode{/}\meta{\(\text{date}_2\)} |
| 404 |
% | \meta{\(\text{date}_1\)}\mcode{/}\mcode{c}\meta{\(\text{date}_2\)} |
| 405 |
% | \mcode{c}\meta{\(\text{date}_1\)}\mcode{/}\mcode{c}\meta{\(\text{date}_2\)} ~~~(with \(\text{date}_1 \leq \text{date}_2\)) ;; |
| 406 |
% \end{bnf} |
| 407 |
% |
| 408 |
% \smallskip |
| 409 |
% |
| 410 |
% \noindent The bounds of the \env{timechart} environment (see \fullref{Section}{sec:timechart-env}) must satisfy |
| 411 |
% \meta{cdate} in this grammar (although only the \meta{year} is used); the start and finish dates of an |
| 412 |
% \cs{timechartinterval} command (see \fullref{Subsection}{subsec:intervals}) must satisfy \meta{cdate-or-crange}; the |
| 413 |
% parameter of an \cs{timecharttext} command (see \fullref{Subsection}{subsec:text}) must satisfy \meta{date}. |
| 414 |
% |
| 415 |
% \medskip |
| 416 |
% \noindent \textit{Note.} For performance reasons, the date parser does only limited error-checking. Months outside the |
| 417 |
% range from \mcode{01} to \mcode{12} or days outside the range of the specified month will be ignored. Otherwise |
| 418 |
% malformed dates or date ranges may produce obscure error messages or unexpected results. |
| 419 |
% |
| 420 |
% |
| 421 |
% |
| 422 |
% \section{\env{timechart} environment} |
| 423 |
% \label{sec:timechart-env} |
| 424 |
% |
| 425 |
% \begin{function}{timechart} |
| 426 |
% \begin{syntax} |
| 427 |
% \cs{begin}\texttt{\{}\env{timechart}\texttt{\}}\oarg{options}\marg{start}\marg{finish} |
| 428 |
% \meta{content} |
| 429 |
% \cs{end}\texttt{\{}\env{timechart}\texttt{\}} |
| 430 |
% \end{syntax} |
| 431 |
% This is the main environment for creating a chronological chart. The mandatory arguments \meta{start} and |
| 432 |
% \meta{finish} specify the first and last years of the chart. These can be dates with circa indicators (that is, they |
| 433 |
% satisfy \meta{cdate} in the grammar in \fullref{Section}{sec:dates-and-ranges}), but the circa specifier has no |
| 434 |
% effect and only the `year' part of the date is used. The optional argument \meta{options} supplies PGF keys that |
| 435 |
% apply to the entire chart. |
| 436 |
% |
| 437 |
% The \meta{content} comprises commands like \cs{timechartinterval}, \cs{timecharttext}, \cs{timechartspace}, |
| 438 |
% commands for positioning, as described in \fullref{Section}{sec:within}, and the user's own \TikZ\ code. |
| 439 |
% \end{function} |
| 440 |
% |
| 441 |
% |
| 442 |
% |
| 443 |
% \subsection{General configuration of the \env{timechart} environment} |
| 444 |
% |
| 445 |
% \begin{describekey}{/timechart/width}{dimension}{\cs{textwidth}} |
| 446 |
% The width of the chart. This refers to the width of the grid and axis of the chart, not |
| 447 |
% including intervals that pass beyond the specified limits of the chart, or axis labels that protrude beyond the |
| 448 |
% width of the axis itself. |
| 449 |
% \end{describekey} |
| 450 |
% |
| 451 |
% |
| 452 |
% \begin{describekey}{/timechart/tolerance}{dimension}{5pt} |
| 453 |
% The length by which an interval is allowed to pass beyond the limits of the chart before it `counts' as doing so |
| 454 |
% and the appropriate indicator is drawn. |
| 455 |
% \end{describekey} |
| 456 |
% |
| 457 |
% |
| 458 |
% \begin{describekey}{/timechart/beyond length}{dimension}{5pt} |
| 459 |
% The length of the indicator that an interval passes beyond the limits of the chart. |
| 460 |
% \end{describekey} |
| 461 |
% |
| 462 |
% \begin{describekey}{/timechart/beyond x radius}{dimension}{4pt} |
| 463 |
% The horizontal radius of the concave part of the indicator that an interval passes beyond the limits of the chart. |
| 464 |
% (The vertical radius will be half the thickness of the bar.) |
| 465 |
% \end{describekey} |
| 466 |
% |
| 467 |
% \begin{describekey}{/timechart/ystep}{dimension}{-10pt} |
| 468 |
% The default length (positive or negative) by which the current \(y\) coordinate is automatically adjusted after each |
| 469 |
% interval, text, or space is placed. |
| 470 |
% \end{describekey} |
| 471 |
% |
| 472 |
% \begin{describekey}{/timechart/minor tick interval}{number}{10} |
| 473 |
% The number of years (which must be positive) between each minor tick on the axis. |
| 474 |
% \end{describekey} |
| 475 |
% |
| 476 |
% \begin{describekey}{/timechart/major tick interval}{number}{50} |
| 477 |
% The number of years (which must be positive) between each major tick on the axis and each vertical line in the grid. |
| 478 |
% \end{describekey} |
| 479 |
% |
| 480 |
% |
| 481 |
% |
| 482 |
% \subsection{Grid configuration} |
| 483 |
% |
| 484 |
% \begin{describekey}{/timechart/no grid}{}{} |
| 485 |
% Do not draw the grid. |
| 486 |
% \end{describekey} |
| 487 |
% |
| 488 |
% \begin{describekey}{/timechart/grid top ysep}{dimension}{3pt} |
| 489 |
% Distance between the top of the grid and the topmost interval or space. |
| 490 |
% \end{describekey} |
| 491 |
% |
| 492 |
% \begin{describekey}{/timechart/grid bottom ysep}{dimension}{3pt} |
| 493 |
% Distance between the bottom of the grid and the bottommost interval or space. |
| 494 |
% \end{describekey} |
| 495 |
% |
| 496 |
% \begin{describekey}{/timechart/grid}{style}{empty} |
| 497 |
% Style for drawing the grid. |
| 498 |
% \end{describekey} |
| 499 |
% |
| 500 |
% |
| 501 |
% |
| 502 |
% \subsection{Axis configuration} |
| 503 |
% |
| 504 |
% \begin{describekey}{/timechart/axis}{position}{above} |
| 505 |
% Where and whether to draw the axis. \meta{position} may be \val{above}, \val{below}, or |
| 506 |
% \val{none}. |
| 507 |
% \end{describekey} |
| 508 |
% |
| 509 |
% \begin{describekey}{/timechart/no axis}{}{} |
| 510 |
% Do not draw the axis. Equivalent to \keyval{/timechart/axis}{none}. |
| 511 |
% \end{describekey} |
| 512 |
% |
| 513 |
% \begin{describekey}{/timechart/axis line}{style}{\keyval{line cap}{rect}} |
| 514 |
% Style for drawing the axis line. |
| 515 |
% \end{describekey} |
| 516 |
% |
| 517 |
% \begin{describekey}{/timechart/minor tick}{style}{empty} |
| 518 |
% Style for drawing minor ticks. |
| 519 |
% \end{describekey} |
| 520 |
% |
| 521 |
% \begin{describekey}{/timechart/minor tick length}{dimension}{1.5mm} |
| 522 |
% Length of minor ticks. |
| 523 |
% \end{describekey} |
| 524 |
% |
| 525 |
% \begin{describekey}{/timechart/major tick}{style}{empty} |
| 526 |
% Style for drawing major ticks. |
| 527 |
% \end{describekey} |
| 528 |
% |
| 529 |
% \begin{describekey}{/timechart/major tick length}{dimension}{3mm} |
| 530 |
% Length of major ticks. |
| 531 |
% \end{describekey} |
| 532 |
% |
| 533 |
% \begin{describekey}{/timechart/major tick label}{style}{as described below} |
| 534 |
% Style for labels on the major ticks on the axis. The intial style essentially sets \keyval{inner sep}{0}, |
| 535 |
% \keyval{outer sep}{0}, \keyval{anchor}{mid west}, \keyval{rotate}{90}. |
| 536 |
% \end{describekey} |
| 537 |
% |
| 538 |
% \begin{describekey}{/timechart/major tick eras}{locations}{outer} |
| 539 |
% Which major tick labels have era indicators. \meta{locations} may be \val{none}, \val{all}, or \val{outer} (which |
| 540 |
% means that only the first and last labels have era indicators). This option does not affect the epoch marker (see |
| 541 |
% \fullref{Subsection}{subsec:year-zero}). |
| 542 |
% \end{describekey} |
| 543 |
% |
| 544 |
% |
| 545 |
% |
| 546 |
% \section{Within the \env{timechart} environment} |
| 547 |
% \label{sec:within} |
| 548 |
% |
| 549 |
% |
| 550 |
% |
| 551 |
% \subsection{Intervals} |
| 552 |
% \label{subsec:intervals} |
| 553 |
% |
| 554 |
% \begin{function}{\timechartinterval} |
| 555 |
% \begin{syntax} |
| 556 |
% \cs{timechartinterval}\oarg{options}\marg{start}\marg{finish}\marg{label} |
| 557 |
% \end{syntax} |
| 558 |
% This command creates an interval in the chart at the current \(y\) coordinate between the specified \meta{start} and |
| 559 |
% \meta{finish}, with the given \meta{label}. These arguments are mandatory. Each of \meta{start} and \meta{finish} |
| 560 |
% can be either a year or a range of years, possibly with circa markers. That is, each must satisfy |
| 561 |
% \meta{cyear-or-crange} in the grammar in \fullref{Section}{sec:dates-and-ranges}. |
| 562 |
% |
| 563 |
% The optional argument \meta{options} specifies PGF keys within \key{/timechart/} that are applied locally to the |
| 564 |
% interval. |
| 565 |
% |
| 566 |
% The current \(y\) coordinate will be adjusted according to \key{/timechart/ystep} unless \key{/timechart/no |
| 567 |
% autostep} has been set. |
| 568 |
% \end{function} |
| 569 |
% |
| 570 |
% |
| 571 |
% |
| 572 |
% \subsubsection{Interval configuration} |
| 573 |
% |
| 574 |
% \begin{describekey}{/timechart/no autostep}{}{} |
| 575 |
% Do not automatically alter the current \(y\) coordinate by the amount specified in \key{/timechart/ystep}. |
| 576 |
% \end{describekey} |
| 577 |
% |
| 578 |
% \begin{describekey}{/timechart/ref}{label}{none} |
| 579 |
% Make the interval label a hyperlink to the position labelled by \meta{label}. |
| 580 |
% \end{describekey} |
| 581 |
% |
| 582 |
% \begin{describekey}{/timechart/mark}{comma-separated list of years}{empty} |
| 583 |
% Draw marks in the interval at the years contained in the list. Each entry in the list must be a definite year (that |
| 584 |
% is, must satisfy \meta{year} in the grammar in \fullref{Section}{sec:dates-and-ranges}), must lie in the definite |
| 585 |
% part of the interval (not in the start or finish ranges) and cannot lie beyond the bounds of the chart on a side |
| 586 |
% where there interval exceeds tolerance. The colour of marks can be specified using \key{/timechart/interval mark |
| 587 |
% color}. \key{/timechart/marks} is a synonym for this key. |
| 588 |
% \end{describekey} |
| 589 |
% |
| 590 |
% \begin{describekey}{/timechart/circa uncertainty}{number}{3} |
| 591 |
% Treat a circa indicator \mcode{c} as indicating an uncertainity of \(\pm\meta{number}\). |
| 592 |
% \end{describekey} |
| 593 |
% |
| 594 |
% \begin{describekey}{/timechart/interval minimum width}{dimension}{1pt} |
| 595 |
% Ensure that any interval has a width of at least \meta{dimension}. This is useful to ensure that a single event is |
| 596 |
% visible in the chart. |
| 597 |
% |
| 598 |
% If an interval is specified with start and finish ranges, and with \keyval{start range}{fade} and \keyval{finish |
| 599 |
% range}{fade}, then the `certain' portion of the interval will also have width at least \meta{dimension}. (This |
| 600 |
% restriction prevents a common rendering error where start and finish fadings around a `certain' interval of length |
| 601 |
% \(0\) would not quite meet.) |
| 602 |
% \end{describekey} |
| 603 |
% |
| 604 |
% \begin{describekey}{/timechart/interval bar color}{color}{black} |
| 605 |
% Fill the interval bar with \meta{color}. |
| 606 |
% \end{describekey} |
| 607 |
% |
| 608 |
% \begin{describekey}{/timechart/interval bar thickness}{dimension}{8pt} |
| 609 |
% Set the vertical thickness of the interval bar to \meta{dimension}. |
| 610 |
% \end{describekey} |
| 611 |
% |
| 612 |
% \begin{describekey}{/timechart/interval bar node name}{string}{bar node} |
| 613 |
% Set the name of the node containing the interval bar to \meta{string}. |
| 614 |
% \end{describekey} |
| 615 |
% |
| 616 |
% \begin{describekey}{/timechart/interval mark color}{color}{gray} |
| 617 |
% Draw marks using \meta{color}. |
| 618 |
% \end{describekey} |
| 619 |
% |
| 620 |
% \begin{describekey}{/timechart/interval label}{style}{empty} |
| 621 |
% Style to apply to an interval label. |
| 622 |
% \end{describekey} |
| 623 |
% |
| 624 |
% \begin{describekey}{/timechart/interval label centered}{style}{as below} |
| 625 |
% Style to apply to an interval label placed centrally. Initially, this style executes the style |
| 626 |
% \key{/timechart/interval label} and sets \keyval{text}{white}. The reason for a separate style for centred labels is |
| 627 |
% that often a contrasting colour will be required. For instance, labels positioned to the left and right may be |
| 628 |
% black, but if the bar is black, a centred label should be a light colour. |
| 629 |
% \end{describekey} |
| 630 |
% |
| 631 |
% \begin{describekey}{/timechart/interval label centered background}{style}{as below} |
| 632 |
% Style to apply to the `background' interval label placed centrally. Initially, this style executes |
| 633 |
% \key{/timechart/interval label}. The `background' interval label is simply the usual label and is placed in the same |
| 634 |
% location, but on a layer behind the bar and, unlike the label itself, is not clipped. The reason for this style is |
| 635 |
% that if the bar is narrow, part of the label text (such as ascenders and/or descenders) may naturally extend beyond |
| 636 |
% the bar itself and it may be useful that thse should appear in a different colour. |
| 637 |
% \end{describekey} |
| 638 |
% |
| 639 |
% \begin{describekey}{/timechart/interval label baseline}{dimension}{-3pt} |
| 640 |
% Position the baseline of the interval label \meta{dimension} below the current \(y\) coordinate (which is the |
| 641 |
% midpoint of the interval bar). |
| 642 |
% \end{describekey} |
| 643 |
% |
| 644 |
% \begin{describekey}{/timechart/interval label pos}{position}{left} |
| 645 |
% Specify where to place the label relative to the interval bar: \meta{position} may be \val{left}, \val{center}, or |
| 646 |
% \val{right}. The position \val{center} places the label at the midpoint of \emph{the visible segment of the solid |
| 647 |
% part} of the interval bar (that is, not including fading at the start or finish of the bar, and not including part |
| 648 |
% of the bart that would extend beyond the bounds of the chart). Further, a centred label is clipped to the size of |
| 649 |
% the bar and a unclipped `background' copy of it is drawn behind the bar, so that the portion appearing `on' and |
| 650 |
% `outside' the bar can have different styles. (See the keys \key{/timechart/interval label centered} and |
| 651 |
% \key{/timechart/interval label centered background}.) |
| 652 |
% \end{describekey} |
| 653 |
% |
| 654 |
% \begin{describekey}{/timechart/interval label node name}{string}{label node} |
| 655 |
% Set the name of the node containing the interval label to \meta{string}. |
| 656 |
% \end{describekey} |
| 657 |
% |
| 658 |
% \begin{describekey}{/timechart/start range}{range-type}{fade} |
| 659 |
% Type of indication of the range where an interval may start. \meta{range-type} can be \val{fade}, which produces an |
| 660 |
% indicator like \timechartlegendstartrange[legend item width=8mm], or \val{slant}, which produces |
| 661 |
% \timechartlegendstartrange[legend item width=8mm,start range=slant]. |
| 662 |
% \end{describekey} |
| 663 |
% |
| 664 |
% \begin{describekey}{/timechart/finish range}{range-type}{fade} |
| 665 |
% Type of indication of the range where an interval may finish. \meta{range-type} can be \val{fade}, which produces an |
| 666 |
% indicator like \timechartlegendfinishrange[legend item width=8mm], or \val{slant}, which produces |
| 667 |
% \timechartlegendfinishrange[legend item width=8mm,finish range=slant]. |
| 668 |
% \end{describekey} |
| 669 |
% |
| 670 |
% |
| 671 |
% |
| 672 |
% \subsection{Text} |
| 673 |
% \label{subsec:text} |
| 674 |
% |
| 675 |
% \begin{function}{\timecharttext} |
| 676 |
% \begin{syntax} |
| 677 |
% \cs{timecharttext}\oarg{options}\marg{year}\marg{text} |
| 678 |
% \end{syntax} |
| 679 |
% Place \meta{text} in the time chart at the current \(y\) coordinate and at the horizontal position of \meta{year}, |
| 680 |
% which must be a definite year (that is, must satsify \meta{year} in the grammar in |
| 681 |
% \fullref{Section}{sec:dates-and-ranges}). |
| 682 |
% |
| 683 |
% The optional argument \meta{options} specifies PGF keys within \key{/timechart/} that are applied locally. |
| 684 |
% |
| 685 |
% The current \(y\) coordinate will be adjusted according to \key{/timechart/ystep} unless \key{/timechart/no |
| 686 |
% autostep} has been set. |
| 687 |
% \end{function} |
| 688 |
% |
| 689 |
% |
| 690 |
% |
| 691 |
% \subsubsection{Text configuration} |
| 692 |
% |
| 693 |
% \begin{describekey}{/timechart/text node name}{string}{text node} |
| 694 |
% Set the name of the node containing the text to \meta{string}. |
| 695 |
% \end{describekey} |
| 696 |
% |
| 697 |
% \begin{describekey}{/timechart/text}{style}{empty} |
| 698 |
% Style to apply to the text. |
| 699 |
% \end{describekey} |
| 700 |
% |
| 701 |
% \begin{describekey}{/timechart/text baseline}{dimension}{-3pt} |
| 702 |
% Position the baseline of the text \meta{dimension} below the current \(y\) coordinate. |
| 703 |
% \end{describekey} |
| 704 |
% |
| 705 |
% \begin{describekey}{/timechart/text pos}{position}{left} |
| 706 |
% Specify where to place the label relative to the given \meta{year}: \meta{position} may be \val{left}, \val{center}, |
| 707 |
% or \val{right}. |
| 708 |
% \end{describekey} |
| 709 |
% |
| 710 |
% |
| 711 |
% |
| 712 |
% \subsection{Space} |
| 713 |
% |
| 714 |
% \begin{function}{\timechartspace} |
| 715 |
% \begin{syntax} |
| 716 |
% \cs{timechartspace}\oarg{options} |
| 717 |
% \end{syntax} |
| 718 |
% Create a space in the time chart at the current \(y\) coordinate, with the same effect on vertical spacing as an |
| 719 |
% interval. More precisely, the current \(y\) coordinate will be adjusted according to \key{/timechart/ystep} unless |
| 720 |
% \key{/timechart/no autostep} has been set. |
| 721 |
% |
| 722 |
% The optional argument \meta{options} specifies PGF keys within \key{/timechart/} that are applied locally. |
| 723 |
% \end{function} |
| 724 |
% |
| 725 |
% |
| 726 |
% |
| 727 |
% \subsection{Positioning} |
| 728 |
% \label{subsec:positioning} |
| 729 |
% |
| 730 |
% The commands \cs{timechartinterval}, \cs{timecharttext}, and \cs{timechartspace} all act at the current \(y\) |
| 731 |
% coordinate and change its value according to \key{/timechart/ystep} (unless \key{/timechart/no autostep} is used). |
| 732 |
% There are several functions to set the current \(y\) coordinate and to have it reset automatically. |
| 733 |
% |
| 734 |
% \begin{function}{\timechartsety} |
| 735 |
% \begin{syntax} |
| 736 |
% \cs{timechartsety}\marg{dimension} |
| 737 |
% \end{syntax} |
| 738 |
% Set the current \(y\) coordinate to \meta{dimension}. |
| 739 |
% \end{function} |
| 740 |
% |
| 741 |
% \begin{function}{\timechartsavey} |
| 742 |
% \begin{syntax} |
| 743 |
% \cs{timechartsavey} |
| 744 |
% \end{syntax} |
| 745 |
% Save the current \(y\) coordinate. If \cs{timechartresety} is used, the \(y\) coordinate resets to the last saved |
| 746 |
% \(y\) coordinate. If the current \(y\) coordinate exceeds the minimum or maximum set by |
| 747 |
% \cs{timechartsetyminimumautoreset} and \cs{timechartsetymaximumautoreset}, it will be reset to the last saved \(y\) |
| 748 |
% coordinate. |
| 749 |
% \end{function} |
| 750 |
% |
| 751 |
% \begin{function}{\timechartresety} |
| 752 |
% \begin{syntax} |
| 753 |
% \cs{timechartresety} |
| 754 |
% \end{syntax} |
| 755 |
% Reset the \(y\) coordinate to the last coordinate saved using \cs{timechartsavey}, or to \(0\) if there has been no |
| 756 |
% use of \cs{timechartsavey} within the current \env{timechart} environment. |
| 757 |
% \end{function} |
| 758 |
% |
| 759 |
% \begin{function}{\timechartsetyminimumautoreset, \timechartsetymaximumautoreset} |
| 760 |
% \begin{syntax} |
| 761 |
% \cs{timechartsetyminimumautoreset}\marg{min-coordinate} |
| 762 |
% \cs{timechartsetymaximumautoreset}\marg{max-coordinate} |
| 763 |
% \end{syntax} |
| 764 |
% Set \(y\) coordinates that automatically trigger \cs{timechartresety} if the current \(y\) coordinate goes below |
| 765 |
% \meta{min-coordinate} or above \meta{max-coordinate}. |
| 766 |
% \end{function} |
| 767 |
% |
| 768 |
% \begin{function}{\timechartstepy} |
| 769 |
% \begin{syntax} |
| 770 |
% \cs{timechartstepy}\oarg{count} |
| 771 |
% \end{syntax} |
| 772 |
% Manually step the current \(y\) coordinate by \meta{count} times the value of \key{/timechart/ystep}. The default |
| 773 |
% value of \meta{count} is 1. (The \key{/timechart/no autostep} does not affect \cs{timechartstepy}.) |
| 774 |
% \end{function} |
| 775 |
% |
| 776 |
% |
| 777 |
% |
| 778 |
% \subsection{Completion} |
| 779 |
% |
| 780 |
% \begin{function}{\timechartfinish} |
| 781 |
% Signal that the chart is complete and that the grid and axis should be drawn (unless the keys \key{/timechart/no |
| 782 |
% grid} and/or \key{/timechart/no axis} have been used). It is not necessary to use this command: if it is not given, |
| 783 |
% the grid and axis will be drawn at the end of the \env{timechart} environment. But after this command, the \TikZ\ |
| 784 |
% nodes \texttt{grid} and \texttt{axis} are available, containing (respectively) the grid and the axis. These can be |
| 785 |
% used in for further \TikZ\ drawing. |
| 786 |
% |
| 787 |
% Note that after \cs{timechartfinish}, none of the various \cs{timechart}\ldots\ commands are available inside that |
| 788 |
% \env{timechart} environment. |
| 789 |
% \end{function} |
| 790 |
% |
| 791 |
% |
| 792 |
% |
| 793 |
% \subsection{Shortcut keys} |
| 794 |
% |
| 795 |
% \begin{describekey}{/timechart/left}{}{} |
| 796 |
% Equivalent to setting \key{/timechart/interval label pos} and \key{/timechart/text pos} to \val{left}. |
| 797 |
% \end{describekey} |
| 798 |
% |
| 799 |
% \begin{describekey}{/timechart/center}{}{} |
| 800 |
% Equivalent to setting \key{/timechart/interval label pos} and \key{/timechart/text pos} to \val{center}. |
| 801 |
% \end{describekey} |
| 802 |
% |
| 803 |
% \begin{describekey}{/timechart/right}{}{} |
| 804 |
% Equivalent to setting \key{/timechart/interval label pos} and \key{/timechart/text pos}{right} to \val{right}. |
| 805 |
% \end{describekey} |
| 806 |
% |
| 807 |
% |
| 808 |
% |
| 809 |
% \section{Era indicators} |
| 810 |
% \label{sec:era-indicators} |
| 811 |
% |
| 812 |
% \begin{function}{\timechartmakebeforeyear,\timechartmakeafteryear} |
| 813 |
% \begin{syntax} |
| 814 |
% \cs{timechartmakebeforeyear}\marg{number} |
| 815 |
% \cs{timechartmakeafteryear}\marg{number} |
| 816 |
% \end{syntax} |
| 817 |
% Typeset \meta{number} (which should be a positive whole number) as a year before or after the epoch. By default, |
| 818 |
% \cs{timechartmakebeforeyear}\marg{number} produces \timechartmakebeforeyear{\meta{number}} and |
| 819 |
% \cs{timechartmakeafteryear}\marg{number} produces \timechartmakeafteryear{\meta{number}}. |
| 820 |
% |
| 821 |
% These commands are used for axis labels and can be re-defined by the user. For example, if \textsc{bc}/\textsc{ad} |
| 822 |
% is preferred to \textsc{bce}/\textsc{ce}, the user can define |
| 823 |
% \iffalse |
| 824 |
%<*example> |
| 825 |
% \fi |
| 826 |
\begin{lstlisting} |
| 827 |
\renewcommand*{\timechartmakebeforeyear}[1]{#1~\textsc{bc}} |
| 828 |
\renewcommand*{\timechartmakeafteryear}[1]{\textsc{ad}~#1} |
| 829 |
\end{lstlisting} |
| 830 |
% \iffalse |
| 831 |
%</example> |
| 832 |
% \fi |
| 833 |
% Similarly, if \textsc{ah}/\textsc{bh} is preferred, the user can define |
| 834 |
% \iffalse |
| 835 |
%<*example> |
| 836 |
% \fi |
| 837 |
\begin{lstlisting} |
| 838 |
\renewcommand*{\timechartmakebeforeyear}[1]{#1~\textsc{bh}} |
| 839 |
\renewcommand*{\timechartmakeafteryear}[1]{\textsc{ah}~#1} |
| 840 |
\end{lstlisting} |
| 841 |
% \iffalse |
| 842 |
%</example> |
| 843 |
% \fi |
| 844 |
% \end{function} |
| 845 |
% |
| 846 |
% |
| 847 |
% |
| 848 |
% \section{Legend} |
| 849 |
% \label{sec:keys} |
| 850 |
% |
| 851 |
% \pkg{timechart} supplies a number of auxiliary macros for creating a legend to explain, for example the significance |
| 852 |
% of different colours of intervals. For example, \fullref{Figure}{fig:example1-legend} shows a suitable legend for |
| 853 |
% \fullref{Figure}{fig:example1}. |
| 854 |
% |
| 855 |
% \begin{figure}[t] |
| 856 |
% \centering |
| 857 |
% \input{timechart-example1-legend.tex} |
| 858 |
% \caption{Example legend for the timechart shown in \fullref{Figure}{fig:example1}.} |
| 859 |
% \label{fig:example1-legend} |
| 860 |
% \end{figure} |
| 861 |
% |
| 862 |
% The \cs{timechartlength}\ldots\ macros are \emph{not} meant to be used inside a \env{timechart} environment, but in |
| 863 |
% locations such as running text or a \env{tabular} environment. |
| 864 |
% |
| 865 |
% \begin{function}{\timechartlegenditem} |
| 866 |
% \begin{syntax} |
| 867 |
% \cs{timechartlegenditem}\oarg{options} |
| 868 |
% \end{syntax} |
| 869 |
% Draw a bar suitable for use in a legend. \meta{options} specifies PGF keys that are applied within |
| 870 |
% \key{/timechart}. The same PGF keys that affect interval bars affect the drawn bar, as do the keys listed below. |
| 871 |
% \end{function} |
| 872 |
% |
| 873 |
% \begin{function}{\timechartlegendstartrange, \timechartlegendfinishrange} |
| 874 |
% \begin{syntax} |
| 875 |
% \cs{timechartlegendstartrange}\oarg{options} |
| 876 |
% \cs{timechartlegendfinishrange}\oarg{options} |
| 877 |
% \end{syntax} |
| 878 |
% Draw a bar suitable for use in a legend, with a start or finish range. \meta{options} specifies PGF keys that are |
| 879 |
% applied within \key{/timechart/}. The same PGF keys that affect interval bars affect the drawn bar, as do the |
| 880 |
% keys listed below. |
| 881 |
% \end{function} |
| 882 |
% |
| 883 |
% \begin{describekey}{/timechart/legend item width}{dimension}{9mm} |
| 884 |
% When using macros \cs{timechartlegenditem}, \cs{timechartlegendstartrange}, or \cs{timechartlegendfinishrange}, draw |
| 885 |
% a bar of total width \meta{dimension}. |
| 886 |
% \end{describekey} |
| 887 |
% |
| 888 |
% \begin{describekey}{/timechart/legend item range width}{dimension}{3mm} |
| 889 |
% When using \cs{timechartlegendstartrange} or \cs{timechartlegendfinishrange}, draw a bar with a range of width |
| 890 |
% \meta{dimension}. |
| 891 |
% \end{describekey} |
| 892 |
% |
| 893 |
% |
| 894 |
% |
| 895 |
% \section{Usage notes} |
| 896 |
% |
| 897 |
% \subsection{Additional \TikZ\ code} |
| 898 |
% |
| 899 |
% The \env{timechart} environment is a \env{tikzpicture}. The user can add any \TikZ\ code before, between, or after |
| 900 |
% content created using the \cs{timechart}\ldots\ commands. Each use of \cs{timechartinterval} defines two nodes. One, |
| 901 |
% by default named \val{bar node}, contains the interval bar; the other, by default named \val{label node}, contains the |
| 902 |
% interval label. Similarly, text added using \cs{timecharttext} is contained in a node, by default named \val{text |
| 903 |
% node}. (The default names are re-used, but can be changed using the keys \key{/timechart/interval bar node name}, |
| 904 |
% \key{/timechart/interval label node name}, and \key{/timechart/text node name}.) The user can use these nodes to |
| 905 |
% position extra content. |
| 906 |
% |
| 907 |
% If the \cs{timechartfinish} command is used (after which the \cs{timechart}\ldots\ commands are no longer available |
| 908 |
% within the \env{timechart} environment) the nodes \mcode{grid} and \mcode{axis}, which contain the grid and the axis, |
| 909 |
% are also available. |
| 910 |
% |
| 911 |
% |
| 912 |
% |
| 913 |
% \subsection{\texorpdfstring{`year zero'}{year zero}} |
| 914 |
% \label{subsec:year-zero} |
| 915 |
% |
| 916 |
% Although calendars typically do not admit a `year zero' (for instance, \timechartmakebeforeyear{1} is immediately |
| 917 |
% followed by \timechartmakeafteryear{1}, with no intervening `year zero'), \pkg{timechart} does allow \val{0} for the |
| 918 |
% \meta{start} or \meta{finish} of the \env{timechart} environment or as the \meta{start} or \meta{finish} of |
| 919 |
% \cs{timechartinterval} or the \meta{year} of \cs{timecharttext}. But `year zero' is indicated on the axis by a special |
| 920 |
% epoch marker showing the last year before and first year after the epoch. |
| 921 |
% |
| 922 |
% |
| 923 |
% |
| 924 |
% \section{Feature requests and bug reports} |
| 925 |
% |
| 926 |
% The development code and issue tracker are hosted at Codeberg: \url{https://codeberg.org/ajcain/timechart} |
| 927 |
% |
| 928 |
% |
| 929 |
% |
| 930 |
% \section{Appendix: full example source} |
| 931 |
% \label{sec:full-example} |
| 932 |
% |
| 933 |
% This section contains the necessary source code to produce the example timechart and legend shown in |
| 934 |
% \fullref{Figures}{fig:example1} and \ref{fig:example1-legend} on pages \pageref{fig:example1} and |
| 935 |
% \pageref{fig:example1-legend}. |
| 936 |
% |
| 937 |
% |
| 938 |
% |
| 939 |
% \subsection{Setup source} |
| 940 |
% |
| 941 |
% \lstinputlisting{timechart-example1-setup.tex} |
| 942 |
% |
| 943 |
% |
| 944 |
% |
| 945 |
% \subsection{Timechart source} |
| 946 |
% |
| 947 |
% \lstinputlisting[breaklines=true]{timechart-example1-timechart.tex} |
| 948 |
% |
| 949 |
% |
| 950 |
% |
| 951 |
% \subsection{Legend source} |
| 952 |
% |
| 953 |
% \lstinputlisting{timechart-example1-legend.tex} |
| 954 |
% |
| 955 |
% |
| 956 |
% |
| 957 |
% \end{documentation} |
| 958 |
% |
| 959 |
% |
| 960 |
% |
| 961 |
% \iffalse |
| 962 |
%<*example1-setup> |
| 963 |
\pgfkeys{ |
| 964 |
/timechart/.cd, |
| 965 |
julioclaudian/.style={ |
| 966 |
interval bar color=red!70!black, |
| 967 |
interval mark color=red!70!black!50!white |
| 968 |
}, |
| 969 |
fouremperors/.style={ |
| 970 |
interval bar color=green!65!black, |
| 971 |
interval mark color=green!65!black!50!white |
| 972 |
}, |
| 973 |
flavian/.style={ |
| 974 |
interval bar color=yellow!85!black, |
| 975 |
interval mark color=yellow!85!black!50!white |
| 976 |
}, |
| 977 |
nervaantonine/.style={ |
| 978 |
interval bar color=blue!80!black, |
| 979 |
interval mark color=blue!80!black!50!white |
| 980 |
}, |
| 981 |
fiveemperors/.style={ |
| 982 |
interval bar color=green!50!black, |
| 983 |
interval mark color=green!50!black!50!white |
| 984 |
}, |
| 985 |
severan/.style={ |
| 986 |
interval bar color=orange!80!black, |
| 987 |
interval mark color=orange!80!black!50!white |
| 988 |
}, |
| 989 |
thirdcentury/.style={ |
| 990 |
interval bar color=green!35!black, |
| 991 |
interval mark color=green!35!black!50!white |
| 992 |
}, |
| 993 |
tetrarchy/.style={ |
| 994 |
interval bar color=purple!70!black, |
| 995 |
interval mark color=purple!70!black!50!white |
| 996 |
}, |
| 997 |
constantinian/.style={ |
| 998 |
interval bar color=blue!65!white, |
| 999 |
interval mark color=blue!65!white!50!white |
| 1000 |
}, |
| 1001 |
valentinianic/.style={ |
| 1002 |
interval bar color=orange!60!black, |
| 1003 |
interval mark color=orange!60!black!50!white |
| 1004 |
}, |
| 1005 |
theodosian/.style={ |
| 1006 |
interval bar color=cyan, |
| 1007 |
interval mark color=cyan!50!white |
| 1008 |
}, |
| 1009 |
theodosian-east/.style={ |
| 1010 |
interval bar color=cyan!80!black, |
| 1011 |
interval mark color=cyan!80!black!50!white |
| 1012 |
}, |
| 1013 |
theodosian-west/.style={ |
| 1014 |
interval bar color=cyan!80!white, |
| 1015 |
interval mark color=cyan!80!white!50!white |
| 1016 |
}, |
| 1017 |
leonid/.style={ |
| 1018 |
interval bar color=purple!40!white, |
| 1019 |
interval mark color=purple!40!white!50!white |
| 1020 |
}, |
| 1021 |
justinian/.style={ |
| 1022 |
interval bar color=orange!60!white, |
| 1023 |
interval mark color=orange!60!white!50!white |
| 1024 |
}, |
| 1025 |
lastwest/.style={ |
| 1026 |
interval bar color=green!25!black, |
| 1027 |
interval mark color=green!25!black!50!white |
| 1028 |
}, |
| 1029 |
} |
| 1030 |
%</example1-setup> |
| 1031 |
%<*example1-timechart> |
| 1032 |
\begin{timechart}[ |
| 1033 |
axis line/.append style={ draw=gray, line width=.5pt }, |
| 1034 |
grid/.append style={ draw=lightgray!50!white, line width=.5pt }, |
| 1035 |
minor tick/.append style={ draw=gray }, |
| 1036 |
major tick/.append style={ line width=.5pt, draw=gray }, |
| 1037 |
major tick label/.append style={ node font=\small }, |
| 1038 |
interval label/.style={ node font=\sffamily\footnotesize }, |
| 1039 |
text/.style={ node font=\sffamily\small\itshape, }, |
| 1040 |
ystep=-3.25mm, |
| 1041 |
]{-50}{500} |
| 1042 |
|
| 1043 |
\pgfmathsetmacro{\mainlinecount}{46} |
| 1044 |
|
| 1045 |
\timechartsetyminimumautoreset{-3.25mm*\mainlinecount+1mm} |
| 1046 |
|
| 1047 |
\timechartinterval[interval bar color=gray,right,mark=-45]{-100}{-44}{Julius Caesar} |
| 1048 |
\timechartinterval[julioclaudian,right,mark=-27]{-63}{-14}{Augustus} |
| 1049 |
\timechartinterval[julioclaudian,right,mark=14]{-42}{37}{Tiberius} |
| 1050 |
\timechartinterval[julioclaudian,right,mark=37]{12}{41}{Caligula} |
| 1051 |
\timechartinterval[julioclaudian,right,mark=41]{-10}{54}{Claudius} |
| 1052 |
\timechartinterval[julioclaudian,right,mark=54]{37}{68}{Nero} |
| 1053 |
|
| 1054 |
\timechartinterval[fouremperors,mark=68]{-3}{69}{Galba} |
| 1055 |
\timechartinterval[fouremperors,mark=69]{32}{69}{Otho} |
| 1056 |
\timechartinterval[fouremperors,mark=69]{15}{69}{Vitellius} |
| 1057 |
|
| 1058 |
\timechartinterval[flavian,mark=69]{9}{79}{Vespasian} |
| 1059 |
\timechartinterval[flavian,mark=79]{39}{81}{Titus} |
| 1060 |
\timechartinterval[flavian,mark=81]{51}{96}{Domitian} |
| 1061 |
|
| 1062 |
\timechartinterval[nervaantonine,mark=96]{30}{98}{Nerva} |
| 1063 |
\timechartinterval[nervaantonine,mark=98]{53}{117}{Trajan} |
| 1064 |
\timechartinterval[nervaantonine,mark=117]{76}{138}{Hadrian} |
| 1065 |
\timechartinterval[nervaantonine,mark=138]{86}{161}{Antoninus Pius} |
| 1066 |
\timechartinterval[nervaantonine,mark=161]{121}{180}{Marcus Aurelius} |
| 1067 |
\timechartinterval[nervaantonine,mark=161]{130}{169}{Lucius Verus} |
| 1068 |
\timechartinterval[nervaantonine,mark=180]{161}{192}{Commodus} |
| 1069 |
|
| 1070 |
\timechartinterval[fiveemperors,mark=193]{126}{193}{Pertinax} |
| 1071 |
\timechartinterval[fiveemperors,mark=193]{133}{193}{Didius Julianus} |
| 1072 |
|
| 1073 |
\timechartinterval[severan,mark=193]{145}{211}{Septimus Severus} |
| 1074 |
\timechartinterval[severan,mark=211]{188}{217}{Caracalla} |
| 1075 |
\timechartinterval[severan,mark=211]{189}{211}{Geta} |
| 1076 |
\timechartinterval[severan,mark=217]{c165}{218}{Macrinus} |
| 1077 |
\timechartinterval[severan,mark=218]{203/204}{222}{Elagabalus} |
| 1078 |
\timechartinterval[severan,mark=222]{208}{235}{Severus Alexander} |
| 1079 |
|
| 1080 |
\timechartinterval[thirdcentury,mark=235]{c172/c180}{238}{Maximinus I} |
| 1081 |
\timechartinterval[thirdcentury,mark=238]{c158}{238}{Gordian I} |
| 1082 |
\timechartinterval[thirdcentury,mark=238]{192}{238}{Gordian II} |
| 1083 |
\timechartinterval[thirdcentury,mark=238]{164}{238}{Pupienus} |
| 1084 |
\timechartinterval[thirdcentury,mark=238]{c164}{238}{Balbinus} |
| 1085 |
\timechartinterval[thirdcentury,mark=238]{225}{244}{Gordian III} |
| 1086 |
\timechartinterval[thirdcentury,mark=244]{c204}{249}{Philip I} |
| 1087 |
\timechartinterval[thirdcentury,mark=249]{c190/200}{251}{Decius} |
| 1088 |
\timechartinterval[thirdcentury,mark=251]{c206}{253}{Trebonianus Gallus} |
| 1089 |
\timechartinterval[thirdcentury,mark=253]{c207}{253}{Aemilianus} |
| 1090 |
\timechartinterval[thirdcentury,mark=253]{c200}{262}{Valerian} |
| 1091 |
\timechartinterval[thirdcentury,mark=253]{218}{268}{Gallienus} |
| 1092 |
\timechartinterval[thirdcentury,mark=268]{214}{270}{Claudius II} |
| 1093 |
\timechartinterval[thirdcentury,mark=270]{230/250}{270}{Quintillus} |
| 1094 |
\timechartinterval[thirdcentury,mark=270]{214}{275}{Aurelian} |
| 1095 |
\timechartinterval[thirdcentury,mark=275]{c200}{276}{Tacitus} |
| 1096 |
\timechartinterval[thirdcentury,mark=276]{226/256}{276}{Florianus} |
| 1097 |
\timechartinterval[thirdcentury,mark=276]{232}{282}{Probus} |
| 1098 |
\timechartinterval[thirdcentury,mark=282]{c224}{283}{Carus} |
| 1099 |
\timechartinterval[thirdcentury,mark=283]{c250}{285}{Carinus} |
| 1100 |
\timechartinterval[thirdcentury,mark=283]{c253}{284}{Numerian} |
| 1101 |
|
| 1102 |
\timechartinterval[tetrarchy,mark=284]{242/245}{311/312}{Diocletian} |
| 1103 |
\timechartinterval[tetrarchy,mark=286]{c250}{310}{Maximian} |
| 1104 |
\timechartinterval[tetrarchy,mark=305]{c258}{311}{Galerius} |
| 1105 |
\timechartinterval[tetrarchy,mark=305]{c250}{306}{Constantius I} |
| 1106 |
\timechartinterval[tetrarchy,mark=306]{257/287}{307}{Severus II} |
| 1107 |
\timechartinterval[tetrarchy,marks={308,324}]{c265}{325}{Licinius} |
| 1108 |
\timechartinterval[tetrarchy,mark=310]{c270}{313}{Maximinus II} |
| 1109 |
\timechartinterval[tetrarchy,mark=316]{267/297}{317}{Valerius Valens} |
| 1110 |
\timechartinterval[tetrarchy,mark=324]{275/305}{325}{Martinian} |
| 1111 |
|
| 1112 |
\timechartinterval[constantinian,mark=306]{272/273}{337}{Constantine I} |
| 1113 |
\timechartinterval[constantinian,mark=337]{316}{340}{Constantine II} |
| 1114 |
\timechartinterval[constantinian,mark=337]{322/323}{350}{Constans I} |
| 1115 |
\timechartinterval[constantinian,mark=337]{317}{361}{Constantius II} |
| 1116 |
\timechartinterval[constantinian,mark=361]{331}{363}{Julian} |
| 1117 |
\timechartinterval[constantinian,mark=363]{330/331}{364}{Jovian} |
| 1118 |
|
| 1119 |
\timechartinterval[valentinianic,mark=364]{321}{375}{Valentinian I} |
| 1120 |
\timechartinterval[valentinianic,mark=364]{c328}{378}{Valens} |
| 1121 |
\timechartinterval[valentinianic,mark=375]{359}{383}{Gratian} |
| 1122 |
\timechartinterval[valentinianic,mark=388]{371}{392}{Valentinian II} |
| 1123 |
|
| 1124 |
\timechartinterval[theodosian,mark=379]{346/347}{395}{Theodosius I} |
| 1125 |
\timecharttext[center]{395}{Eastern} |
| 1126 |
\timechartinterval[theodosian-east,mark=395]{377}{408}{Arcadius} |
| 1127 |
\timechartinterval[theodosian-east,mark=408]{401}{450}{Theodosius II} |
| 1128 |
\timechartinterval[theodosian-east,mark=450]{391/392}{457}{Marcian} |
| 1129 |
|
| 1130 |
\timechartinterval[leonid,mark=457]{400/401}{474}{Leo I} |
| 1131 |
\timechartinterval[leonid,mark=474]{467}{474}{Leo II} |
| 1132 |
\timechartinterval[leonid,mark={474,475,476}]{425}{491}{Zeno} |
| 1133 |
\timechartinterval[leonid,mark=475]{426/456}{476/477}{Basilicus} |
| 1134 |
\timechartinterval[leonid,mark=491]{430/431}{518}{Anastasius I} |
| 1135 |
|
| 1136 |
\timechartinterval[justinian,mark=518]{450}{527}{Justin I} |
| 1137 |
\timechartinterval[justinian,mark=527]{482}{565}{Justinian I} |
| 1138 |
|
| 1139 |
\timecharttext[center]{395}{Western} |
| 1140 |
\timechartinterval[theodosian-west,mark=395]{384}{423}{Honorius} |
| 1141 |
\timechartinterval[theodosian-west,mark=421]{371/401}{421}{Constantius III} |
| 1142 |
\timechartinterval[theodosian-west,mark=425]{419}{455}{Valentian III} |
| 1143 |
|
| 1144 |
\timechartinterval[lastwest,mark=455]{405/435}{455}{Petronius Maximus} |
| 1145 |
\timechartinterval[lastwest,mark=455]{406/436}{456/457}{Avitius} |
| 1146 |
\timechartinterval[lastwest,mark=457]{411/441}{461}{Majorian} |
| 1147 |
\timechartinterval[lastwest,mark=461]{415/445}{465}{Libius Severus} |
| 1148 |
\timechartinterval[lastwest,mark=467]{422/452}{472}{Anthemius} |
| 1149 |
\timechartinterval[lastwest,mark=472]{422/452}{472}{Olybrius} |
| 1150 |
\timechartinterval[lastwest,mark={473,474}]{443/473}{474/504}{Glycerius} |
| 1151 |
\timechartinterval[lastwest,mark={474,465}]{430/460}{480}{Julius Nepos} |
| 1152 |
\timechartinterval[lastwest,mark={475,476}]{c465}{507/527}{Romulus} |
| 1153 |
|
| 1154 |
\timechartsetyminimumautoreset{-\maxdimen} |
| 1155 |
\timechartsety{(-\mainlinecount-1)*3.25mm} |
| 1156 |
|
| 1157 |
\timechartinterval[ |
| 1158 |
center, |
| 1159 |
interval bar color=darkgray, |
| 1160 |
interval text/.append style={ text=white }, |
| 1161 |
interval bar thickness=6.5mm |
| 1162 |
]{-509}{-27}{} |
| 1163 |
\timechartstepy[-1] |
| 1164 |
\timechartinterval[ |
| 1165 |
center, |
| 1166 |
interval bar color=black, |
| 1167 |
interval text/.append style={ node font=\sffamily\normalsize,text=white }, |
| 1168 |
interval bar thickness=6.5mm |
| 1169 |
]{-27}{395}{Roman Empire} |
| 1170 |
\timechartstepy[-1.5] |
| 1171 |
\timechartinterval[ |
| 1172 |
center, |
| 1173 |
interval bar color=lightgray, |
| 1174 |
interval bar thickness=3.25mm |
| 1175 |
]{395}{1453}{Eastern} |
| 1176 |
\timechartinterval[ |
| 1177 |
center, |
| 1178 |
interval bar color=gray, |
| 1179 |
interval bar thickness=3.25mm |
| 1180 |
]{395}{476}{Western} |
| 1181 |
\end{timechart} |
| 1182 |
%</example1-timechart> |
| 1183 |
%<*example1-legend> |
| 1184 |
\begin{tabular}{rl} |
| 1185 |
\timechartlegenditem[julioclaudian] & Julio-Claudian dynasty \\ |
| 1186 |
\timechartlegenditem[fouremperors] & Year of four emperors \\ |
| 1187 |
\timechartlegenditem[flavian] & Flavian dynasty \\ |
| 1188 |
\timechartlegenditem[nervaantonine] & Nerva-Antonine dynasty \\ |
| 1189 |
\timechartlegenditem[fiveemperors] & Year of five emperors \\ |
| 1190 |
\timechartlegenditem[severan] & Severan dynasty \\ |
| 1191 |
\timechartlegenditem[thirdcentury] & Crisis of the third century \\ |
| 1192 |
\timechartlegenditem[tetrarchy] & Tetrarchy \\ |
| 1193 |
\timechartlegenditem[constantinian] & Constantinian dynasty \\ |
| 1194 |
\timechartlegenditem[valentinianic] & Valentinianic dynasty \\ |
| 1195 |
\timechartlegenditem[theodosian] & Theodosian dynasty \\ |
| 1196 |
\timechartlegenditem[theodosian-east] & --- in the east \\ |
| 1197 |
\timechartlegenditem[theodosian-west] & --- in the west \\ |
| 1198 |
\timechartlegenditem[leonid] & Leonid dynasty \\ |
| 1199 |
\timechartlegenditem[justinian] & Justinian dynasty \\ |
| 1200 |
\timechartlegenditem[lastwest] & Last emperors in the west \\ |
| 1201 |
\end{tabular} |
| 1202 |
%</example1-legend> |
| 1203 |
%<*example2-v1> |
| 1204 |
\begin{timechart}{-50}{75} |
| 1205 |
\timechartinterval{-63}{-14}{Augustus} |
| 1206 |
\timechartinterval{-42}{37}{Tiberius} |
| 1207 |
\timechartinterval{12}{41}{Caligula} |
| 1208 |
\timechartinterval{-10}{54}{Claudius} |
| 1209 |
\timechartinterval{37}{68}{Nero} |
| 1210 |
\end{timechart} |
| 1211 |
%</example2-v1> |
| 1212 |
%<*example2-v2> |
| 1213 |
\begin{timechart}[ |
| 1214 |
minor tick interval=5, |
| 1215 |
major tick interval=25, |
| 1216 |
grid/.append style={ draw=lightgray }, |
| 1217 |
axis line/.append style={ draw=gray }, |
| 1218 |
minor tick/.append style={ draw=gray }, |
| 1219 |
major tick/.append style={ draw=gray }, |
| 1220 |
interval label/.append style={ node font=\sffamily\small }, |
| 1221 |
julioclaudian/.style={ interval bar color=red!80!black }, |
| 1222 |
]{-50}{75} |
| 1223 |
\timechartinterval[right,julioclaudian]{-63}{-14}{Augustus} |
| 1224 |
\timechartinterval[right,julioclaudian]{-42}{37}{Tiberius} |
| 1225 |
\timechartinterval[julioclaudian]{12}{41}{Caligula} |
| 1226 |
\timechartinterval[julioclaudian]{-10}{54}{Claudius} |
| 1227 |
\timechartinterval[julioclaudian]{37}{68}{Nero} |
| 1228 |
\end{timechart} |
| 1229 |
%</example2-v2> |
| 1230 |
% \fi |
| 1231 |
% |
| 1232 |
% |
| 1233 |
% |
| 1234 |
% \begin{implementation} |
| 1235 |
% |
| 1236 |
% \setcounter{secnumdepth}{7} |
| 1237 |
% |
| 1238 |
% |
| 1239 |
% |
| 1240 |
% \section{Implementation} |
| 1241 |
% |
| 1242 |
% \begin{macrocode} |
| 1243 |
%<*package> |
| 1244 |
%<@@=timechart> |
| 1245 |
% \end{macrocode} |
| 1246 |
% |
| 1247 |
% |
| 1248 |
% |
| 1249 |
% \subsection{Coding standard} |
| 1250 |
% |
| 1251 |
% This package makes extensive use of \pkg{pgfmath} computations. The usual \pkg{expl3} standard of ending variables |
| 1252 |
% with a type indicator (\texttt{\_bool}, \texttt{\_int}, etc.) is therefore adapted as follows: |
| 1253 |
% \begin{itemize} |
| 1254 |
% \item[\texttt{\_year}] Stores a year, which could in principle be fractional. |
| 1255 |
% \item[\texttt{\_pgf}] Stores a length calculated by \pkg{pgfmath}. (Unlike \texttt{\_dim}, there is no underlying |
| 1256 |
% dimension register.) |
| 1257 |
% \item[\texttt{\_x}] Stores a raw \(x\) coordinate (not in \TikZ's XY-coordinate system). |
| 1258 |
% \item[\texttt{\_y}] Stores a raw \(y\) coordinate (not in \TikZ's XY-coordinate system). |
| 1259 |
% \item[\texttt{\_text}] Stores text (not an \pkg{expl3} string). |
| 1260 |
% \end{itemize} |
| 1261 |
% |
| 1262 |
% |
| 1263 |
% |
| 1264 |
% \subsection{Initial set-up} |
| 1265 |
% |
| 1266 |
% Package identification/version information. |
| 1267 |
% \begin{macrocode} |
| 1268 |
\NeedsTeXFormat{LaTeX2e}[2020-02-02] |
| 1269 |
\ProvidesExplPackage{timechart}{2025-10-17}{0.56.1} |
| 1270 |
{Typesetting chronological charts} |
| 1271 |
% \end{macrocode} |
| 1272 |
% |
| 1273 |
% |
| 1274 |
% |
| 1275 |
% \subsection{Debugging macro} |
| 1276 |
% |
| 1277 |
% \begin{macro}{\@@_debug:n,\@@_debug_real:n} |
| 1278 |
% Macro to output (many) debugging messages. |
| 1279 |
% \begin{macrocode} |
| 1280 |
\cs_new:Npn \@@_debug_real:n #1 |
| 1281 |
{ |
| 1282 |
\typeout{timechart:~#1} |
| 1283 |
} |
| 1284 |
\cs_set_eq:NN\@@_debug:n\use_none:n |
| 1285 |
% \end{macrocode} |
| 1286 |
% \end{macro} |
| 1287 |
% |
| 1288 |
% |
| 1289 |
% |
| 1290 |
% \subsection{Load TikZ} |
| 1291 |
% |
| 1292 |
% \begin{macrocode} |
| 1293 |
\RequirePackage{tikz} |
| 1294 |
% \end{macrocode} |
| 1295 |
% In the remainder of the package, only a limited subset of \TikZ\ is used, and PGF code is preferred. For PGF keys, it |
| 1296 |
% is necessary to use \texttt{\textasciitilde} in place of a space. |
| 1297 |
% |
| 1298 |
% |
| 1299 |
% |
| 1300 |
% \subsection{Scratch variables} |
| 1301 |
% |
| 1302 |
% \begin{macro}{\l_@@_tmpa_bool,\l_@@_tmpb_bool,\l_@@_tmpc_bool,\l_@@_tmpd_bool} |
| 1303 |
% Scratch boolean variables. |
| 1304 |
% \begin{macrocode} |
| 1305 |
\bool_new:N\l_@@_tmpa_bool |
| 1306 |
\bool_new:N\l_@@_tmpb_bool |
| 1307 |
\bool_new:N\l_@@_tmpc_bool |
| 1308 |
\bool_new:N\l_@@_tmpd_bool |
| 1309 |
% \end{macrocode} |
| 1310 |
% \end{macro} |
| 1311 |
% |
| 1312 |
% \begin{macro}{\l_@@_tmpa_dim,\l_@@_tmpb_dim,\l_@@_tmpc_dim,\l_@@_tmpd_dim} |
| 1313 |
% Scratch dimension variables, reusing \cs{l_tmpa_dim} and \cs{l_tmpb_dim} with uniform names. |
| 1314 |
% \begin{macrocode} |
| 1315 |
\cs_set_eq:NN\l_@@_tmpa_dim\l_tmpa_dim |
| 1316 |
\cs_set_eq:NN\l_@@_tmpb_dim\l_tmpb_dim |
| 1317 |
\dim_new:N\l_@@_tmpc_dim |
| 1318 |
\dim_new:N\l_@@_tmpd_dim |
| 1319 |
% \end{macrocode} |
| 1320 |
% \end{macro} |
| 1321 |
% |
| 1322 |
% |
| 1323 |
% |
| 1324 |
% \subsection{Generic auxiliary functions} |
| 1325 |
% |
| 1326 |
% \begin{macro}{\@@_make_ref:NN} |
| 1327 |
% Make hyperreference from text, if the supplied target is non-empty. |
| 1328 |
% \begin{arguments} |
| 1329 |
% \item Reference for hyperlink target, or empty. |
| 1330 |
% \item Text. |
| 1331 |
% \end{arguments} |
| 1332 |
% \begin{macrocode} |
| 1333 |
\cs_new:Npn\@@_make_ref:NN #1#2 |
| 1334 |
{ |
| 1335 |
\str_if_empty:NTF #1 |
| 1336 |
{ #2 } |
| 1337 |
{ \hyperref[#1]{#2} } |
| 1338 |
} |
| 1339 |
% \end{macrocode} |
| 1340 |
% \end{macro} |
| 1341 |
% |
| 1342 |
% |
| 1343 |
% |
| 1344 |
% \subsection{PGF auxiliary functions} |
| 1345 |
% |
| 1346 |
% \begin{macro}{@@_pgfmathsetbool:nn} |
| 1347 |
% Set an \pkg{expl3} boolean variable to the outcome of a \pkg{pgfmath} comparison. This macro is simply a wrapper |
| 1348 |
% around \cs{pgfmathsetmacro} using \mcode{ifthenelse} and returning the boolean literal true or false. |
| 1349 |
% \begin{macrocode} |
| 1350 |
\cs_new:Npn\@@_pgfmathsetbool:nn #1#2 |
| 1351 |
{ |
| 1352 |
\pgfmathsetmacro{#1}{ifthenelse(#2,"\c_true_bool","\c_false_bool")} |
| 1353 |
} |
| 1354 |
% \end{macrocode} |
| 1355 |
% \end{macro} |
| 1356 |
% |
| 1357 |
% \begin{macro}{\@@_if_equal:nnF}% |
| 1358 |
% Use \pkg{pgfmath} to check whether \param{1} and \param{2} are equal. If not, execute \param{3}. |
| 1359 |
% \begin{macrocode} |
| 1360 |
\cs_new:Npn\@@_if_equal:nnF #1#2#3 |
| 1361 |
{ |
| 1362 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool}{#1==#2} |
| 1363 |
\bool_if:NF\l_@@_tmpa_bool{#3} |
| 1364 |
} |
| 1365 |
% \end{macrocode} |
| 1366 |
% \end{macro} |
| 1367 |
% |
| 1368 |
% \begin{macro}{\@@_pgfextractxy:nnn} |
| 1369 |
% Extract coordinates of \param{3} (a PGF point) to dimension variables \param{1} and \param{2}. This macro simply |
| 1370 |
% combines the functionality of \cs{pgfextractx} and \cs{pgfextracty}. |
| 1371 |
% \begin{macrocode} |
| 1372 |
\cs_new:Npn\@@_pgfextractxy:nnn #1#2#3 |
| 1373 |
{ |
| 1374 |
\pgf@process{#3} |
| 1375 |
#1=\pgf@x\relax |
| 1376 |
#2=\pgf@y\relax |
| 1377 |
} |
| 1378 |
% \end{macrocode} |
| 1379 |
% \end{macro} |
| 1380 |
% |
| 1381 |
% \begin{macro}{\@@_hsmash_pgfnode:nnnnn} |
| 1382 |
% Do the same as \cs{pgfnode} but only update the bounding box `vertically'. |
| 1383 |
% \begin{macrocode} |
| 1384 |
\cs_new:Npn\@@_hsmash_pgfnode:nnnnn #1#2#3#4#5 |
| 1385 |
{ |
| 1386 |
\pgfinterruptboundingbox |
| 1387 |
\pgfnode{#1}{#2}{#3}{#4}{#5} |
| 1388 |
\pgfcoordinate |
| 1389 |
{@@_tmpa_coord} |
| 1390 |
{\pgfpointanchor{current~bounding~box}{south}} |
| 1391 |
\pgfcoordinate |
| 1392 |
{@@_tmpb_coord} |
| 1393 |
{\pgfpointanchor{current~bounding~box}{north}} |
| 1394 |
\endpgfinterruptboundingbox |
| 1395 |
\pgfextractx |
| 1396 |
{\l_@@_tmpa_dim} |
| 1397 |
{\pgfpointanchor{@@_tmpa_coord}{center}} |
| 1398 |
\pgfextractx |
| 1399 |
{\l_@@_tmpb_dim} |
| 1400 |
{\pgfpointanchor{@@_tmpb_coord}{center}} |
| 1401 |
\pgfpathmoveto{\pgfpoint{\l_@@_tmpa_dim}{0}} |
| 1402 |
\pgfpathmoveto{\pgfpoint{\l_@@_tmpb_dim}{0}} |
| 1403 |
\pgfusepath{discard} |
| 1404 |
} |
| 1405 |
% \end{macrocode} |
| 1406 |
% \end{macro} |
| 1407 |
% |
| 1408 |
% \begin{macro}{\@@_make_rectangle_node:nnnn} |
| 1409 |
% Make a node with south west corner \param{1}, north east corner \param{2}, and name \param{3}. \param{1} and |
| 1410 |
% \param{2} should be given as PGF points. \param{4} is a boolean literal indicating whether the path should be |
| 1411 |
% stroked. |
| 1412 |
% \begin{macrocode} |
| 1413 |
\cs_new:Npn\@@_make_rectangle_node:nnnn #1#2#3#4 |
| 1414 |
{ |
| 1415 |
\group_begin: |
| 1416 |
\@@_pgfextractxy:nnn |
| 1417 |
{\l_@@_tmpa_dim}{\l_@@_tmpb_dim}{#1} |
| 1418 |
\@@_pgfextractxy:nnn |
| 1419 |
{\l_@@_tmpc_dim}{\l_@@_tmpd_dim}{#2} |
| 1420 |
\pgftransformshift{#1} |
| 1421 |
\pgfset{ |
| 1422 |
minimum~width=\l_@@_tmpc_dim-\l_@@_tmpa_dim, |
| 1423 |
minimum~height=\l_@@_tmpd_dim-\l_@@_tmpb_dim, |
| 1424 |
inner~sep=0, |
| 1425 |
outer~sep=0, |
| 1426 |
} |
| 1427 |
\bool_if:NTF #4 |
| 1428 |
{ \pgfnode{rectangle}{south~west}{}{#3}{\pgfusepath{draw}} } |
| 1429 |
{ \pgfnode{rectangle}{south~west}{}{#3}{\pgfusepath{discard}} } |
| 1430 |
\group_end: |
| 1431 |
} |
| 1432 |
% \end{macrocode} |
| 1433 |
% \end{macro} |
| 1434 |
% |
| 1435 |
% \begin{macro}{\@@_set_style_line_width:nn} |
| 1436 |
% Set macro \param{1} to be the line width set by the PGF style \param{2}. Note that \cs{begingroup} and \cs{endgroup} |
| 1437 |
% are used here because of the definition of \cs{pgfmathsmuggle}. |
| 1438 |
% \begin{macrocode} |
| 1439 |
\cs_new:Npn\@@_set_style_line_width:nn #1#2 |
| 1440 |
{ |
| 1441 |
\begingroup |
| 1442 |
\tikzset{#2} |
| 1443 |
\pgfmathsetlengthmacro{#1}{\pgflinewidth} |
| 1444 |
\pgfmathsmuggle #1 |
| 1445 |
\endgroup |
| 1446 |
} |
| 1447 |
% \end{macrocode} |
| 1448 |
% \end{macro} |
| 1449 |
% |
| 1450 |
% |
| 1451 |
% |
| 1452 |
% \subsection{PGF keys} |
| 1453 |
% |
| 1454 |
% All PGF keys for this package are under \key{/timechart/}. |
| 1455 |
% \begin{macrocode} |
| 1456 |
\pgfkeys{ |
| 1457 |
/timechart/.cd, |
| 1458 |
% \end{macrocode} |
| 1459 |
% Keys applicable to debugging. |
| 1460 |
% \begin{macrocode} |
| 1461 |
debug/.code = { |
| 1462 |
\cs_set_eq:NN\@@_debug:n\@@_debug_real:n |
| 1463 |
}, |
| 1464 |
no~debug/.code = { |
| 1465 |
\cs_set_eq:NN\@@_debug:n\use_none:n |
| 1466 |
}, |
| 1467 |
% \end{macrocode} |
| 1468 |
% Keys applicable to whole chart. |
| 1469 |
% \begin{macrocode} |
| 1470 |
width/.initial=\textwidth, |
| 1471 |
ystep/.initial=-10pt, |
| 1472 |
minor~tick~interval/.initial=10, |
| 1473 |
major~tick~interval/.initial=50, |
| 1474 |
tolerance~start/.initial=5pt, |
| 1475 |
tolerance~finish/.initial=5pt, |
| 1476 |
beyond~length~start/.initial=5pt, |
| 1477 |
beyond~length~finish/.initial=5pt, |
| 1478 |
beyond~x~radius~start/.initial=4pt, |
| 1479 |
beyond~x~radius~finish/.initial=4pt, |
| 1480 |
% \end{macrocode} |
| 1481 |
% Shortcuts for tolerance and `beyond' indicators. |
| 1482 |
% \begin{macrocode} |
| 1483 |
tolerance/.code = { |
| 1484 |
\pgfkeyssetvalue{/timechart/tolerance~start}{#1} |
| 1485 |
\pgfkeyssetvalue{/timechart/tolerance~finish}{#1} |
| 1486 |
}, |
| 1487 |
beyond~length/.code = { |
| 1488 |
\pgfkeyssetvalue{/timechart/beyond~length~start}{#1} |
| 1489 |
\pgfkeyssetvalue{/timechart/beyond~length~finish}{#1} |
| 1490 |
}, |
| 1491 |
beyond~x~radius/.code = { |
| 1492 |
\pgfkeyssetvalue{/timechart/beyond~x~radius~start}{#1} |
| 1493 |
\pgfkeyssetvalue{/timechart/beyond~x~radius~finish}{#1} |
| 1494 |
}, |
| 1495 |
% \end{macrocode} |
| 1496 |
% Keys applicable to the grid. |
| 1497 |
% \begin{macrocode} |
| 1498 |
no~grid/.code = { \bool_set_false:N\l_@@_grid_bool }, |
| 1499 |
grid~top~ysep/.initial={3pt}, |
| 1500 |
grid~bottom~ysep/.initial={3pt}, |
| 1501 |
grid/.style={}, |
| 1502 |
% \end{macrocode} |
| 1503 |
% Keys applicable to the axis. |
| 1504 |
% \begin{macrocode} |
| 1505 |
axis~line/.style={ |
| 1506 |
line~cap=rect, |
| 1507 |
}, |
| 1508 |
axis~ysep/.initial=3pt, |
| 1509 |
axis/.is~choice, |
| 1510 |
axis/none/.code |
| 1511 |
= { \int_set:Nn\l_@@_axis_int{0} }, |
| 1512 |
axis/above/.code |
| 1513 |
= { \int_set:Nn\l_@@_axis_int{1} }, |
| 1514 |
axis/below/.code |
| 1515 |
= { \int_set:Nn\l_@@_axis_int{2} }, |
| 1516 |
no~axis/.code = { \int_set:Nn\l_@@_axis_int{0} }, |
| 1517 |
minor~tick/.style={}, |
| 1518 |
minor~tick~length/.initial=1.5mm, |
| 1519 |
major~tick/.style={}, |
| 1520 |
major~tick~length/.initial=3mm, |
| 1521 |
major~tick~label/.style={ |
| 1522 |
inner~sep=0, |
| 1523 |
outer~sep=0, |
| 1524 |
anchor=mid~west, |
| 1525 |
rotate=90, |
| 1526 |
}, |
| 1527 |
major~tick~eras/.is~choice, |
| 1528 |
major~tick~eras/none/.code |
| 1529 |
= { \int_set:Nn\l_@@_major_tick_eras_int{0} }, |
| 1530 |
major~tick~eras/all/.code |
| 1531 |
= { \int_set:Nn\l_@@_major_tick_eras_int{1} }, |
| 1532 |
major~tick~eras/outer/.code |
| 1533 |
= { \int_set:Nn\l_@@_major_tick_eras_int{2} }, |
| 1534 |
% \end{macrocode} |
| 1535 |
% Keys applicable to intervals, texts, spaces, and legends. |
| 1536 |
% \begin{macrocode} |
| 1537 |
no~autostep/.code = { \bool_set_false:Nz\l_@@_autostep_bool }, |
| 1538 |
ref/.initial={}, |
| 1539 |
mark/.initial={}, |
| 1540 |
marks/.forward~to=/timechart/mark, |
| 1541 |
circa~uncertainty/.initial=3, |
| 1542 |
interval~minimum~width/.initial=1pt, |
| 1543 |
interval~bar~color/.initial=black, |
| 1544 |
interval~bar~thickness/.initial=8pt, |
| 1545 |
interval~bar~node~name/.initial = {bar~node}, |
| 1546 |
interval~mark~color/.initial=gray, |
| 1547 |
interval~label/.style={}, |
| 1548 |
interval~label~centered/.style={/timechart/interval~label,text=white}, |
| 1549 |
interval~label~centered~background/.style={/timechart/interval~label}, |
| 1550 |
interval~label~baseline/.initial=-3pt, |
| 1551 |
interval~label~pos/.is~choice, |
| 1552 |
interval~label~pos/left/.code |
| 1553 |
= { \int_set:Nn\l_@@_label_pos_int{0} }, |
| 1554 |
interval~label~pos/center/.code |
| 1555 |
= { \int_set:Nn\l_@@_label_pos_int{1} }, |
| 1556 |
interval~label~pos/right/.code |
| 1557 |
= { \int_set:Nn\l_@@_label_pos_int{2} }, |
| 1558 |
interval~label~node~name/.initial = {label~node}, |
| 1559 |
start~range/.is~choice, |
| 1560 |
start~range/fade/.code |
| 1561 |
= { \int_set:Nn\l_@@_start_range_type_int{0} }, |
| 1562 |
start~range/slant/.code |
| 1563 |
= { \int_set:Nn\l_@@_start_range_type_int{1} }, |
| 1564 |
finish~range/.is~choice, |
| 1565 |
finish~range/fade/.code |
| 1566 |
= { \int_set:Nn\l_@@_finish_range_type_int{0} }, |
| 1567 |
finish~range/slant/.code |
| 1568 |
= { \int_set:Nn\l_@@_finish_range_type_int{1} }, |
| 1569 |
% \end{macrocode} |
| 1570 |
% Keys applicable only to texts. |
| 1571 |
% \begin{macrocode} |
| 1572 |
text~node~name/.initial = {text~node}, |
| 1573 |
text/.style={}, |
| 1574 |
text~baseline/.initial=-3pt, |
| 1575 |
text~pos/.is~choice, |
| 1576 |
text~pos/left/.code = { \int_set:Nn\l_@@_text_pos_int{0} }, |
| 1577 |
text~pos/center/.code = { \int_set:Nn\l_@@_text_pos_int{1} }, |
| 1578 |
text~pos/right/.code = { \int_set:Nn\l_@@_text_pos_int{2} }, |
| 1579 |
% \end{macrocode} |
| 1580 |
% Keys applicable only to legends. |
| 1581 |
% \begin{macrocode} |
| 1582 |
legend~item~width/.initial=9mm, |
| 1583 |
legend~item~range~width/.initial=3mm, |
| 1584 |
% \end{macrocode} |
| 1585 |
% Shortcuts for positioning. |
| 1586 |
% \begin{macrocode} |
| 1587 |
left/.code = { |
| 1588 |
\int_set:Nn\l_@@_label_pos_int{0} |
| 1589 |
\int_set:Nn\l_@@_text_pos_int{0} |
| 1590 |
}, |
| 1591 |
center/.code = { |
| 1592 |
\int_set:Nn\l_@@_label_pos_int{1} |
| 1593 |
\int_set:Nn\l_@@_text_pos_int{1} |
| 1594 |
}, |
| 1595 |
right/.code = { |
| 1596 |
\int_set:Nn\l_@@_label_pos_int{2} |
| 1597 |
\int_set:Nn\l_@@_text_pos_int{2} |
| 1598 |
}, |
| 1599 |
} |
| 1600 |
% \end{macrocode} |
| 1601 |
% |
| 1602 |
% \begin{macro}{\l_@@_grid_bool} |
| 1603 |
% Boolean indicating whether the grid will be drawn. This variable is by default true but can be set false via the |
| 1604 |
% \key{/timechart/no grid} PGF key. |
| 1605 |
% \begin{macrocode} |
| 1606 |
\bool_new:N\l_@@_grid_bool |
| 1607 |
\bool_set_true:N\l_@@_grid_bool |
| 1608 |
% \end{macrocode} |
| 1609 |
% \end{macro} |
| 1610 |
% |
| 1611 |
% \begin{macro}{\l_@@_axis_int} |
| 1612 |
% An integer indicating whether and where the axis will be drawn. This is set via the \key{/timechart/axis} PGF |
| 1613 |
% key. |
| 1614 |
% \begin{macrocode} |
| 1615 |
\int_new:N\l_@@_axis_int |
| 1616 |
\int_set:Nn\l_@@_axis_int{1} |
| 1617 |
% \end{macrocode} |
| 1618 |
% \end{macro} |
| 1619 |
% |
| 1620 |
% \begin{macro}{\l_@@_major_tick_eras_int} |
| 1621 |
% An integer indicating which major ticks will have era indicators. This is set via the \key{/timechart/major tick |
| 1622 |
% era} PGF key. |
| 1623 |
% \begin{macrocode} |
| 1624 |
\int_new:N\l_@@_major_tick_eras_int |
| 1625 |
\int_set:Nn\l_@@_major_tick_eras_int{2} |
| 1626 |
% \end{macrocode} |
| 1627 |
% \end{macro} |
| 1628 |
% |
| 1629 |
% \begin{macro}{\l_@@_autostep_bool} |
| 1630 |
% Boolean indicating whether to automatically step the \(y\) coordinate after an interval, text, or space. This |
| 1631 |
% variable is by default true but can be set false via the \key{/timechart/no autostep} PGF key. |
| 1632 |
% \begin{macrocode} |
| 1633 |
\bool_new:N\l_@@_autostep_bool |
| 1634 |
\bool_set_true:N\l_@@_autostep_bool |
| 1635 |
% \end{macrocode} |
| 1636 |
% \end{macro} |
| 1637 |
% |
| 1638 |
% \begin{macro}{\l_@@_label_pos_int} |
| 1639 |
% An integer to hold the interval label position. This is set via the \key{/timechart/interval label pos} PGF key. |
| 1640 |
% \begin{macrocode} |
| 1641 |
\int_new:N \l_@@_label_pos_int |
| 1642 |
% \end{macrocode} |
| 1643 |
% \end{macro} |
| 1644 |
% |
| 1645 |
% \begin{macro}{\l_@@_text_pos_int} |
| 1646 |
% An integer to hold the text position. This is set via the \key{/timechart/text pos} PGF key. |
| 1647 |
% \begin{macrocode} |
| 1648 |
\int_new:N \l_@@_text_pos_int |
| 1649 |
% \end{macrocode} |
| 1650 |
% \end{macro} |
| 1651 |
% |
| 1652 |
% \begin{macro}{\l_@@_start_range_type_int,\l_@@_finish_range_type_int} |
| 1653 |
% Integers to hold the type of the start/end ranges. These are set via the \key{/timechart/start range} and |
| 1654 |
% \key{/timechart/finish range} PGF keys. |
| 1655 |
% \begin{macrocode} |
| 1656 |
\int_new:N \l_@@_start_range_type_int |
| 1657 |
\int_new:N \l_@@_finish_range_type_int |
| 1658 |
% \end{macrocode} |
| 1659 |
% \end{macro} |
| 1660 |
% |
| 1661 |
% |
| 1662 |
% |
| 1663 |
% \subsection{Main environment} |
| 1664 |
% |
| 1665 |
% \begin{macro}{timechart} |
| 1666 |
% The main environment. |
| 1667 |
% \begin{arguments} |
| 1668 |
% \item PGF keys to apply. |
| 1669 |
% \item Start year. |
| 1670 |
% \item End year. |
| 1671 |
% \end{arguments} |
| 1672 |
% \begin{macrocode} |
| 1673 |
\NewDocumentEnvironment{timechart}{ O{} m m } |
| 1674 |
{ \@@_main_begin:nnn{#1}{#2}{#3} } |
| 1675 |
{ \@@_main_end: } |
| 1676 |
% \end{macrocode} |
| 1677 |
% \end{macro} |
| 1678 |
% |
| 1679 |
% \begin{macro}{\@@_main_begin:nnn} |
| 1680 |
% This command uses values specified by PGF keys to make some necessary calculations to begin the chart. |
| 1681 |
% \begin{macrocode} |
| 1682 |
\cs_new:Npn \@@_main_begin:nnn #1#2#3 |
| 1683 |
{ |
| 1684 |
% \end{macrocode} |
| 1685 |
% Process the supplied PGF keys and retrieve values that affect the chart as a whole. |
| 1686 |
% \begin{macrocode} |
| 1687 |
\pgfkeys{ |
| 1688 |
/timechart/.cd, |
| 1689 |
#1, |
| 1690 |
width/.get=\l_@@_width_pgf, |
| 1691 |
ystep/.get=\l_@@_ystep_pgf, |
| 1692 |
grid~top~ysep/.get=\l_@@_grid_top_ysep_pgf, |
| 1693 |
grid~bottom~ysep/.get=\l_@@_grid_bottom_ysep_pgf, |
| 1694 |
minor~tick~interval/.get=\l_@@_minor_tick_interval_year, |
| 1695 |
major~tick~interval/.get=\l_@@_major_tick_interval_year, |
| 1696 |
} |
| 1697 |
% \end{macrocode} |
| 1698 |
% Start the \TikZ\ picture and set up the necessary layers. |
| 1699 |
% \begin{macrocode} |
| 1700 |
\tikzpicture |
| 1701 |
\pgfdeclarelayer{grid} |
| 1702 |
\pgfdeclarelayer{labelbg} |
| 1703 |
\pgfsetlayers{grid,labelbg,main} |
| 1704 |
% \end{macrocode} |
| 1705 |
% Store the line width of the grid and axis, treating them as \qty{0}{\point} if they are disabled. |
| 1706 |
% \begin{macrocode} |
| 1707 |
\bool_if:NTF\l_@@_grid_bool |
| 1708 |
{ |
| 1709 |
\@@_set_style_line_width:nn |
| 1710 |
{\l_@@_grid_line_width} |
| 1711 |
{/timechart/grid} |
| 1712 |
} |
| 1713 |
{ \pgfmathsetlengthmacro{\l_@@_grid_line_width}{0} } |
| 1714 |
\int_if_zero:nTF{ \l_@@_axis_int } |
| 1715 |
{ |
| 1716 |
\pgfmathsetlengthmacro{\l_@@_axis_line_width}{0} |
| 1717 |
\pgfmathsetlengthmacro{\l_@@_major_tick_line_width}{0} |
| 1718 |
\pgfmathsetlengthmacro{\l_@@_minor_tick_line_width}{0} |
| 1719 |
} |
| 1720 |
{ |
| 1721 |
\@@_set_style_line_width:nn |
| 1722 |
{\l_@@_axis_line_width} |
| 1723 |
{/timechart/axis~line} |
| 1724 |
\@@_set_style_line_width:nn |
| 1725 |
{\l_@@_major_tick_line_width} |
| 1726 |
{/timechart/major~tick} |
| 1727 |
\@@_set_style_line_width:nn |
| 1728 |
{\l_@@_minor_tick_line_width} |
| 1729 |
{/timechart/minor~tick} |
| 1730 |
} |
| 1731 |
% \end{macrocode} |
| 1732 |
% Store the start and finish years (ignoring circa, month, day), and then set up the conversion from years to \(x\) |
| 1733 |
% coordinates. \cs{l_@@_x} is the \(x\)-distance corresponding to one year, and \mcode{yeartox} is the \pkg{pgfmath} |
| 1734 |
% function that does the conversion. |
| 1735 |
% \begin{macrocode} |
| 1736 |
\@@_parse_date:NNn\l_tmpa_bool\l_@@_start_year{#2} |
| 1737 |
\@@_parse_date:NNn\l_tmpa_bool\l_@@_finish_year{#3} |
| 1738 |
\pgfmathsetmacro{\l_@@_start_year} |
| 1739 |
{floor(\l_@@_start_year)} |
| 1740 |
\pgfmathsetmacro{\l_@@_finish_year} |
| 1741 |
{floor(\l_@@_finish_year)} |
| 1742 |
\pgfmathsetmacro{\l_@@_x} |
| 1743 |
{ |
| 1744 |
( |
| 1745 |
\l_@@_width_pgf |
| 1746 |
- max( |
| 1747 |
\l_@@_grid_line_width, |
| 1748 |
\l_@@_axis_line_width, |
| 1749 |
\l_@@_major_tick_line_width, |
| 1750 |
\l_@@_minor_tick_line_width |
| 1751 |
) |
| 1752 |
)/(\l_@@_finish_year-\l_@@_start_year) |
| 1753 |
} |
| 1754 |
\pgfkeys{ |
| 1755 |
/pgf/declare~function={ |
| 1756 |
yeartox(\n)=\l_@@_x*(\n-\l_@@_start_year); |
| 1757 |
}, |
| 1758 |
} |
| 1759 |
% \end{macrocode} |
| 1760 |
% Calculate the start and finish \(x\) coordinates. |
| 1761 |
% \begin{macrocode} |
| 1762 |
\pgfmathsetmacro{\l_@@_start_x} |
| 1763 |
{yeartox(\l_@@_start_year)} |
| 1764 |
\pgfmathsetmacro{\l_@@_finish_x} |
| 1765 |
{yeartox(\l_@@_finish_year)} |
| 1766 |
% \end{macrocode} |
| 1767 |
% Set up tracking of current \(y\) coordinate. |
| 1768 |
% \begin{macrocode} |
| 1769 |
\pgfmathsetmacro{\l_@@_current_y}{0} |
| 1770 |
\pgfmathsetmacro{\l_@@_saved_y}{0} |
| 1771 |
\pgfmathsetmacro{\l_@@_auto_reset_minimum_y}{-16000pt} |
| 1772 |
\pgfmathsetmacro{\l_@@_auto_reset_maximum_y}{16000pt} |
| 1773 |
% \end{macrocode} |
| 1774 |
% Calculate some years used in loops. |
| 1775 |
% \begin{macrocode} |
| 1776 |
\pgfmathsetmacro{\l_@@_start_plus_year}{ |
| 1777 |
\l_@@_start_year+\l_@@_minor_tick_interval_year |
| 1778 |
} |
| 1779 |
\pgfmathsetmacro{\l_@@_start_plusplus_year}{ |
| 1780 |
\l_@@_start_year+(2*\l_@@_minor_tick_interval_year) |
| 1781 |
} |
| 1782 |
\pgfmathsetmacro{\l_@@_end_minus_year}{ |
| 1783 |
\l_@@_finish_year-\l_@@_minor_tick_interval_year |
| 1784 |
} |
| 1785 |
% \end{macrocode} |
| 1786 |
% Begin a group and make available the user commands \cs{timechart}\ldots. (The group will be ended by |
| 1787 |
% \cs{@@_main_end_user:}.) |
| 1788 |
% \begin{macrocode} |
| 1789 |
\group_begin: |
| 1790 |
\cs_set_eq:NN\timechartinterval\@@_interval_user:Ommm |
| 1791 |
\cs_set_eq:NN\timecharttext\@@_text_user:Omm |
| 1792 |
\cs_set_eq:NN\timechartspace\@@_space_user:O |
| 1793 |
\cs_set_eq:NN\timechartsety\@@_set_y_user:m |
| 1794 |
\cs_set_eq:NN\timechartsavey\@@_save_y_user: |
| 1795 |
\cs_set_eq:NN\timechartresety\@@_reset_y_user: |
| 1796 |
\cs_set_eq:NN\timechartsetyminimumautoreset |
| 1797 |
\@@_set_y_minimum_auto_reset_user:m |
| 1798 |
\cs_set_eq:NN\timechartsetymaximumautoreset |
| 1799 |
\@@_set_y_maximum_auto_reset_user:m |
| 1800 |
\cs_set_eq:NN\timechartstepy\@@_step_y_user:O |
| 1801 |
\cs_set_eq:NN\timechartfinish\@@_main_end_user: |
| 1802 |
} |
| 1803 |
% \end{macrocode} |
| 1804 |
% \end{macro} |
| 1805 |
% |
| 1806 |
% \begin{macro}{\@@_main_end:} |
| 1807 |
% Make sure the chart is complete and end the \TikZ\ picture. \cs{@@_main_end_user:} ends the group begun by |
| 1808 |
% \cs{@@_main_begin:nnn}, so whether the user has \emph{not} called it (as \cs{timechartfinish}) is equivalent to it |
| 1809 |
% being equal to \cs{timechartfinish}. |
| 1810 |
% \begin{macrocode} |
| 1811 |
\cs_new:Npn\@@_main_end: |
| 1812 |
{ |
| 1813 |
\cs_if_eq:NNT\timechartfinish\@@_main_end_user: |
| 1814 |
{ \@@_main_end_user: } |
| 1815 |
\endtikzpicture |
| 1816 |
} |
| 1817 |
% \end{macrocode} |
| 1818 |
% \end{macro} |
| 1819 |
% |
| 1820 |
% \begin{macro}{\@@_main_end_user:} |
| 1821 |
% End the group begun by \cs{@@_main_begin:nnn}, draw the axis and grid, and set the bounding box. This macro is made |
| 1822 |
% available as \cs{timechartfinish} inside the \env{timechart} environment. |
| 1823 |
% \begin{macrocode} |
| 1824 |
\cs_new:Npn\@@_main_end_user: |
| 1825 |
{ |
| 1826 |
% \end{macrocode} |
| 1827 |
% The aim here is to set the bounding box (1) to fit horizontally the axis \emph{not} including labels and the grid |
| 1828 |
% and (2) to fit vertically the axis including labels and the grid . All the `horizonatal' data is already known, and |
| 1829 |
% the `vertical' data is determined by the \emph{current} bounding box. So extract the `vertical' data and then reset |
| 1830 |
% the bounding box. |
| 1831 |
% \begin{macrocode} |
| 1832 |
\pgfextracty{\l_@@_tmpa_dim} |
| 1833 |
{ \pgfpointanchor{current~bounding~box}{south} } |
| 1834 |
\pgfextracty{\l_@@_tmpb_dim} |
| 1835 |
{ \pgfpointanchor{current~bounding~box}{north} } |
| 1836 |
\pgfresetboundingbox |
| 1837 |
% \end{macrocode} |
| 1838 |
% If the timechart is empty, then the extracted \(y\) coordinates of `north' and `south' anchors of the bounding box |
| 1839 |
% will be \qty{-16000}{\point} and \qty{16000}{\point} respectively. Test for this and treat them as both having \(y\) |
| 1840 |
% coordinate \qty{0}{\point} in this case. |
| 1841 |
% \begin{macrocode} |
| 1842 |
\dim_compare:nNnTF{\l_@@_tmpa_dim}>{\l_@@_tmpb_dim} |
| 1843 |
{ |
| 1844 |
\pgfmathsetmacro{\l_@@_content_bottom_y}{0pt} |
| 1845 |
\pgfmathsetmacro{\l_@@_content_top_y}{0pt} |
| 1846 |
} |
| 1847 |
{ |
| 1848 |
\pgfmathsetmacro{\l_@@_content_bottom_y} |
| 1849 |
{\l_@@_tmpa_dim} |
| 1850 |
\pgfmathsetmacro{\l_@@_content_top_y} |
| 1851 |
{\l_@@_tmpb_dim} |
| 1852 |
} |
| 1853 |
% \end{macrocode} |
| 1854 |
% Now draw the grid and axis if necessary and set the bounding box if not. |
| 1855 |
% \begin{macrocode} |
| 1856 |
\bool_if:NTF{\l_@@_grid_bool} |
| 1857 |
{ \@@_grid_draw: } |
| 1858 |
{ \@@_nogrid_bounding_box_set: } |
| 1859 |
\@@_axis_draw: |
| 1860 |
% \end{macrocode} |
| 1861 |
% Finally, end the group begun by \cs{@@_main_begin:nnn}. |
| 1862 |
% \begin{macrocode} |
| 1863 |
\group_end: |
| 1864 |
} |
| 1865 |
% \end{macrocode} |
| 1866 |
% \end{macro} |
| 1867 |
% |
| 1868 |
% |
| 1869 |
% |
| 1870 |
% \subsection{Grid drawing} |
| 1871 |
% |
| 1872 |
% \begin{macro}{\@@_grid_draw:} |
| 1873 |
% Draw the grid of the chart, assuming that the \(y\) coordinates of the top and bottom of the content have been |
| 1874 |
% calculated and stored in \cs{l_@@_content_top_y} and \cs{l_@@_content_bottom_y}. These variable will be updated to |
| 1875 |
% the grid top and bottom. |
| 1876 |
% \begin{macrocode} |
| 1877 |
\cs_new:Npn\@@_grid_draw: |
| 1878 |
{ |
| 1879 |
\pgfmathsetmacro{\l_@@_content_bottom_y}{ |
| 1880 |
\l_@@_content_bottom_y-\l_@@_grid_bottom_ysep_pgf |
| 1881 |
} |
| 1882 |
\pgfmathsetmacro{\l_@@_content_top_y}{ |
| 1883 |
\l_@@_content_top_y+\l_@@_grid_top_ysep_pgf |
| 1884 |
} |
| 1885 |
\pgfonlayer{ grid } |
| 1886 |
\scope[/timechart/grid] |
| 1887 |
\foreach \year in { |
| 1888 |
\l_@@_start_plus_year, |
| 1889 |
\l_@@_start_plusplus_year, |
| 1890 |
..., |
| 1891 |
\l_@@_end_minus_year |
| 1892 |
} { |
| 1893 |
\group_begin: |
| 1894 |
% \end{macrocode} |
| 1895 |
% Only draw gridlines at major ticks. |
| 1896 |
% \begin{macrocode} |
| 1897 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 1898 |
{ Mod(\year,\l_@@_major_tick_interval_year)==0 } |
| 1899 |
\bool_if:NT\l_@@_tmpa_bool |
| 1900 |
{ |
| 1901 |
\pgftransformshift{ \pgfpoint{yeartox(\year)}{0} } |
| 1902 |
\pgfpathmoveto{ \pgfpoint{0}{\l_@@_content_top_y} } |
| 1903 |
\pgfpathlineto{ \pgfpoint{0}{\l_@@_content_bottom_y} } |
| 1904 |
\pgfusepath{ draw } |
| 1905 |
} |
| 1906 |
\group_end: |
| 1907 |
} |
| 1908 |
% \end{macrocode} |
| 1909 |
% Define and draw the grid node. |
| 1910 |
% \begin{macrocode} |
| 1911 |
\@@_make_rectangle_node:nnnn |
| 1912 |
{ \pgfpoint{\l_@@_start_x}{\l_@@_content_bottom_y} } |
| 1913 |
{ \pgfpoint{\l_@@_finish_x}{\l_@@_content_top_y} } |
| 1914 |
{ grid } |
| 1915 |
{ \c_true_bool } |
| 1916 |
\endscope |
| 1917 |
\endpgfonlayer |
| 1918 |
} |
| 1919 |
% \end{macrocode} |
| 1920 |
% \end{macro} |
| 1921 |
% |
| 1922 |
% |
| 1923 |
% |
| 1924 |
% \subsection{Axis drawing} |
| 1925 |
% |
| 1926 |
% \begin{macro}{\@@_axis_draw:} |
| 1927 |
% Draw the axis, with large/small ticks and labels on appropriate years. |
| 1928 |
% \begin{macrocode} |
| 1929 |
\cs_new:Npn\@@_axis_draw: |
| 1930 |
{ |
| 1931 |
\group_begin: |
| 1932 |
\int_case:nn{ \l_@@_axis_int } |
| 1933 |
{ |
| 1934 |
{0} |
| 1935 |
{ \prg_do_nothing: } |
| 1936 |
{1} |
| 1937 |
{ |
| 1938 |
\pgftransformshift{ |
| 1939 |
\pgfpoint{0}{ |
| 1940 |
\l_@@_content_top_y |
| 1941 |
+\pgfkeysvalueof{/timechart/axis~ysep} |
| 1942 |
} |
| 1943 |
} |
| 1944 |
\pgfmathsetmacro{\l_@@_tick_orientation_pgf}{1} |
| 1945 |
\cs_set:Npn\l_@@_tick_label_anchor_text |
| 1946 |
{ mid~west } |
| 1947 |
\cs_set:Npn\l_@@_zero_tick_before_label_anchor_text |
| 1948 |
{ base~west } |
| 1949 |
\cs_set:Npn\l_@@_zero_tick_after_label_anchor_text |
| 1950 |
{ north~west } |
| 1951 |
\@@_axis_draw_aux: |
| 1952 |
} |
| 1953 |
{2} |
| 1954 |
{ |
| 1955 |
\pgftransformshift{ |
| 1956 |
\pgfpoint{0}{ |
| 1957 |
\l_@@_content_bottom_y |
| 1958 |
-\pgfkeysvalueof{/timechart/axis~ysep} |
| 1959 |
} |
| 1960 |
} |
| 1961 |
\pgfmathsetmacro{\l_@@_tick_orientation_pgf}{-1} |
| 1962 |
\cs_set:Npn\l_@@_tick_label_anchor_text |
| 1963 |
{ mid~east } |
| 1964 |
\cs_set:Npn\l_@@_zero_tick_before_label_anchor_text |
| 1965 |
{ base~east } |
| 1966 |
\cs_set:Npn\l_@@_zero_tick_after_label_anchor_text |
| 1967 |
{ north~east } |
| 1968 |
\@@_axis_draw_aux: |
| 1969 |
} |
| 1970 |
} |
| 1971 |
\group_end: |
| 1972 |
} |
| 1973 |
% \end{macrocode} |
| 1974 |
% \end{macro} |
| 1975 |
% |
| 1976 |
% \begin{macro}{\@@_axis_draw_aux:} |
| 1977 |
% Draw the axis, with large/small ticks and labels on appropriate years, assuming that the \(y\) coordinate has been |
| 1978 |
% calculated and stored in \cs{l_@@_axis_y}. |
| 1979 |
% \begin{macrocode} |
| 1980 |
\cs_new:Npn\@@_axis_draw_aux: |
| 1981 |
{ |
| 1982 |
\pgfkeys{ |
| 1983 |
/timechart/minor~tick~length/.get=\@@_minor_tick_length_pgf, |
| 1984 |
/timechart/major~tick~length/.get=\@@_major_tick_length_pgf, |
| 1985 |
} |
| 1986 |
% \end{macrocode} |
| 1987 |
% Work out the first and last years which will have a major tick (since these are marked with the era). |
| 1988 |
% \begin{macrocode} |
| 1989 |
\pgfmathsetmacro{\l_@@_start_major_tick_year} |
| 1990 |
{ |
| 1991 |
\l_@@_start_year |
| 1992 |
-Mod( |
| 1993 |
\l_@@_start_year, |
| 1994 |
\l_@@_major_tick_interval_year |
| 1995 |
) |
| 1996 |
} |
| 1997 |
\pgfmathsetmacro{\l_@@_start_major_tick_year} |
| 1998 |
{ |
| 1999 |
ifthenelse( |
| 2000 |
\l_@@_start_major_tick_year<\l_@@_start_year, |
| 2001 |
\l_@@_start_major_tick_year |
| 2002 |
+\l_@@_major_tick_interval_year, |
| 2003 |
\l_@@_start_major_tick_year |
| 2004 |
) |
| 2005 |
} |
| 2006 |
\pgfmathsetmacro{\l_@@_start_plus_major_tick_year} |
| 2007 |
{ |
| 2008 |
\l_@@_start_major_tick_year |
| 2009 |
+\l_@@_major_tick_interval_year |
| 2010 |
} |
| 2011 |
\pgfmathsetmacro{\l_@@_finish_major_tick_year} |
| 2012 |
{ |
| 2013 |
\l_@@_finish_year |
| 2014 |
-Mod( |
| 2015 |
\l_@@_finish_year, |
| 2016 |
\l_@@_major_tick_interval_year |
| 2017 |
) |
| 2018 |
} |
| 2019 |
% \end{macrocode} |
| 2020 |
% Loop over years and draw the minor ticks. |
| 2021 |
% \begin{macrocode} |
| 2022 |
\foreach \year in { |
| 2023 |
\l_@@_start_year, |
| 2024 |
\l_@@_start_plus_year, |
| 2025 |
..., |
| 2026 |
\l_@@_finish_year |
| 2027 |
} { |
| 2028 |
\pgfmathsetmacro{\x}{yeartox(\year)} |
| 2029 |
\@@_pgfmathsetbool:nn |
| 2030 |
{\l_@@_tmpa_bool} |
| 2031 |
{ |
| 2032 |
Mod( |
| 2033 |
\year-\l_@@_start_major_tick_year, |
| 2034 |
\l_@@_major_tick_interval_year |
| 2035 |
)==0 |
| 2036 |
} |
| 2037 |
\bool_if:NF\l_@@_tmpa_bool |
| 2038 |
{ \@@_axis_draw_minor_tick:N\x } |
| 2039 |
} |
| 2040 |
% \end{macrocode} |
| 2041 |
% Loop over years and draw the major ticks. |
| 2042 |
% \begin{macrocode} |
| 2043 |
\foreach \year in { |
| 2044 |
\l_@@_start_major_tick_year, |
| 2045 |
\l_@@_start_plus_major_tick_year, |
| 2046 |
..., |
| 2047 |
\l_@@_finish_major_tick_year |
| 2048 |
} { |
| 2049 |
\pgfmathsetmacro{\x}{yeartox(\year)} |
| 2050 |
\@@_axis_draw_labelled_major_tick:NN\x\year |
| 2051 |
} |
| 2052 |
% \end{macrocode} |
| 2053 |
% Define the axis line and define the axis node. |
| 2054 |
% \begin{macrocode} |
| 2055 |
\@@_draw_axis_line |
| 2056 |
\int_case:nn{\l_@@_axis_int} |
| 2057 |
{ |
| 2058 |
{1} |
| 2059 |
{ |
| 2060 |
\pgfextracty{\l_@@_tmpa_dim} |
| 2061 |
{ \pgfpointanchor{current~bounding~box}{north} } |
| 2062 |
\pgfmathsetmacro{\l_@@_axis_top_y}{\l_@@_tmpa_dim} |
| 2063 |
\pgfmathsetmacro{\l_@@_axis_bottom_y}{0} |
| 2064 |
} |
| 2065 |
{2} |
| 2066 |
{ |
| 2067 |
\pgfextracty{\l_@@_tmpa_dim} |
| 2068 |
{ \pgfpointanchor{current~bounding~box}{south} } |
| 2069 |
\pgfmathsetmacro{\l_@@_axis_top_y}{0} |
| 2070 |
\pgfmathsetmacro{\l_@@_axis_bottom_y}{\l_@@_tmpa_dim} |
| 2071 |
} |
| 2072 |
} |
| 2073 |
\@@_make_rectangle_node:nnnn |
| 2074 |
{ \pgfpoint{\l_@@_start_x}{\l_@@_axis_bottom_y} } |
| 2075 |
{ \pgfpoint{\l_@@_finish_x}{\l_@@_axis_top_y} } |
| 2076 |
{ axis } |
| 2077 |
{ \c_false_bool } |
| 2078 |
} |
| 2079 |
% \end{macrocode} |
| 2080 |
% \end{macro} |
| 2081 |
% |
| 2082 |
% All the remaining axis-related macros (which begin \cs{@@_axis_draw_}) assume that a transformation has been applied |
| 2083 |
% so that the axis line is at \(y=0\). |
| 2084 |
% |
| 2085 |
% \begin{macro}{\@@_axis_draw_minor_tick:N} |
| 2086 |
% Draw an unlabelled tick at \(x\) coordinate \param{1}. |
| 2087 |
% \begin{macrocode} |
| 2088 |
\cs_new:Npn\@@_axis_draw_minor_tick:N #1 |
| 2089 |
{ |
| 2090 |
\scope[/timechart/minor~tick] |
| 2091 |
\pgfpathmoveto{ \pgfpoint{#1}{0} } |
| 2092 |
\pgfpathlineto{ |
| 2093 |
\pgfpoint{#1}{ |
| 2094 |
\l_@@_tick_orientation_pgf |
| 2095 |
*\@@_minor_tick_length_pgf |
| 2096 |
} |
| 2097 |
} |
| 2098 |
\pgfusepath{draw} |
| 2099 |
\endscope |
| 2100 |
} |
| 2101 |
% \end{macrocode} |
| 2102 |
% \end{macro} |
| 2103 |
% |
| 2104 |
% \begin{macro}{\@@_axis_draw_labelled_major_tick:NN} |
| 2105 |
% Draw a labelled major tick at \(x\) coordinate \param{1}, with label for year \param{2}, using the special epoch |
| 2106 |
% marker if the year is 0, and showing the era if and only if the year is for the first or last major tick. This macro |
| 2107 |
% assumes that \cs{@@_start_major_tick_year} and \cs{@@_finish_major_tick_year} have been calculated. |
| 2108 |
% \begin{macrocode} |
| 2109 |
\cs_new:Npn\@@_axis_draw_labelled_major_tick:NN #1#2 |
| 2110 |
{ |
| 2111 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool}{#2==0} |
| 2112 |
\bool_if:NTF \l_@@_tmpa_bool |
| 2113 |
{ \@@_axis_draw_zero_tick:N #1 } |
| 2114 |
{ |
| 2115 |
\int_case:nn { \l_@@_major_tick_eras_int } |
| 2116 |
{ |
| 2117 |
{0}{ \bool_set_false:N\l_@@_tmpd_bool } |
| 2118 |
{1}{ \bool_set_true:N\l_@@_tmpd_bool } |
| 2119 |
{2} |
| 2120 |
{ |
| 2121 |
\@@_pgfmathsetbool:nn{\l_@@_tmpb_bool} |
| 2122 |
{ #2==\l_@@_start_major_tick_year } |
| 2123 |
\@@_pgfmathsetbool:nn{\l_@@_tmpc_bool} |
| 2124 |
{ #2==\l_@@_finish_major_tick_year } |
| 2125 |
\bool_set:Nn\l_@@_tmpd_bool |
| 2126 |
{ \l_@@_tmpb_bool || \l_@@_tmpc_bool } |
| 2127 |
} |
| 2128 |
} |
| 2129 |
\@@_axis_draw_major_tick:N #1 |
| 2130 |
\@@_axis_draw_year_label:nnnnnn |
| 2131 |
{ #1 } |
| 2132 |
{ #2 } |
| 2133 |
{ \l_@@_tmpd_bool } |
| 2134 |
{ \l_@@_tick_label_anchor_text } |
| 2135 |
{ 0 } |
| 2136 |
{ |
| 2137 |
\l_@@_tick_orientation_pgf |
| 2138 |
*(\@@_major_tick_length_pgf+1mm) |
| 2139 |
} |
| 2140 |
} |
| 2141 |
} |
| 2142 |
% \end{macrocode} |
| 2143 |
% \end{macro} |
| 2144 |
% |
| 2145 |
% \begin{macro}{\@@_axis_draw_major_tick:N} |
| 2146 |
% Draw a major tick at \(x\) coordinate \param{1}. |
| 2147 |
% \begin{macrocode} |
| 2148 |
\cs_new:Npn\@@_axis_draw_major_tick:N #1 |
| 2149 |
{ |
| 2150 |
\scope[/timechart/major~tick] |
| 2151 |
\pgfpathmoveto{ \pgfpoint{#1}{0} } |
| 2152 |
\pgfpathlineto{ |
| 2153 |
\pgfpoint{#1}{ |
| 2154 |
\l_@@_tick_orientation_pgf |
| 2155 |
*\@@_major_tick_length_pgf |
| 2156 |
} |
| 2157 |
} |
| 2158 |
\pgfusepath{draw} |
| 2159 |
\endscope |
| 2160 |
} |
| 2161 |
% \end{macrocode} |
| 2162 |
% \end{macro} |
| 2163 |
% |
| 2164 |
% \begin{macro}{\@@_axis_draw_zero_tick:N} |
| 2165 |
% Draw a special (labelled) tick for year zero at \(x=\param{1}\). |
| 2166 |
% \begin{macrocode} |
| 2167 |
\cs_new:Npn\@@_axis_draw_zero_tick:N #1 |
| 2168 |
{ |
| 2169 |
\group_begin: |
| 2170 |
\pgftransformshift{ \pgfpoint{#1}{0} } |
| 2171 |
% \end{macrocode} |
| 2172 |
% The mark is a cross made up of four arcs and the miter joins between them. The parameter \cs{r} is the arc radius. |
| 2173 |
% The parameter \cs{a} is how many degrees should be trimmed from the start/end of a quarter-circle to form each arc. |
| 2174 |
% Thus the length of the miter is dependent on \cs{a}. |
| 2175 |
% \begin{macrocode} |
| 2176 |
\pgfmathsetmacro{\a}{5} |
| 2177 |
\pgfmathsetlengthmacro{\r}{1mm} |
| 2178 |
\pgfmathsetlengthmacro{\t}{\r*(cos(\a)-cos(90-\a))/(1-cos(90-\a))} |
| 2179 |
% \end{macrocode} |
| 2180 |
% The drawing process is: move to the start of the tick, draw the tick, draw the four arcs, then draw a small part of |
| 2181 |
% the tick again. The last step is not mathematically necessary for a smooth join, but ensures that the join |
| 2182 |
% \emph{appears} smooth. |
| 2183 |
% \begin{macrocode} |
| 2184 |
\scope[/timechart/major~tick,line~join=miter] |
| 2185 |
\group_begin: |
| 2186 |
\pgftransformyscale{\l_@@_tick_orientation_pgf} |
| 2187 |
\pgfpathmoveto{\pgfpointorigin} |
| 2188 |
\pgfpathlineto{\pgfpoint{0}{\@@_major_tick_length_pgf}} |
| 2189 |
\pgfpatharc{0}{90-\a}{\t~and~\r} |
| 2190 |
\pgfpatharc{270+\a}{360-\a}{\r} |
| 2191 |
\pgfpatharc{180+\a}{270-\a}{\r} |
| 2192 |
\pgfpatharc{90+\a}{180-\a}{\t~and~\r} |
| 2193 |
\pgfpathlineto{\pgfpoint{0}{\@@_major_tick_length_pgf-1pt}} |
| 2194 |
\pgfusepath{draw} |
| 2195 |
\group_end: |
| 2196 |
\endscope |
| 2197 |
% \end{macrocode} |
| 2198 |
% There is no year 0, so label the zero mark with the 1 before and 1 after the epoch. |
| 2199 |
% \begin{macrocode} |
| 2200 |
\@@_axis_draw_year_label:nnnnnn |
| 2201 |
{ 0 } |
| 2202 |
{ -1 } |
| 2203 |
{ \c_true_bool } |
| 2204 |
{ \l_@@_zero_tick_before_label_anchor_text } |
| 2205 |
{ -.5mm } |
| 2206 |
{ \l_@@_tick_orientation_pgf*5.5mm } |
| 2207 |
\@@_axis_draw_year_label:nnnnnn |
| 2208 |
{ 0 } |
| 2209 |
{ 1 } |
| 2210 |
{ \c_true_bool } |
| 2211 |
{ \l_@@_zero_tick_after_label_anchor_text } |
| 2212 |
{ .5mm } |
| 2213 |
{ \l_@@_tick_orientation_pgf*5.5mm } |
| 2214 |
\group_end: |
| 2215 |
} |
| 2216 |
% \end{macrocode} |
| 2217 |
% \end{macro} |
| 2218 |
% |
| 2219 |
% \begin{macro}{\@@_axis_draw_line} |
| 2220 |
% Draw the axis line itself. |
| 2221 |
% \begin{macrocode} |
| 2222 |
\cs_new:Npn\@@_draw_axis_line |
| 2223 |
{ |
| 2224 |
\scope[/timechart/axis~line] |
| 2225 |
\pgfpathmoveto{ \pgfpoint{\l_@@_start_x}{0} } |
| 2226 |
\pgfpathlineto{ \pgfpoint{\l_@@_finish_x}{0} } |
| 2227 |
\pgfusepath{draw} |
| 2228 |
\endscope |
| 2229 |
} |
| 2230 |
% \end{macrocode} |
| 2231 |
% \end{macro} |
| 2232 |
% |
| 2233 |
% \begin{macro}{\@@_axis_draw_year_label:nnnnnn} |
| 2234 |
% Draw a year label. |
| 2235 |
% \begin{arguments} |
| 2236 |
% \item \(x\) coordinate. |
| 2237 |
% \item Year for label. |
| 2238 |
% \item Boolean literal indicating whether the era should be shown. |
| 2239 |
% \item Anchor for node. |
| 2240 |
% \item \(x\) offset (dimension). |
| 2241 |
% \item \(y\) offset (dimension). |
| 2242 |
% \end{arguments} |
| 2243 |
% \begin{macrocode} |
| 2244 |
\cs_new:Npn\@@_axis_draw_year_label:nnnnnn #1#2#3#4#5#6 |
| 2245 |
{ |
| 2246 |
\group_begin: |
| 2247 |
\pgftransformshift{ \pgfpoint{#1+#5}{#6} } |
| 2248 |
\pgfmathtruncatemacro{\absyear}{ abs(#2) } |
| 2249 |
\scope[/timechart/major~tick~label] |
| 2250 |
\bool_if:NTF #3 |
| 2251 |
{ |
| 2252 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool}{#2<0} |
| 2253 |
\bool_if:NTF\l_@@_tmpa_bool |
| 2254 |
{ \cs_set_eq:NN\@@_make_year:n\timechartmakebeforeyear } |
| 2255 |
{ \cs_set_eq:NN\@@_make_year:n\timechartmakeafteryear } |
| 2256 |
} |
| 2257 |
{ \cs_set_eq:NN\@@_make_year:n\use:n } |
| 2258 |
\@@_hsmash_pgfnode:nnnnn |
| 2259 |
{rectangle} |
| 2260 |
{#4} |
| 2261 |
{\@@_make_year:n{\absyear}} |
| 2262 |
{} |
| 2263 |
{} |
| 2264 |
\endscope |
| 2265 |
\group_end: |
| 2266 |
} |
| 2267 |
% \end{macrocode} |
| 2268 |
% \end{macro} |
| 2269 |
% |
| 2270 |
% \begin{macro}{\timechartmakebeforeyear,\timechartmakeafteryear} |
| 2271 |
% User-redefineable macros to format a year as before or after the epoch. |
| 2272 |
% \begin{macrocode} |
| 2273 |
\cs_new:Npn\timechartmakebeforeyear #1 |
| 2274 |
{ |
| 2275 |
#1\nobreakspace\textsc{bce} |
| 2276 |
} |
| 2277 |
\cs_new:Npn\timechartmakeafteryear #1 |
| 2278 |
{ |
| 2279 |
#1\nobreakspace\textsc{ce} |
| 2280 |
} |
| 2281 |
% \end{macrocode} |
| 2282 |
% \end{macro} |
| 2283 |
% |
| 2284 |
% |
| 2285 |
% |
| 2286 |
% \subsection{Bounding box} |
| 2287 |
% |
| 2288 |
% \begin{macro}{\@@_nogrid_bounding_box_set:} |
| 2289 |
% Set the bounding box when no grid is being drawn. |
| 2290 |
% \begin{macrocode} |
| 2291 |
\cs_new:Npn\@@_nogrid_bounding_box_set: |
| 2292 |
{ |
| 2293 |
\pgfpathmoveto |
| 2294 |
{ \pgfpoint{\l_@@_start_x}{\l_@@_content_bottom_y} } |
| 2295 |
\pgfpathmoveto |
| 2296 |
{ \pgfpoint{\l_@@_finish_x}{\l_@@_content_top_y} } |
| 2297 |
\pgfusepath{discard} |
| 2298 |
} |
| 2299 |
% \end{macrocode} |
| 2300 |
% \end{macro} |
| 2301 |
% |
| 2302 |
% |
| 2303 |
% |
| 2304 |
% \subsection{Positioning} |
| 2305 |
% |
| 2306 |
% \begin{macro}{\@@_set_y_user:m} |
| 2307 |
% Set current \(y\) coordinate to \param{1}. This macro will be made available as \cs{timechartsety} in the |
| 2308 |
% \env{timechart} environment. |
| 2309 |
% \begin{macrocode} |
| 2310 |
\cs_new:Npn\@@_set_y_user:m #1 |
| 2311 |
{ |
| 2312 |
\pgfmathsetmacro{\l_@@_current_y}{#1} |
| 2313 |
} |
| 2314 |
% \end{macrocode} |
| 2315 |
% \end{macro} |
| 2316 |
% |
| 2317 |
% \begin{macro}{\@@_save_y_user:} |
| 2318 |
% Save the current \(y\) coordinate. This macro will be made available as \cs{timechartsavey} in the |
| 2319 |
% \env{timechart} environment. |
| 2320 |
% \begin{macrocode} |
| 2321 |
\cs_new:Npn\@@_save_y_user: |
| 2322 |
{ |
| 2323 |
\pgfmathsetmacro{\l_@@_saved_y}{\l_@@_current_y} |
| 2324 |
} |
| 2325 |
% \end{macrocode} |
| 2326 |
% \end{macro} |
| 2327 |
% |
| 2328 |
% \begin{macro}{\@@_reset_y_user:} |
| 2329 |
% Set the current \(y\) coordinate to the last saved coordinate. This macro will be made available as |
| 2330 |
% \cs{timechartsresety} in the \env{timechart} environment. |
| 2331 |
% \begin{macrocode} |
| 2332 |
\cs_new:Npn\@@_reset_y_user: |
| 2333 |
{ |
| 2334 |
\pgfmathsetmacro{\l_@@_current_y}{\l_@@_saved_y} |
| 2335 |
} |
| 2336 |
% \end{macrocode} |
| 2337 |
% \end{macro} |
| 2338 |
% |
| 2339 |
% \begin{macro}{\@@_set_y_minimum_auto_reset_user:m} |
| 2340 |
% Set a \(y\) coordinate below which \cs{@@_step_y_user:} will automatically reset the currrent \(y\) coordinate to |
| 2341 |
% the last saved \(y\) coordinate. This macro will be made available as \cs{timechartssetyminimumautoreset} in the |
| 2342 |
% \env{timechart} environment. |
| 2343 |
% \begin{macrocode} |
| 2344 |
\cs_new:Npn\@@_set_y_minimum_auto_reset_user:m #1 |
| 2345 |
{ |
| 2346 |
\pgfmathsetmacro{\l_@@_auto_reset_minimum_y}{#1} |
| 2347 |
} |
| 2348 |
% \end{macrocode} |
| 2349 |
% \end{macro} |
| 2350 |
% |
| 2351 |
% \begin{macro}{\@@_set_y_maximum_auto_reset_user:m} |
| 2352 |
% Set a \(y\) coordinate above which \cs{@@_step_y_user:} will automatically reset the currrent \(y\) coordinate to |
| 2353 |
% the last saved \(y\) coordinate. This macro will be made available as \cs{timechartssetymaximumautoreset} in the |
| 2354 |
% \env{timechart} environment. |
| 2355 |
% \begin{macrocode} |
| 2356 |
\cs_new:Npn\@@_set_y_maximum_auto_reset_user:m #1 |
| 2357 |
{ |
| 2358 |
\pgfmathsetmacro{\l_@@_auto_reset_maximum_y}{#1} |
| 2359 |
} |
| 2360 |
% \end{macrocode} |
| 2361 |
% \end{macro} |
| 2362 |
% |
| 2363 |
% \begin{macro}{\@@_step_y_user:O} |
| 2364 |
% Increment the current \(y\) coordinate by \param{1} times the length specified in \key{/timechart/ystep}. This |
| 2365 |
% macro will be made available as \cs{timechartstepy} in the \env{timechart} environment. |
| 2366 |
% \begin{macrocode} |
| 2367 |
\NewDocumentCommand{\@@_step_y_user:O}{ O{1} } |
| 2368 |
{ |
| 2369 |
\pgfmathsetmacro{\l_@@_current_y} |
| 2370 |
{\l_@@_current_y+#1*\l_@@_ystep_pgf} |
| 2371 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 2372 |
{ |
| 2373 |
or( |
| 2374 |
\l_@@_current_y<\l_@@_auto_reset_minimum_y, |
| 2375 |
\l_@@_current_y>\l_@@_auto_reset_maximum_y |
| 2376 |
) |
| 2377 |
} |
| 2378 |
\bool_if:nT{\l_@@_tmpa_bool} |
| 2379 |
{ \pgfmathsetmacro{\l_@@_current_y}{\l_@@_saved_y)} } |
| 2380 |
} |
| 2381 |
% \end{macrocode} |
| 2382 |
% \end{macro} |
| 2383 |
% |
| 2384 |
% |
| 2385 |
% |
| 2386 |
% \subsection{Bounds checking} |
| 2387 |
% |
| 2388 |
% \begin{macro}{\@@_if_x_in_bounds:nT}% |
| 2389 |
% Check if \(x\) coordinate \param{1} is (strictly) within the bounds of the chart; if so, execute \param{2}. |
| 2390 |
% \begin{macrocode} |
| 2391 |
\cs_new:Npn\@@_if_x_in_bounds:nT #1#2 |
| 2392 |
{ |
| 2393 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool}{ |
| 2394 |
and( |
| 2395 |
#1>=\l_@@_start_x, |
| 2396 |
#1<=\l_@@_finish_x |
| 2397 |
) |
| 2398 |
} |
| 2399 |
\bool_if:NT\l_@@_tmpa_bool |
| 2400 |
{#2} |
| 2401 |
} |
| 2402 |
|
| 2403 |
% \end{macrocode} |
| 2404 |
% \end{macro} |
| 2405 |
% |
| 2406 |
% \begin{macro}{\@@_if_x_range_intersect_bounds_x:nnT}% |
| 2407 |
% Check if the range between \(x\) coordinates \param{1} and \param{2} intersects the range of the bounds of the |
| 2408 |
% chart; if so, execute \param{3}. |
| 2409 |
% \begin{macrocode} |
| 2410 |
\cs_new:Npn\@@_if_x_range_intersect_bounds:nnT #1#2#3 |
| 2411 |
{ |
| 2412 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool}{ |
| 2413 |
or( |
| 2414 |
or( |
| 2415 |
and( |
| 2416 |
#2>=\l_@@_start_x, |
| 2417 |
#2<=\l_@@_finish_x |
| 2418 |
), |
| 2419 |
and( |
| 2420 |
#1>=\l_@@_start_x, |
| 2421 |
#1<=\l_@@_finish_x |
| 2422 |
) |
| 2423 |
), |
| 2424 |
and( |
| 2425 |
#1<\l_@@_start_x, |
| 2426 |
#2>\l_@@_finish_x |
| 2427 |
) |
| 2428 |
) |
| 2429 |
} |
| 2430 |
\bool_if:NT\l_@@_tmpa_bool |
| 2431 |
{#3} |
| 2432 |
} |
| 2433 |
% \end{macrocode} |
| 2434 |
% \end{macro} |
| 2435 |
% |
| 2436 |
% |
| 2437 |
% |
| 2438 |
% \subsection{Date and date range parsing} |
| 2439 |
% |
| 2440 |
% \begin{macro}{\@@_parse_date_or_daterange:NNNNNn} |
| 2441 |
% Parse the text in \param{6}, which should represent a date or date range, into parameters \param{1}--\param{5}. |
| 2442 |
% \begin{arguments} |
| 2443 |
% \item range indicator boolean variable. |
| 2444 |
% \item minimum circa indicator boolean variable. |
| 2445 |
% \item minimum variable. |
| 2446 |
% \item maximum circa indicator boolean variable. |
| 2447 |
% \item maximum variable. |
| 2448 |
% \item text to parse. |
| 2449 |
% \end{arguments} |
| 2450 |
% \begin{macrocode} |
| 2451 |
\cs_new:Npn\@@_parse_date_or_daterange:NNNNNn #1#2#3#4#5#6 |
| 2452 |
{ |
| 2453 |
\bool_set:Nn #1 {\@@_is_nondaterange_p:w #6/\q_stop} |
| 2454 |
\bool_set_inverse:N #1 |
| 2455 |
\bool_if:nTF #1 |
| 2456 |
{ \@@_parse_range:w #2#3#4#5\q_mark #6\q_stop } |
| 2457 |
{ |
| 2458 |
\@@_parse_date:NNn #2#3{#6} |
| 2459 |
\bool_set_eq:NN #4#2 |
| 2460 |
\pgfmathsetmacro{#5}{#3} |
| 2461 |
} |
| 2462 |
} |
| 2463 |
% \end{macrocode} |
| 2464 |
% \end{macro} |
| 2465 |
% |
| 2466 |
% \begin{macro}{\@@_is_nondaterange_p:w} |
| 2467 |
% To be called in the form \cs{@@_is_nondaterange_p:w}\meta{text}\texttt{/}\cs{q_stop}. Return boolean true if and |
| 2468 |
% only if \meta{text} (known to be either a date or date range) contains a range marker. |
| 2469 |
% \begin{macrocode} |
| 2470 |
\cs_new:Npn\@@_is_nondaterange_p:w #1/#2\q_stop |
| 2471 |
{ |
| 2472 |
\tl_if_empty_p:n{#2} |
| 2473 |
} |
| 2474 |
% \end{macrocode} |
| 2475 |
% \end{macro} |
| 2476 |
% \begin{macro}{\@@_parse_range:w} |
| 2477 |
% To be called in the form |
| 2478 |
% \cs{@@_parse_range:w}\meta{cmin}\meta{min}\meta{cmax}\meta{max}\cs{q_mark}\meta{text}\cs{q_stop}. Parse \meta{text} |
| 2479 |
% (known to represent a date range) into minimum circa indicator boolean variable \meta{cmin}, minimum variable |
| 2480 |
% \meta{min}, maximum circa indicator boolean variable \meta{cmax}, maximum variable \meta{max}. |
| 2481 |
% \begin{macrocode} |
| 2482 |
\cs_new:Npn\@@_parse_range:w #1#2#3#4\q_mark #5/#6\q_stop |
| 2483 |
{ |
| 2484 |
\_@@_parse_date:NNn #1#2{#5} |
| 2485 |
\_@@_parse_date:NNn #3#4{#6} |
| 2486 |
} |
| 2487 |
% \end{macrocode} |
| 2488 |
% \end{macro} |
| 2489 |
% |
| 2490 |
% \begin{macro}{\@@_parse_date:NNn} |
| 2491 |
% Parse text (known to represent a date) into the supplied variables. Parameters \param{1} and \param{2} are the |
| 2492 |
% variables for (respectively) circa indicator boolean and date, and \param{3} is the text to be parsed: |
| 2493 |
% \begin{arguments} |
| 2494 |
% \item circa indicator boolean variable. |
| 2495 |
% \item date variable. |
| 2496 |
% \item text to parse. |
| 2497 |
% \end{arguments} |
| 2498 |
% \begin{macrocode} |
| 2499 |
\cs_new:Npn\@@_parse_date:NNn #1#2#3 |
| 2500 |
{ |
| 2501 |
\bool_set:Nn #1 { \@@_is_circa_p:w #3c\q_stop } |
| 2502 |
\bool_if:NTF #1 |
| 2503 |
{ \@@_parse_circa_date:w #2\q_mark #3\q_stop } |
| 2504 |
{ \@@_parse_noncirca_date:Nn #2{#3} } |
| 2505 |
} |
| 2506 |
% \end{macrocode} |
| 2507 |
% \end{macro} |
| 2508 |
% |
| 2509 |
% \begin{macro}{\@@_is_circa_p:w} |
| 2510 |
% To be called in the form \cs{@@_is_circa_p:w}\meta{text}\texttt{c}\cs{q_stop}. Return boolean true if and only if |
| 2511 |
% \meta{text} (known to be either a date or a date with a circa indicator) has a circa indicator. |
| 2512 |
% \begin{macrocode} |
| 2513 |
\cs_new:Npn\@@_is_circa_p:w #1c#2\q_stop |
| 2514 |
{ |
| 2515 |
\tl_if_empty_p:n{#1} |
| 2516 |
} |
| 2517 |
% \end{macrocode} |
| 2518 |
% \end{macro} |
| 2519 |
% |
| 2520 |
% \begin{macro}{\@@_parse_circa_date:w} |
| 2521 |
% To be called in the form \cs{@@_parse_circa_date:w}\meta{var}\cs{q_mark}\meta{text}\cs{q_stop}. Parse \meta{text} |
| 2522 |
% (known to represent a circa date) into the supplied variable. \param{1} is the variable for the date and \param{2} |
| 2523 |
% is the text to be parsed. |
| 2524 |
% \begin{macrocode} |
| 2525 |
\cs_new:Npn\@@_parse_circa_date:w #1\q_mark c#2\q_stop |
| 2526 |
{ |
| 2527 |
\@@_parse_noncirca_date:Nn #1{#2} |
| 2528 |
} |
| 2529 |
% \end{macrocode} |
| 2530 |
% \end{macro} |
| 2531 |
% |
| 2532 |
% \begin{macro}{\@@_parse_noncirca_date:w} |
| 2533 |
% To be called in the form \cs{@@_parse_noncirca_date:w}\meta{var}\cs{q_mark}\meta{text}\break\cs{q_stop}. Parse |
| 2534 |
% \meta{text} (known to represent a non-circa date) into the supplied variable. \param{1} is the variable for the date |
| 2535 |
% and \param{2} is the text to be parsed. |
| 2536 |
% \begin{macrocode} |
| 2537 |
\cs_new:Npn\@@_parse_noncirca_date:Nn #1#2 |
| 2538 |
{ |
| 2539 |
\bool_if:nTF { \@@_is_before_p:w #2-\q_stop } |
| 2540 |
{ \@@_parse_before_date:w #1\q_mark #2\q_stop } |
| 2541 |
{ \@@_parse_signed_date:w #1\q_mark #2-0-0\q_stop } |
| 2542 |
} |
| 2543 |
% \end{macrocode} |
| 2544 |
% \end{macro} |
| 2545 |
% |
| 2546 |
% \begin{macro}{\@@_is_before_p:w} |
| 2547 |
% To be called in the form \cs{@@_is_before_p:w}\meta{text}\texttt{-}\cs{q_stop}. Return boolean true if and only if |
| 2548 |
% \meta{text} (known to be a date without a circa indicator) begins with a \texttt{-}. |
| 2549 |
% \begin{macrocode} |
| 2550 |
\cs_new:Npn\@@_is_before_p:w #1-#2\q_stop |
| 2551 |
{ |
| 2552 |
\tl_if_empty_p:n{#1} |
| 2553 |
} |
| 2554 |
% \end{macrocode} |
| 2555 |
% \end{macro} |
| 2556 |
% |
| 2557 |
% \begin{macro}{\@@_parse_before_date:w} |
| 2558 |
% To be called in the form \cs{@@_parse_before_date:w}\meta{var}\cs{q_mark}\meta{text}\cs{q_stop}. Parse \meta{text} |
| 2559 |
% (known to represent a date with a leading \texttt{-}) into the supplied variable. \param{1} is the variable for the |
| 2560 |
% date and \param{2} is the text to be parsed. |
| 2561 |
% \begin{macrocode} |
| 2562 |
\cs_new:Npn\@@_parse_before_date:w #1\q_mark-#2\q_stop |
| 2563 |
{ |
| 2564 |
\@@_parse_signed_date:w #1-\q_mark #2-0-0\q_stop |
| 2565 |
} |
| 2566 |
% \end{macrocode} |
| 2567 |
% \end{macro} |
| 2568 |
% |
| 2569 |
% Now comes that actual parsing of an ISO-format date \texttt{YYYY-MM-DD}. The following macros serve as lookup tables |
| 2570 |
% for the number of days in the \(n\)-th month and the number of days in the year up to the start of the \(n\)-th month. |
| 2571 |
% \begin{macrocode} |
| 2572 |
\cs_new:cpn{c_@@_year_days_pgf}{365} |
| 2573 |
\cs_new:cpn{c_@@_month_days_1_pgf}{31} |
| 2574 |
\cs_new:cpn{c_@@_month_days_2_pgf}{28} |
| 2575 |
\cs_new:cpn{c_@@_month_days_3_pgf}{31} |
| 2576 |
\cs_new:cpn{c_@@_month_days_4_pgf}{30} |
| 2577 |
\cs_new:cpn{c_@@_month_days_5_pgf}{31} |
| 2578 |
\cs_new:cpn{c_@@_month_days_6_pgf}{30} |
| 2579 |
\cs_new:cpn{c_@@_month_days_7_pgf}{31} |
| 2580 |
\cs_new:cpn{c_@@_month_days_8_pgf}{31} |
| 2581 |
\cs_new:cpn{c_@@_month_days_9_pgf}{30} |
| 2582 |
\cs_new:cpn{c_@@_month_days_10_pgf}{31} |
| 2583 |
\cs_new:cpn{c_@@_month_days_11_pgf}{30} |
| 2584 |
\cs_new:cpn{c_@@_month_days_12_pgf}{31} |
| 2585 |
\cs_new:cpn{c_@@_cumulative_days_1_pgf}{0} |
| 2586 |
\cs_new:cpn{c_@@_cumulative_days_2_pgf}{31} |
| 2587 |
\cs_new:cpn{c_@@_cumulative_days_3_pgf}{59} |
| 2588 |
\cs_new:cpn{c_@@_cumulative_days_4_pgf}{90} |
| 2589 |
\cs_new:cpn{c_@@_cumulative_days_5_pgf}{120} |
| 2590 |
\cs_new:cpn{c_@@_cumulative_days_6_pgf}{151} |
| 2591 |
\cs_new:cpn{c_@@_cumulative_days_7_pgf}{181} |
| 2592 |
\cs_new:cpn{c_@@_cumulative_days_8_pgf}{212} |
| 2593 |
\cs_new:cpn{c_@@_cumulative_days_9_pgf}{243} |
| 2594 |
\cs_new:cpn{c_@@_cumulative_days_10_pgf}{273} |
| 2595 |
\cs_new:cpn{c_@@_cumulative_days_11_pgf}{304} |
| 2596 |
\cs_new:cpn{c_@@_cumulative_days_12_pgf}{334} |
| 2597 |
% \end{macrocode} |
| 2598 |
% |
| 2599 |
% \begin{macro}{\@@_parse_signed_date:w} |
| 2600 |
% To be called in the form \cs{@@_parse_positive_date:w}\meta{var}\meta{sign}\cs{q_mark}\break |
| 2601 |
% \meta{text}\texttt{-0-0}\cs{q_stop}. Parse \meta{text} (known to represent a non-circa date) into the supplied |
| 2602 |
% variable. \param{1} is the variable for the date and \param{2} is possibly \texttt{-}. |
| 2603 |
% |
| 2604 |
% There is a trick in the parsing: |
| 2605 |
% \begin{enumerate} |
| 2606 |
% \item If \meta{text} has the form \meta{year}\texttt{-}\meta{month}\texttt{-}\meta{day}, then parameters |
| 2607 |
% \param{3}, \param{4}, and \param{5} will be, respectively, \meta{year}, \meta{month}, and |
| 2608 |
% \meta{day}\texttt{-0-0}. Thus \param{5} will be evaulated by \pkg{pgfmath} to \meta{day}. |
| 2609 |
% \item If \meta{text} has the form \meta{year}\texttt{-}\meta{month}, then parameters \param{3}, \param{4}, and |
| 2610 |
% \param{5} will be, respectively, \meta{year}, \meta{month}, and \texttt{0-0}. Thus \param{5} will be |
| 2611 |
% evaulated by \pkg{pgfmath} to \(0\). |
| 2612 |
% \item If \meta{text} is simply \meta{year}, then parameters \param{3}, \param{4}, and \param{5} will be, |
| 2613 |
% respectively, \meta{year}, \texttt{0}, and \texttt{0}. |
| 2614 |
% \end{enumerate} |
| 2615 |
% \begin{macrocode} |
| 2616 |
\cs_new:Npn\@@_parse_signed_date:w #1#2\q_mark #3-#4-#5\q_stop |
| 2617 |
{ |
| 2618 |
\pgfmathtruncatemacro{\@@_parsed_year_pgf}{#2#3} |
| 2619 |
\pgfmathtruncatemacro{\@@_parsed_month_pgf}{#4} |
| 2620 |
\pgfmathtruncatemacro{\@@_parsed_day_pgf}{#5} |
| 2621 |
\@@_pgfmathsetbool:nn{\l_tmpa_bool}{ |
| 2622 |
or( |
| 2623 |
\@@_parsed_month_pgf < 1, |
| 2624 |
\@@_parsed_month_pgf > 12, |
| 2625 |
) |
| 2626 |
} |
| 2627 |
\bool_if:NTF\l_tmpa_bool |
| 2628 |
{ |
| 2629 |
% \end{macrocode} |
| 2630 |
% \textit{Case: no valid month is given.} Use only the year. |
| 2631 |
% \begin{macrocode} |
| 2632 |
\pgfmathsetmacro{#1}{#2#3} |
| 2633 |
} |
| 2634 |
{ |
| 2635 |
% \end{macrocode} |
| 2636 |
% \textit{Case: a valid month is given.} Get the number of days in the year, in the month, and in the year up to the |
| 2637 |
% month. Then check if the year is a leap year and, if so, make the appropriate adjustments. |
| 2638 |
% \begin{macrocode} |
| 2639 |
\cs_set_eq:NN\l_@@_year_days_pgf\c_@@_year_days_pgf |
| 2640 |
\cs_set_eq:Nc\l_@@_month_days_pgf |
| 2641 |
{ c_@@_month_days_\@@_parsed_month_pgf _pgf } |
| 2642 |
\cs_set_eq:Nc\l_@@_cumulative_days_pgf |
| 2643 |
{ c_@@_cumulative_days_\@@_parsed_month_pgf _pgf } |
| 2644 |
\@@_pgfmathsetbool:nn{\l_tmpa_bool}{ |
| 2645 |
or( |
| 2646 |
Mod(\@@_parsed_year_pgf,400) == 0, |
| 2647 |
and( |
| 2648 |
Mod(\@@_parsed_year_pgf,4) == 0, |
| 2649 |
Mod(\@@_parsed_year_pgf,100) != 0 |
| 2650 |
) |
| 2651 |
) |
| 2652 |
} |
| 2653 |
\bool_if:NT\l_tmpa_bool |
| 2654 |
{ |
| 2655 |
\pgfmathsetmacro{\l_@@_year_days_pgf} |
| 2656 |
{ \l_@@_year_days_pgf+1 } |
| 2657 |
\@@_pgfmathsetbool:nn{\l_tmpb_bool} |
| 2658 |
{ \@@_parsed_month == 1 } |
| 2659 |
\bool_if:NF\l_tmpb_bool |
| 2660 |
{ |
| 2661 |
\@@_pgfmathsetbool:nn{\l_tmpb_bool} |
| 2662 |
{ \@@_parsed_month == 2 } |
| 2663 |
\bool_if:NF\l_tmpb_bool |
| 2664 |
{ |
| 2665 |
\pgfmathsetmacro{\l_@@_month_days_pgf} |
| 2666 |
{ \l_@@_month_days_pgf + 1 } |
| 2667 |
} |
| 2668 |
{ |
| 2669 |
\pgfmathsetmacro{\l_@@_cumulative_days_pgf} |
| 2670 |
{ \l_@@_cumulative_days_pgf + 1 } |
| 2671 |
} |
| 2672 |
} |
| 2673 |
} |
| 2674 |
\@@_pgfmathsetbool:nn{\l_tmpa_bool}{ |
| 2675 |
or( |
| 2676 |
\@@_parsed_day_pgf < 1, |
| 2677 |
\@@_parsed_day_pgf > \l_@@_month_days_pgf, |
| 2678 |
) |
| 2679 |
} |
| 2680 |
\bool_if:NTF\l_tmpa_bool |
| 2681 |
{ |
| 2682 |
% \end{macrocode} |
| 2683 |
% \textit{Sub-case: no valid day is given.} Use only the year and month. |
| 2684 |
% \begin{macrocode} |
| 2685 |
\pgfmathsetmacro{#1} |
| 2686 |
{ |
| 2687 |
#2#3 |
| 2688 |
+ \l_@@_cumulative_days_pgf/\l_@@_year_days_pgf |
| 2689 |
} |
| 2690 |
} |
| 2691 |
{ |
| 2692 |
% \end{macrocode} |
| 2693 |
% \textit{Sub-case: a valid day is given.} Use the year, month, and day. |
| 2694 |
% \begin{macrocode} |
| 2695 |
\pgfmathsetmacro{#1} |
| 2696 |
{ |
| 2697 |
#2#3 |
| 2698 |
+ ( |
| 2699 |
\l_@@_cumulative_days_pgf |
| 2700 |
+ \@@_parsed_day_pgf |
| 2701 |
)/\l_@@_year_days_pgf |
| 2702 |
} |
| 2703 |
} |
| 2704 |
} |
| 2705 |
} |
| 2706 |
% \end{macrocode} |
| 2707 |
% \end{macro} |
| 2708 |
% |
| 2709 |
% |
| 2710 |
% |
| 2711 |
% \subsection{Interval drawing} |
| 2712 |
% |
| 2713 |
% \subsubsection{Preliminaries} |
| 2714 |
% |
| 2715 |
% \begin{macro}{ |
| 2716 |
% \l_@@_start_is_range_bool, |
| 2717 |
% \l_@@_interval_start_min_circa_bool, |
| 2718 |
% \l_@@_interval_start_max_circa_bool, |
| 2719 |
% \l_@@_finish_is_range_bool, |
| 2720 |
% \l_@@_interval_finish_min_circa_bool, |
| 2721 |
% \l_@@_interval_finish_max_circa_bool, |
| 2722 |
% } |
| 2723 |
% These boolean variables will be used to hold parsed data for the start and finish of an interval: whether it is a |
| 2724 |
% range, whether the beginning of that range is qualified by `circa', and whether the end of that range is qualified |
| 2725 |
% by `circa'. |
| 2726 |
% \begin{macrocode} |
| 2727 |
\bool_new:N\l_@@_start_is_range_bool |
| 2728 |
\bool_new:N\l_@@_interval_start_min_circa_bool |
| 2729 |
\bool_new:N\l_@@_interval_start_max_circa_bool |
| 2730 |
\bool_new:N\l_@@_finish_is_range_bool |
| 2731 |
\bool_new:N\l_@@_interval_finish_min_circa_bool |
| 2732 |
\bool_new:N\l_@@_interval_finish_max_circa_bool |
| 2733 |
% \end{macrocode} |
| 2734 |
% \end{macro} |
| 2735 |
% |
| 2736 |
% |
| 2737 |
% |
| 2738 |
% \subsubsection{Error message definition} |
| 2739 |
% |
| 2740 |
% \begin{macrocode} |
| 2741 |
\msg_new:nnn{timechart}{interval_dates_invalid} |
| 2742 |
{ Invalid~interval~dates:~#1~to~#2 } |
| 2743 |
% \end{macrocode} |
| 2744 |
% |
| 2745 |
% |
| 2746 |
% |
| 2747 |
% \subsubsection{Main macros} |
| 2748 |
% |
| 2749 |
% \begin{macro}{\@@_interval_user:Ommm} |
| 2750 |
% Draw an interval. This macro will be made available as \cs{timechartinterval} inside the \env{timechart} |
| 2751 |
% environment. It is simply a wrapper around the internal \cs{@@_interval:nnnn} macro. |
| 2752 |
% \begin{arguments} |
| 2753 |
% \item PGF keys under \key{/timechart/} to apply. |
| 2754 |
% \item Start year. |
| 2755 |
% \item Finish year. |
| 2756 |
% \item Label. |
| 2757 |
% \end{arguments} |
| 2758 |
% \begin{macrocode} |
| 2759 |
\NewDocumentCommand{\@@_interval_user:Ommm}{ O{} m m m } |
| 2760 |
{ |
| 2761 |
\@@_interval:nnnn{#1}{#2}{#3}{#4} |
| 2762 |
} |
| 2763 |
% \end{macrocode} |
| 2764 |
% \end{macro} |
| 2765 |
% |
| 2766 |
% \begin{macro}{\@@_interval:nnnn} |
| 2767 |
% Internal macro for drawing an interval. |
| 2768 |
% \begin{macrocode} |
| 2769 |
\cs_new:Npn \@@_interval:nnnn #1#2#3#4 |
| 2770 |
{ |
| 2771 |
\@@_debug:n{ |
| 2772 |
************************************************************ |
| 2773 |
} |
| 2774 |
\@@_debug:n{Interval~#2~to~#3~"#4"} |
| 2775 |
% \end{macrocode} |
| 2776 |
% Open an group and parse the start and finish dates or date ranges. |
| 2777 |
% \begin{macrocode} |
| 2778 |
\group_begin: |
| 2779 |
\@@_parse_date_or_daterange:NNNNNn |
| 2780 |
\l_@@_start_is_range_bool |
| 2781 |
\l_@@_interval_start_min_circa_bool |
| 2782 |
\l_@@_interval_start_min_year |
| 2783 |
\l_@@_interval_start_max_circa_bool |
| 2784 |
\l_@@_interval_start_max_year |
| 2785 |
{#2} |
| 2786 |
\@@_parse_date_or_daterange:NNNNNn |
| 2787 |
\l_@@_finish_is_range_bool |
| 2788 |
\l_@@_interval_finish_min_circa_bool |
| 2789 |
\l_@@_interval_finish_min_year |
| 2790 |
\l_@@_interval_finish_max_circa_bool |
| 2791 |
\l_@@_interval_finish_max_year |
| 2792 |
{#3} |
| 2793 |
% \end{macrocode} |
| 2794 |
% Check the results of parsing. |
| 2795 |
% \begin{macrocode} |
| 2796 |
\@@_pgfmathsetbool:nn{\l_tmpa_bool}{ |
| 2797 |
and( |
| 2798 |
\l_@@_interval_start_min_year |
| 2799 |
<= \l_@@_interval_start_max_year, |
| 2800 |
and( |
| 2801 |
\l_@@_interval_start_max_year |
| 2802 |
<= \l_@@_interval_finish_min_year, |
| 2803 |
\l_@@_interval_finish_min_year |
| 2804 |
<= \l_@@_interval_finish_max_year |
| 2805 |
) |
| 2806 |
) |
| 2807 |
} |
| 2808 |
% \end{macrocode} |
| 2809 |
% Proceed if and only if the results of parsing are valid, otherwise output an error message. In both cases, close the |
| 2810 |
% group and, in the former case, step the \(y\) coordinate if appropriate. |
| 2811 |
% \begin{macrocode} |
| 2812 |
\bool_if:NTF\l_tmpa_bool |
| 2813 |
{ |
| 2814 |
\@@_interval_checked:nn{#1}{#4} |
| 2815 |
\group_end: |
| 2816 |
\bool_if:NT\l_@@_autostep_bool |
| 2817 |
{ \@@_step_y_user:O } |
| 2818 |
} |
| 2819 |
{ |
| 2820 |
\msg_error:nnnn{timechart}{interval_dates_invalid}{#2}{#3} |
| 2821 |
\group_end: |
| 2822 |
} |
| 2823 |
} |
| 2824 |
% \end{macrocode} |
| 2825 |
% \end{macro} |
| 2826 |
% |
| 2827 |
% In \cs{@@_interval_user_aux:nnnn}, the start and finish dates were parsed and it has been checked that they satisfy |
| 2828 |
% \begin{align*} |
| 2829 |
% &\cs{l_@@_interval_start_min_year} \\ |
| 2830 |
% &\qquad\leq \cs{l_@@_interval_start_max_year} \\ |
| 2831 |
% &\qquad\qquad\leq \cs{l_@@_interval_finish_min_year} \\ |
| 2832 |
% &\qquad\qquad\qquad\leq \cs{l_@@_interval_finish_max_year}. |
| 2833 |
% \end{align*} |
| 2834 |
% In the code that follows, horizontal coordinates \cs[no-index]{l_@@_interval_..._x} will be computed from |
| 2835 |
% \cs[no-index]{l_@@_interval_..._year}. Subsequently, only the former variables will be used. |
| 2836 |
% |
| 2837 |
% |
| 2838 |
% |
| 2839 |
% |
| 2840 |
% \begin{macro}{\@@_interval_checked:nn} |
| 2841 |
% Draw an interval using the parsed and checked start and finish dates |
| 2842 |
% \begin{arguments} |
| 2843 |
% \item PGF keys under \key{/timechart/} to apply. |
| 2844 |
% \item Label. |
| 2845 |
% \end{arguments} |
| 2846 |
% \begin{macrocode} |
| 2847 |
\cs_new:Npn \@@_interval_checked:nn #1#2 |
| 2848 |
{ |
| 2849 |
% \end{macrocode} |
| 2850 |
% Process keys supplied locally and retrieve the only value needed at this stage. |
| 2851 |
% \begin{macrocode} |
| 2852 |
\pgfqkeys{/timechart}{ |
| 2853 |
#1, |
| 2854 |
circa~uncertainty/.get=\l_@@_circa_uncertainty_year |
| 2855 |
} |
| 2856 |
% \end{macrocode} |
| 2857 |
% Do the minimum amount of calculation necessary to check whether any part of interval is visible. This means |
| 2858 |
% calculating \cs{l_@@_interval_start_min_x} and \cs{l_@@_interval_finish_max_x} (including taking into account any |
| 2859 |
% `circa'). |
| 2860 |
% \begin{macrocode} |
| 2861 |
\bool_if:NTF\l_@@_interval_start_min_circa_bool |
| 2862 |
{ |
| 2863 |
\pgfmathsetmacro{\l_@@_interval_start_min_x} |
| 2864 |
{ yeartox(\l_@@_interval_start_min_year |
| 2865 |
- \l_@@_circa_uncertainty_year) } |
| 2866 |
} |
| 2867 |
{ |
| 2868 |
\pgfmathsetmacro{\l_@@_interval_start_min_x} |
| 2869 |
{ yeartox(\l_@@_interval_start_min_year) } |
| 2870 |
} |
| 2871 |
\bool_if:NTF\l_@@_interval_finish_max_circa_bool |
| 2872 |
{ |
| 2873 |
\pgfmathsetmacro{\l_@@_interval_finish_max_x} |
| 2874 |
{ yeartox(\l_@@_interval_finish_max_year |
| 2875 |
+ \l_@@_circa_uncertainty_year) } |
| 2876 |
} |
| 2877 |
{ |
| 2878 |
\pgfmathsetmacro{\l_@@_interval_finish_max_x} |
| 2879 |
{ yeartox(\l_@@_interval_finish_max_year) } |
| 2880 |
} |
| 2881 |
% \end{macrocode} |
| 2882 |
% Proceed if some part of the interval is visible. |
| 2883 |
% \begin{macrocode} |
| 2884 |
\@@_if_x_range_intersect_bounds:nnT |
| 2885 |
{\l_@@_interval_start_min_x} |
| 2886 |
{\l_@@_interval_finish_max_x} |
| 2887 |
{ \@@_draw_visible_interval:nn{#1}{#2} } |
| 2888 |
} |
| 2889 |
% \end{macrocode} |
| 2890 |
% \end{macro} |
| 2891 |
% |
| 2892 |
% \begin{macro}{\@@_start_beyond_bool,\@@_finish_beyond_bool} |
| 2893 |
% Boolean variables to indicate whether the interval extends beyond the chart at the start or the finish more than the |
| 2894 |
% specified tolerance. |
| 2895 |
% \begin{macrocode} |
| 2896 |
\bool_new:N\l_@@_interval_start_beyond_bool |
| 2897 |
\bool_new:N\l_@@_interval_finish_beyond_bool |
| 2898 |
% \end{macrocode} |
| 2899 |
% \end{macro} |
| 2900 |
% |
| 2901 |
% \begin{macro}{@@_draw_visible_interval:nn} |
| 2902 |
% Draw an interval of which some part is known to be visible. |
| 2903 |
% \begin{arguments} |
| 2904 |
% \item PGF keys |
| 2905 |
% \item Label |
| 2906 |
% \end{arguments} |
| 2907 |
% \begin{macrocode} |
| 2908 |
\cs_new:Npn\@@_draw_visible_interval:nn #1#2 |
| 2909 |
{ |
| 2910 |
% \end{macrocode} |
| 2911 |
% Retrieve PGF key values. |
| 2912 |
% \begin{macrocode} |
| 2913 |
\pgfqkeys{/timechart}{ |
| 2914 |
tolerance~start/.get=\l_@@_start_tolerance_pgf, |
| 2915 |
tolerance~finish/.get=\l_@@_finish_tolerance_pgf, |
| 2916 |
beyond~length~start/.get=\l_@@_start_beyond_length_pgf, |
| 2917 |
beyond~length~finish/.get=\l_@@_finish_beyond_length_pgf, |
| 2918 |
beyond~x~radius~start/.get=\l_@@_start_beyond_x_radius_pgf, |
| 2919 |
beyond~x~radius~finish/.get=\l_@@_finish_beyond_x_radius_pgf, |
| 2920 |
ref/.get=\l_@@_ref_text, |
| 2921 |
mark/.get=\l_@@_mark_text, |
| 2922 |
interval~minimum~width/.get=\l_@@_minimum_width_pgf, |
| 2923 |
interval~bar~color/.get=\l_@@_bar_color, |
| 2924 |
interval~bar~thickness/.get=\l_@@_bar_thickness_pgf, |
| 2925 |
interval~mark~color/.get=\l_@@_mark_color, |
| 2926 |
interval~label~baseline/.get=\l_@@_text_baseline_pgf, |
| 2927 |
interval~label~node~name/.get=\l_@@_interval_label_node_name, |
| 2928 |
} |
| 2929 |
% \end{macrocode} |
| 2930 |
% Calculate the start and finish tolerance and beyond indicator \(x\) coordinates. |
| 2931 |
% \begin{macrocode} |
| 2932 |
\pgfmathsetmacro{\l_@@_start_tolerance_x}{ |
| 2933 |
\l_@@_start_x-(\l_@@_start_tolerance_pgf) |
| 2934 |
} |
| 2935 |
\pgfmathsetmacro{\l_@@_finish_tolerance_x}{ |
| 2936 |
\l_@@_finish_x+(\l_@@_finish_tolerance_pgf) |
| 2937 |
} |
| 2938 |
\pgfmathsetmacro{\l_@@_start_beyond_x}{ |
| 2939 |
\l_@@_start_x-(\l_@@_start_beyond_length_pgf) |
| 2940 |
} |
| 2941 |
\pgfmathsetmacro{\l_@@_finish_beyond_x}{ |
| 2942 |
\l_@@_finish_x+(\l_@@_finish_beyond_length_pgf) |
| 2943 |
} |
| 2944 |
% \end{macrocode} |
| 2945 |
% Do the remaining calculations: calculate \cs{l_@@_interval_start_max_x} and \cs{l_@@_interval_finish_min_x} |
| 2946 |
% (including taking into account any `circa'). |
| 2947 |
% \begin{macrocode} |
| 2948 |
\pgfmathsetlengthmacro{\l_@@_bar_half_thickness_pgf} |
| 2949 |
{.5*\l_@@_bar_thickness_pgf} |
| 2950 |
\cs_set:Npn\l_@@_label_text{#2} |
| 2951 |
\bool_if:NTF\l_@@_interval_start_max_circa_bool |
| 2952 |
{ |
| 2953 |
\pgfmathsetmacro{\l_@@_interval_start_max_x} |
| 2954 |
{ yeartox(\l_@@_interval_start_max_year |
| 2955 |
+ \l_@@_circa_uncertainty_year) } |
| 2956 |
} |
| 2957 |
{ |
| 2958 |
\pgfmathsetmacro{\l_@@_interval_start_max_x} |
| 2959 |
{ yeartox(\l_@@_interval_start_max_year) } |
| 2960 |
} |
| 2961 |
\bool_if:NTF\l_@@_interval_finish_min_circa_bool |
| 2962 |
{ |
| 2963 |
\pgfmathsetmacro{\l_@@_interval_finish_min_x} |
| 2964 |
{ yeartox(\l_@@_interval_finish_min_year |
| 2965 |
- \l_@@_circa_uncertainty_year) } |
| 2966 |
} |
| 2967 |
{ |
| 2968 |
\pgfmathsetmacro{\l_@@_interval_finish_min_x} |
| 2969 |
{ yeartox(\l_@@_interval_finish_min_year) } |
| 2970 |
} |
| 2971 |
% \end{macrocode} |
| 2972 |
% It is possible that circa indicators have made \cs{l_@@_start_max_x} greater than \cs{l_@@_finish_min_x}. |
| 2973 |
% Check for this; if so, set them both to their average. |
| 2974 |
% \begin{macrocode} |
| 2975 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 2976 |
{ |
| 2977 |
\l_@@_interval_start_max_x |
| 2978 |
> \l_@@_interval_finish_min_x |
| 2979 |
} |
| 2980 |
\bool_if:NT\l_@@_tmpa_bool |
| 2981 |
{ |
| 2982 |
\pgfmathsetmacro{\l_@@_interval_start_max_x} |
| 2983 |
{ |
| 2984 |
.5*( |
| 2985 |
\l_@@_interval_start_max_x |
| 2986 |
+ \l_@@_interval_finish_min_x |
| 2987 |
) |
| 2988 |
} |
| 2989 |
\pgfmathsetmacro{\l_@@_interval_finish_min_x} |
| 2990 |
{ \l_@@_interval_start_max_x } |
| 2991 |
} |
| 2992 |
% \end{macrocode} |
| 2993 |
% Check whether the minimum width requirement is satisfied; if not, make an adjustment. |
| 2994 |
% \begin{macrocode} |
| 2995 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 2996 |
{ |
| 2997 |
(\l_@@_interval_finish_max_x |
| 2998 |
-\l_@@_interval_start_min_x) |
| 2999 |
> \l_@@_minimum_width_pgf |
| 3000 |
} |
| 3001 |
\bool_if:NF \l_@@_tmpa_bool |
| 3002 |
{ |
| 3003 |
\pgfmathsetmacro{\l_@@_width_adjust} |
| 3004 |
{ .5*\l_@@_minimum_width_pgf } |
| 3005 |
\pgfmathsetmacro{\l_@@_interval_start_max_x} |
| 3006 |
{ \l_@@_interval_start_max_x-\l_@@_width_adjust } |
| 3007 |
\pgfmathsetmacro{\l_@@_interval_finish_min_x} |
| 3008 |
{ \l_@@_interval_finish_min_x+\l_@@_width_adjust } |
| 3009 |
\pgfmathsetmacro{\l_@@_interval_start_min_x} |
| 3010 |
{ |
| 3011 |
min( |
| 3012 |
\l_@@_interval_start_min_x, |
| 3013 |
\l_@@_interval_start_max_x |
| 3014 |
) |
| 3015 |
} |
| 3016 |
\pgfmathsetmacro{\l_@@_interval_finish_max_x} |
| 3017 |
{ |
| 3018 |
max( |
| 3019 |
\l_@@_interval_finish_max_x, |
| 3020 |
\l_@@_interval_finish_min_x |
| 3021 |
) |
| 3022 |
} |
| 3023 |
} |
| 3024 |
\@@_debug:n{Calculated+adjusted~x~coords:} |
| 3025 |
\@@_debug:n{~ |
| 3026 |
\l_@@_interval_start_min_x/\l_@@_interval_start_max_x~ |
| 3027 |
to~ |
| 3028 |
\l_@@_interval_finish_min_x/\l_@@_interval_finish_max_x |
| 3029 |
} |
| 3030 |
% \end{macrocode} |
| 3031 |
% At this point, the \(x\)-coordinates of the interval have been established. First, decide whether the interval |
| 3032 |
% exceeds the chart by more than the tolerance at the start and the finish. If so, set the appropriate clipping path |
| 3033 |
% (this may be changed again later). |
| 3034 |
% \begin{macrocode} |
| 3035 |
\@@_pgfmathsetbool:nn{\l_@@_interval_start_beyond_bool} |
| 3036 |
{\l_@@_interval_start_min_x<=\l_@@_start_tolerance_x} |
| 3037 |
\bool_if:NT\l_@@_interval_start_beyond_bool |
| 3038 |
{ |
| 3039 |
\cs_set_eq:NN |
| 3040 |
\@@_interval_start_clip_path: |
| 3041 |
\@@_interval_start_clip_path_beyond: |
| 3042 |
} |
| 3043 |
\@@_pgfmathsetbool:nn{\l_@@_interval_finish_beyond_bool} |
| 3044 |
{\l_@@_interval_finish_max_x>=\l_@@_finish_tolerance_x} |
| 3045 |
\bool_if:NT\l_@@_interval_finish_beyond_bool |
| 3046 |
{ |
| 3047 |
\cs_set_eq:NN |
| 3048 |
\@@_interval_finish_clip_path: |
| 3049 |
\@@_interval_finish_clip_path_beyond: |
| 3050 |
} |
| 3051 |
% \end{macrocode} |
| 3052 |
% Compute how the interval will be drawn. There are three components: |
| 3053 |
% \begin{itemize} |
| 3054 |
% \item the \emph{startrange}, comprising the part between \cs{l_@@_interval_start_min_x} to |
| 3055 |
% \cs{l_@@_interval_start_max_x}; |
| 3056 |
% \item the definite part: \cs{l_@@_interval_start_max_x} to \cs{l_@@_interval_finish_min_x}; |
| 3057 |
% \item the \emph{finishrange}: \cs{l_@@_interval_finish_min_x} to \cs{l_@@_interval_finish_max_x}. |
| 3058 |
% \end{itemize} |
| 3059 |
% It is necessary to decide which of these will be drawn. The logic is complicated because any part may lie outside |
| 3060 |
% the timechart or be involved in the beyond indicator. Further, clipping is used for a `slant' startrange or |
| 3061 |
% finishrange and for beyond indicators. |
| 3062 |
% |
| 3063 |
% First of all, consider the definite part. Depending on where this is located, it may be unnecessary to compute or |
| 3064 |
% draw the startrange or finishrange, so some of the following macros may be set to do nothing. |
| 3065 |
% \begin{macrocode} |
| 3066 |
\@@_interval_definite_compute: |
| 3067 |
\@@_interval_startrange_compute: |
| 3068 |
\@@_interval_finishrange_compute: |
| 3069 |
% \end{macrocode} |
| 3070 |
% All the data needed to draw the interval are now ready. Shift to the correct vertical coordinate and open a scope for |
| 3071 |
% drawing. |
| 3072 |
% \begin{macrocode} |
| 3073 |
\pgftransformshift{ \pgfpoint{0}{\l_@@_current_y} } |
| 3074 |
\pgfscope |
| 3075 |
% \end{macrocode} |
| 3076 |
% First, do the computed clipping, for a slant startrange and/or a slant finishrange, or beyond indicators. Then draw |
| 3077 |
% the startrange, finish range, and then the `solid' part, which may be only the definite part or may include a slant |
| 3078 |
% startrange or a slant finishrange. Finally, define the node for the bar, then do the labelling. |
| 3079 |
% \begin{macrocode} |
| 3080 |
\@@_interval_clip: |
| 3081 |
\@@_interval_startrange_draw: |
| 3082 |
\@@_interval_finishrange_draw: |
| 3083 |
\@@_interval_solid_draw: |
| 3084 |
\@@_interval_mark: |
| 3085 |
\@@_interval_define_bar_node: |
| 3086 |
\endpgfscope |
| 3087 |
\@@_interval_label: |
| 3088 |
} |
| 3089 |
% \end{macrocode} |
| 3090 |
% \end{macro} |
| 3091 |
% |
| 3092 |
% |
| 3093 |
% |
| 3094 |
% \subsubsection{Computation} |
| 3095 |
% |
| 3096 |
% These macros determine precisely what is to be drawn. The aim is to minimize the number of drawing commands by |
| 3097 |
% avoiding drawing where areas that would be clipped. |
| 3098 |
% |
| 3099 |
% |
| 3100 |
% |
| 3101 |
% \paragraph{Definite part of the interval} |
| 3102 |
% |
| 3103 |
% \begin{macro}{\@@_interval_definite_compute:} |
| 3104 |
% Compute whether and where to draw the definite part of the interval. Two auxiliary macros, |
| 3105 |
% \cs{@@_interval_definite_compute_ii:} and \cs{@@_interval_definite_compute_ii:} are used, simply to avoid deep |
| 3106 |
% nesting of code. |
| 3107 |
% |
| 3108 |
% First, check whether the entire definite part of the interval is located to the left of the start of the chart and |
| 3109 |
% that the interval does exceed the start tolerance. In this case, the only thing that might be drawn to appear to the |
| 3110 |
% left of the start will be the excess indicator drawn as part of the finish range, so there is no need to draw the |
| 3111 |
% definite part or do anything for the start range. |
| 3112 |
% \begin{macrocode} |
| 3113 |
\cs_new:Npn\@@_interval_definite_compute: |
| 3114 |
{ |
| 3115 |
\@@_debug:n{Computing:~definite~part} |
| 3116 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3117 |
{ \l_@@_interval_finish_min_x < \l_@@_start_x } |
| 3118 |
\bool_if:nTF{ |
| 3119 |
\l_@@_tmpa_bool && \l_@@_interval_start_beyond_bool |
| 3120 |
} |
| 3121 |
{ |
| 3122 |
\cs_set_eq:NN |
| 3123 |
\@@_interval_solid_draw:\prg_do_nothing: |
| 3124 |
\cs_set_eq:NN |
| 3125 |
\@@_interval_startrange_compute:\prg_do_nothing: |
| 3126 |
\cs_set_eq:NN |
| 3127 |
\@@_interval_startrange_draw:\prg_do_nothing: |
| 3128 |
} |
| 3129 |
{ |
| 3130 |
\@@_interval_definite_compute_ii: |
| 3131 |
} |
| 3132 |
} |
| 3133 |
% \end{macrocode} |
| 3134 |
% Second, check whether the entire definite part of the interval is located to the right of the finish of the chart |
| 3135 |
% and that the interval does exceed the finish tolerance. In this case, the only thing that might be drawn to appear |
| 3136 |
% to the right of the finish will be the excess indicator drawn as part of the start range, so there is no need to |
| 3137 |
% draw the definite part or do anything for the finish range. |
| 3138 |
% \begin{macrocode} |
| 3139 |
\cs_new:Npn\@@_interval_definite_compute_ii: |
| 3140 |
{ |
| 3141 |
\@@_debug:n{~(Stage~II)} |
| 3142 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3143 |
{ \l_@@_interval_start_max_x > \l_@@_finish_x } |
| 3144 |
\bool_if:nTF{ |
| 3145 |
\l_@@_tmpa_bool && \l_@@_interval_finish_beyond_bool |
| 3146 |
} |
| 3147 |
{ |
| 3148 |
\cs_set_eq:NN |
| 3149 |
\@@_interval_solid_draw:\prg_do_nothing: |
| 3150 |
\cs_set_eq:NN |
| 3151 |
\@@_interval_finishrange_compute:\prg_do_nothing: |
| 3152 |
\cs_set_eq:NN |
| 3153 |
\@@_interval_finishrange_draw:\prg_do_nothing: |
| 3154 |
} |
| 3155 |
{ |
| 3156 |
\@@_interval_definite_compute_iii: |
| 3157 |
} |
| 3158 |
} |
| 3159 |
% \end{macrocode} |
| 3160 |
% At this point, some part of the definite part of the interval has to be drawn. |
| 3161 |
% \begin{macrocode} |
| 3162 |
\cs_new:Npn\@@_interval_definite_compute_iii: |
| 3163 |
{ |
| 3164 |
\@@_debug:n{~(Stage~III)} |
| 3165 |
% \end{macrocode} |
| 3166 |
% If the start of the definite part of the interval is at or to the left of the start of the chart and the interval |
| 3167 |
% exceeds the start tolerance, set the start of the solid part to the position of the start excess indicator. In this |
| 3168 |
% case, nothing needs to be done for the start range. Otherwise, set the start of the solid part to the start of the |
| 3169 |
% definite part. |
| 3170 |
% \begin{macrocode} |
| 3171 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3172 |
{ \l_@@_interval_start_max_x <= \l_@@_start_x } |
| 3173 |
\bool_if:nTF{ |
| 3174 |
\l_@@_tmpa_bool && \l_@@_interval_start_beyond_bool |
| 3175 |
} |
| 3176 |
{ |
| 3177 |
\cs_set_eq:NN |
| 3178 |
\l_@@_interval_solid_start_x\l_@@_start_beyond_x |
| 3179 |
\cs_set_eq:NN |
| 3180 |
\@@_interval_startrange_compute:\prg_do_nothing: |
| 3181 |
\cs_set_eq:NN |
| 3182 |
\@@_interval_startrange_draw:\prg_do_nothing: |
| 3183 |
} |
| 3184 |
{ |
| 3185 |
\cs_set_eq:NN |
| 3186 |
\l_@@_interval_solid_start_x |
| 3187 |
\l_@@_interval_start_max_x |
| 3188 |
} |
| 3189 |
% \end{macrocode} |
| 3190 |
% If the finish of the definite part of the interval is at or to the right of the finish of the chart and the interval |
| 3191 |
% exceeds the finish tolerance, set the finsih of the solid part to the position of the finish excess indicator. In |
| 3192 |
% this case, nothing needs to be done for the start range. Otherwise, set the start of the solid part to the start of |
| 3193 |
% the definite part. |
| 3194 |
% \begin{macrocode} |
| 3195 |
\@@_pgfmathsetbool:nn{\l_@@_tmpb_bool} |
| 3196 |
{ \l_@@_interval_finish_min_x >= \l_@@_finish_x } |
| 3197 |
\bool_if:nTF{ |
| 3198 |
\l_@@_tmpb_bool && \l_@@_interval_finish_beyond_bool |
| 3199 |
} |
| 3200 |
{ |
| 3201 |
\cs_set_eq:NN |
| 3202 |
\l_@@_interval_solid_finish_x\l_@@_finish_beyond_x |
| 3203 |
\cs_set_eq:NN |
| 3204 |
\@@_interval_finishrange_compute:\prg_do_nothing: |
| 3205 |
\cs_set_eq:NN |
| 3206 |
\@@_interval_finishrange_draw:\prg_do_nothing: |
| 3207 |
} |
| 3208 |
{ |
| 3209 |
\cs_set_eq:NN |
| 3210 |
\l_@@_interval_solid_finish_x |
| 3211 |
\l_@@_interval_finish_min_x |
| 3212 |
} |
| 3213 |
} |
| 3214 |
% \end{macrocode} |
| 3215 |
% \end{macro} |
| 3216 |
% |
| 3217 |
% |
| 3218 |
% |
| 3219 |
% \paragraph{Startrange} |
| 3220 |
% |
| 3221 |
% \begin{macro}{\@@_interval_startrange_compute:} |
| 3222 |
% Compute how to draw the startrange of an interval. This macro will only be called if it is necessary to draw some |
| 3223 |
% part of the startrange. |
| 3224 |
% \begin{macrocode} |
| 3225 |
\cs_new:Npn\@@_interval_startrange_compute: |
| 3226 |
{ |
| 3227 |
\@@_debug:n{Computing:~startrange} |
| 3228 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3229 |
{ |
| 3230 |
\l_@@_interval_start_min_x |
| 3231 |
== \l_@@_interval_start_max_x |
| 3232 |
} |
| 3233 |
\bool_if:NTF\l_@@_tmpa_bool |
| 3234 |
{ |
| 3235 |
\cs_set_eq:NN\@@_interval_startrange_draw:\prg_do_nothing: |
| 3236 |
} |
| 3237 |
{ |
| 3238 |
\@@_interval_startrange_compute_ii: |
| 3239 |
} |
| 3240 |
} |
| 3241 |
% \end{macrocode} |
| 3242 |
% \end{macro} |
| 3243 |
% |
| 3244 |
% |
| 3245 |
% \begin{macro}{\@@_interval_startrange_compute_ii:} |
| 3246 |
% Compute how to draw the startrange of an interval. This macro will only be called if the start range is non-empty. |
| 3247 |
% \begin{macrocode} |
| 3248 |
\bool_new:N\l_@@_interval_startrange_finish_beyond_bool |
| 3249 |
\cs_new:Npn\@@_interval_startrange_compute_ii: |
| 3250 |
{ |
| 3251 |
\@@_debug:n{~(Stage~II)} |
| 3252 |
% \end{macrocode} |
| 3253 |
% First, if the interval extends beyond the start tolerance then (since some part of the startrange) is visible, the |
| 3254 |
% start excess indicator forms part of the range. In this case, the drawn range starts at the start of the timechart and the |
| 3255 |
% start excess indicator mirrors this `level' of the range. Otherwise the drawn range starts at the extreme start of the |
| 3256 |
% interval at `level' \(0\) and a start excess indicator is not drawn. |
| 3257 |
% \begin{macrocode} |
| 3258 |
\bool_if:NTF\l_@@_interval_start_beyond_bool |
| 3259 |
{ |
| 3260 |
\cs_set_eq:NN |
| 3261 |
\l_@@_interval_startrange_start_x\l_@@_start_x |
| 3262 |
\pgfmathsetmacro{\l_@@_interval_startrange_start_level_pgf} |
| 3263 |
{ |
| 3264 |
(\l_@@_interval_startrange_start_x |
| 3265 |
-\l_@@_interval_start_min_x) |
| 3266 |
/ |
| 3267 |
(\l_@@_interval_start_max_x |
| 3268 |
-\l_@@_interval_start_min_x) |
| 3269 |
} |
| 3270 |
} |
| 3271 |
{ |
| 3272 |
\cs_set_eq:NN |
| 3273 |
\l_@@_interval_startrange_start_x |
| 3274 |
\l_@@_interval_start_min_x |
| 3275 |
\pgfmathsetmacro |
| 3276 |
{\l_@@_interval_startrange_start_level_pgf}{0} |
| 3277 |
} |
| 3278 |
% \end{macrocode} |
| 3279 |
% Second, if the interval extends beyond the finish tolerance and the start of the definite part of the interval is to |
| 3280 |
% the right of the finish of the timechart, the finish excess indicator forms part of the range. In this case, the |
| 3281 |
% drawn range finishes at the finish of the timechart and the excess indicator mirrors this `level' of the range. |
| 3282 |
% Otherwise the drawn range finishes at the extreme finish of the interval at `level' \(0\) and a finish excess |
| 3283 |
% indicator is not drawn. |
| 3284 |
% \begin{macrocode} |
| 3285 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3286 |
{ \l_@@_interval_start_max_x > \l_@@_finish_x } |
| 3287 |
\bool_set:Nn\l_@@_interval_startrange_finish_beyond_bool |
| 3288 |
{ |
| 3289 |
\l_@@_tmpa_bool |
| 3290 |
&& \l_@@_interval_finish_beyond_bool |
| 3291 |
} |
| 3292 |
\bool_if:NTF\l_@@_interval_startrange_finish_beyond_bool |
| 3293 |
{ |
| 3294 |
\cs_set_eq:NN |
| 3295 |
\l_@@_interval_startrange_finish_x |
| 3296 |
\l_@@_finish_x |
| 3297 |
\pgfmathsetmacro{\l_@@_interval_startrange_finish_level_pgf} |
| 3298 |
{ |
| 3299 |
(\l_@@_interval_startrange_finish_x |
| 3300 |
-\l_@@_interval_start_min_x) |
| 3301 |
/ |
| 3302 |
(\l_@@_interval_start_max_x |
| 3303 |
-\l_@@_interval_start_min_x) |
| 3304 |
} |
| 3305 |
} |
| 3306 |
{ |
| 3307 |
\cs_set_eq:NN |
| 3308 |
\l_@@_interval_startrange_finish_x |
| 3309 |
\l_@@_interval_start_max_x |
| 3310 |
\pgfmathsetmacro |
| 3311 |
{\l_@@_interval_startrange_finish_level_pgf}{1} |
| 3312 |
} |
| 3313 |
\int_case:nn {\l_@@_start_range_type_int} |
| 3314 |
{ |
| 3315 |
{0}{ |
| 3316 |
\cs_set_eq:NN |
| 3317 |
\@@_interval_startrange_draw: |
| 3318 |
\@@_interval_startrange_draw_pseudofade: |
| 3319 |
} |
| 3320 |
{1}{ |
| 3321 |
\@@_interval_startrange_slant_compute: |
| 3322 |
} |
| 3323 |
} |
| 3324 |
} |
| 3325 |
% \end{macrocode} |
| 3326 |
% \end{macro} |
| 3327 |
% |
| 3328 |
% \begin{macro}{\@@_interval_startrange_slant_compute:} |
| 3329 |
% Compute the clipping and drawing necessary for a slant startrange. |
| 3330 |
% \begin{macrocode} |
| 3331 |
\cs_new:Npn \@@_interval_startrange_slant_compute: |
| 3332 |
{ |
| 3333 |
\@@_debug:n{~(Startrange~slant)} |
| 3334 |
\bool_if:NTF\l_@@_interval_start_beyond_bool |
| 3335 |
{ |
| 3336 |
\bool_if:NTF\l_@@_interval_startrange_finish_beyond_bool |
| 3337 |
{ |
| 3338 |
\cs_set_eq:NN |
| 3339 |
\@@_interval_both_clip_path: |
| 3340 |
\@@_interval_startrange_clip_path_beyond_both: |
| 3341 |
} |
| 3342 |
{ |
| 3343 |
\cs_set_eq:NN |
| 3344 |
\@@_interval_start_clip_path: |
| 3345 |
\@@_interval_startrange_clip_path_beyond_start: |
| 3346 |
} |
| 3347 |
} |
| 3348 |
{ |
| 3349 |
\bool_if:NTF\l_@@_interval_startrange_finish_beyond_bool |
| 3350 |
{ |
| 3351 |
\cs_set_eq:NN |
| 3352 |
\@@_interval_both_clip_path: |
| 3353 |
\@@_interval_startrange_clip_path_beyond_finish: |
| 3354 |
} |
| 3355 |
{ |
| 3356 |
\cs_set_eq:NN |
| 3357 |
\@@_interval_start_clip_path: |
| 3358 |
\@@_interval_startrange_clip_path_start: |
| 3359 |
} |
| 3360 |
} |
| 3361 |
\cs_if_eq:NNTF\@@_interval_solid_draw:\prg_do_nothing: |
| 3362 |
{ |
| 3363 |
\cs_set_eq:NN |
| 3364 |
\@@_interval_startrange_draw: |
| 3365 |
\@@_interval_startfinishrange_draw_slant: |
| 3366 |
} |
| 3367 |
{ |
| 3368 |
\cs_set_eq:NN |
| 3369 |
\l_@@_interval_solid_start_x |
| 3370 |
\l_@@_start_beyond_x |
| 3371 |
\cs_set_eq:NN |
| 3372 |
\@@_interval_startrange_draw: |
| 3373 |
\prg_do_nothing: |
| 3374 |
} |
| 3375 |
} |
| 3376 |
% \end{macrocode} |
| 3377 |
% \end{macro} |
| 3378 |
% |
| 3379 |
% |
| 3380 |
% |
| 3381 |
% \paragraph{Finishrange} |
| 3382 |
% |
| 3383 |
% \begin{macro}{\@@_interval_finishrange_compute:} |
| 3384 |
% Compute how to draw the finishrange of an interval. This macro will only be called if it is necessary to draw some |
| 3385 |
% part of the finishrange. |
| 3386 |
% \begin{macrocode} |
| 3387 |
\cs_new:Npn\@@_interval_finishrange_compute: |
| 3388 |
{ |
| 3389 |
\@@_debug:n{Computing:~finishrange} |
| 3390 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3391 |
{ |
| 3392 |
\l_@@_interval_finish_max_x |
| 3393 |
== \l_@@_interval_finish_min_x |
| 3394 |
} |
| 3395 |
\bool_if:NTF\l_@@_tmpa_bool |
| 3396 |
{ |
| 3397 |
\cs_set_eq:NN\@@_interval_finishrange_draw:\prg_do_nothing: |
| 3398 |
} |
| 3399 |
{ |
| 3400 |
\@@_interval_finishrange_compute_ii: |
| 3401 |
} |
| 3402 |
} |
| 3403 |
% \end{macrocode} |
| 3404 |
% \end{macro} |
| 3405 |
% |
| 3406 |
% |
| 3407 |
% \begin{macro}{\@@_interval_finishrange_compute_ii:} |
| 3408 |
% Compute how to draw the finishrange of an interval. This macro will only be called if the finishrange is non-empty. |
| 3409 |
% \begin{macrocode} |
| 3410 |
\bool_new:N\l_@@_interval_finishrange_start_beyond_bool |
| 3411 |
\cs_new:Npn\@@_interval_finishrange_compute_ii: |
| 3412 |
{ |
| 3413 |
\@@_debug:n{~(Stage~II)} |
| 3414 |
% \end{macrocode} |
| 3415 |
% First, if the interval extends beyond the finish tolerance then (since some part of the finishrange) is visible, the |
| 3416 |
% finish excess indicator forms part of the range. In this case, the drawn range finishs at the finish of the |
| 3417 |
% timechart and the finish excess indicator mirrors this `level' of the range. Otherwise the drawn range finishs at |
| 3418 |
% the extreme finish of the interval at `level' \(0\) and a finish excess indicator is not drawn. |
| 3419 |
% \begin{macrocode} |
| 3420 |
\bool_if:NTF\l_@@_interval_finish_beyond_bool |
| 3421 |
{ |
| 3422 |
\cs_set_eq:NN |
| 3423 |
\l_@@_interval_finishrange_finish_x |
| 3424 |
\l_@@_finish_x |
| 3425 |
\pgfmathsetmacro{\l_@@_interval_finishrange_finish_level_pgf} |
| 3426 |
{ |
| 3427 |
(\l_@@_interval_finishrange_finish_x |
| 3428 |
-\l_@@_interval_finish_max_x) |
| 3429 |
/ |
| 3430 |
(\l_@@_interval_finish_min_x |
| 3431 |
-\l_@@_interval_finish_max_x) |
| 3432 |
} |
| 3433 |
} |
| 3434 |
{ |
| 3435 |
\cs_set_eq:NN |
| 3436 |
\l_@@_interval_finishrange_finish_x |
| 3437 |
\l_@@_interval_finish_max_x |
| 3438 |
\pgfmathsetmacro |
| 3439 |
{\l_@@_interval_finishrange_finish_level_pgf}{0} |
| 3440 |
} |
| 3441 |
|
| 3442 |
% \end{macrocode} |
| 3443 |
% Second, if the interval extends beyond the start tolerance and the finish of the definite part of the interval is to |
| 3444 |
% the left of the start of the timechart, the start excess indicator forms part of the range. In this case, the |
| 3445 |
% drawn range starts at the start of the timechart and the excess indicator mirrors this `level' of the range. |
| 3446 |
% Otherwise the drawn range starts at the extreme start of the interval at `level' \(0\) and a start excess |
| 3447 |
% indicator is not drawn. |
| 3448 |
% \begin{macrocode} |
| 3449 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 3450 |
{ \l_@@_interval_finish_min_x < \l_@@_start_x } |
| 3451 |
\bool_set:Nn\l_@@_interval_finishrange_start_beyond_bool |
| 3452 |
{ |
| 3453 |
\l_@@_tmpa_bool |
| 3454 |
&& \l_@@_interval_start_beyond_bool |
| 3455 |
} |
| 3456 |
\bool_if:NTF\l_@@_interval_finishrange_start_beyond_bool |
| 3457 |
{ |
| 3458 |
\cs_set_eq:NN |
| 3459 |
\l_@@_interval_finishrange_start_x |
| 3460 |
\l_@@_start_x |
| 3461 |
\pgfmathsetmacro{\l_@@_interval_finishrange_start_level_pgf} |
| 3462 |
{ |
| 3463 |
(\l_@@_interval_finishrange_start_x |
| 3464 |
-\l_@@_interval_finish_max_x) |
| 3465 |
/ |
| 3466 |
(\l_@@_interval_finish_min_x |
| 3467 |
-\l_@@_interval_finish_max_x) |
| 3468 |
} |
| 3469 |
} |
| 3470 |
{ |
| 3471 |
\cs_set_eq:NN |
| 3472 |
\l_@@_interval_finishrange_start_x |
| 3473 |
\l_@@_interval_finish_min_x |
| 3474 |
\pgfmathsetmacro |
| 3475 |
{\l_@@_interval_finishrange_start_level_pgf}{1} |
| 3476 |
} |
| 3477 |
\int_case:nn {\l_@@_finish_range_type_int} |
| 3478 |
{ |
| 3479 |
{0}{ |
| 3480 |
\cs_set_eq:NN |
| 3481 |
\@@_interval_finishrange_draw: |
| 3482 |
\@@_interval_finishrange_draw_pseudofade: |
| 3483 |
} |
| 3484 |
{1}{ |
| 3485 |
\@@_interval_finishrange_slant_compute: |
| 3486 |
} |
| 3487 |
} |
| 3488 |
} |
| 3489 |
% \end{macrocode} |
| 3490 |
% \end{macro} |
| 3491 |
% |
| 3492 |
% \begin{macro}{\@@_interval_finishrange_slant_compute:} |
| 3493 |
% Compute the clipping and drawing necessary for a slant finishrange. |
| 3494 |
% \begin{macrocode} |
| 3495 |
\cs_new:Npn \@@_interval_finishrange_slant_compute: |
| 3496 |
{ |
| 3497 |
\@@_debug:n{~(Finishrange~slant)} |
| 3498 |
\bool_if:NTF\l_@@_interval_finish_beyond_bool |
| 3499 |
{ |
| 3500 |
\bool_if:NTF\l_@@_interval_finishrange_start_beyond_bool |
| 3501 |
{ |
| 3502 |
\cs_set_eq:NN |
| 3503 |
\@@_interval_both_clip_path: |
| 3504 |
\@@_interval_finishrange_clip_path_beyond_both: |
| 3505 |
} |
| 3506 |
{ |
| 3507 |
\cs_set_eq:NN |
| 3508 |
\@@_interval_finish_clip_path: |
| 3509 |
\@@_interval_finishrange_clip_path_beyond_finish: |
| 3510 |
} |
| 3511 |
} |
| 3512 |
{ |
| 3513 |
\bool_if:NTF\l_@@_interval_finishrange_start_beyond_bool |
| 3514 |
{ |
| 3515 |
\cs_set_eq:NN |
| 3516 |
\@@_interval_both_clip_path: |
| 3517 |
\@@_interval_finishrange_clip_path_beyond_start: |
| 3518 |
} |
| 3519 |
{ |
| 3520 |
\cs_set_eq:NN |
| 3521 |
\@@_interval_finish_clip_path: |
| 3522 |
\@@_interval_finishrange_clip_path_finish: |
| 3523 |
} |
| 3524 |
} |
| 3525 |
\cs_if_eq:NNTF\@@_interval_solid_draw:\prg_do_nothing: |
| 3526 |
{ |
| 3527 |
\cs_set_eq:NN |
| 3528 |
\@@_interval_finishrange_draw: |
| 3529 |
\@@_interval_startfinishrange_draw_slant: |
| 3530 |
} |
| 3531 |
{ |
| 3532 |
\cs_set_eq:NN |
| 3533 |
\l_@@_interval_solid_finish_x |
| 3534 |
\l_@@_finish_beyond_x |
| 3535 |
\cs_set_eq:NN |
| 3536 |
\@@_interval_finishrange_draw: |
| 3537 |
\prg_do_nothing: |
| 3538 |
} |
| 3539 |
} |
| 3540 |
% \end{macrocode} |
| 3541 |
% \end{macro} |
| 3542 |
% |
| 3543 |
% |
| 3544 |
% |
| 3545 |
% \subsubsection{Drawing} |
| 3546 |
% |
| 3547 |
% |
| 3548 |
% |
| 3549 |
% \paragraph{Solid} |
| 3550 |
% |
| 3551 |
% \begin{macro}{\@@_interval_solid_draw:} |
| 3552 |
% Draw the solid part of an interval. |
| 3553 |
% \begin{macrocode} |
| 3554 |
\cs_new:Npn\@@_interval_solid_draw: |
| 3555 |
{ |
| 3556 |
\@@_debug:n{ |
| 3557 |
Drawing:~solid~\l_@@_interval_solid_start_x~ |
| 3558 |
to~\l_@@_interval_solid_finish_x |
| 3559 |
} |
| 3560 |
\pgfpathrectanglecorners{ |
| 3561 |
\pgfpoint |
| 3562 |
{\l_@@_interval_solid_start_x} |
| 3563 |
{-\l_@@_bar_half_thickness_pgf} |
| 3564 |
}{ |
| 3565 |
\pgfpoint |
| 3566 |
{\l_@@_interval_solid_finish_x} |
| 3567 |
{\l_@@_bar_half_thickness_pgf} |
| 3568 |
} |
| 3569 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3570 |
\pgfusepath{fill} |
| 3571 |
} |
| 3572 |
% \end{macrocode} |
| 3573 |
% \end{macro} |
| 3574 |
% |
| 3575 |
% |
| 3576 |
% |
| 3577 |
% \paragraph{Start/finish range pseudofade} |
| 3578 |
% |
| 3579 |
% \begin{macro}{\@@_interval_startrange_draw_pseudofade:} |
| 3580 |
% Draw a fading startrange and beyond indicators |
| 3581 |
% \begin{macrocode} |
| 3582 |
\cs_new:Npn\@@_interval_startrange_draw_pseudofade: |
| 3583 |
{ |
| 3584 |
\@@_debug:n{Drawing:~startrange,~pseudofade} |
| 3585 |
\@@_debug:n{~ |
| 3586 |
\l_@@_interval_startrange_start_x~ |
| 3587 |
(\l_@@_interval_startrange_start_level_pgf)~ |
| 3588 |
to~\l_@@_interval_startrange_finish_x~ |
| 3589 |
(\l_@@_interval_startrange_finish_level_pgf) |
| 3590 |
} |
| 3591 |
\@@_interval_draw_pseudofade:nnnnn |
| 3592 |
{\l_@@_interval_startrange_start_x} |
| 3593 |
{\l_@@_interval_startrange_finish_x} |
| 3594 |
{\l_@@_bar_color} |
| 3595 |
{\l_@@_interval_startrange_start_level_pgf} |
| 3596 |
{\l_@@_interval_startrange_finish_level_pgf} |
| 3597 |
\bool_if:NT\l_@@_interval_start_beyond_bool |
| 3598 |
{ \@@_interval_startrange_start_beyond_draw_fade: } |
| 3599 |
\bool_if:NT\l_@@_interval_startrange_finish_beyond_bool |
| 3600 |
{ \@@_interval_startrange_finish_beyond_draw_fade: } |
| 3601 |
} |
| 3602 |
% \end{macrocode} |
| 3603 |
% \end{macro} |
| 3604 |
% |
| 3605 |
% \begin{macro}{\@@_interval_startrange_start_beyond_draw_fade:} |
| 3606 |
% Draw a `faded' beyond indicator for a startrange that extends beyond the timechart start. |
| 3607 |
% \begin{macrocode} |
| 3608 |
\cs_new:Npn\@@_interval_startrange_start_beyond_draw_fade: |
| 3609 |
{ |
| 3610 |
\@@_debug:n{Drawing:~startrange,~pseudofade~beyond~start} |
| 3611 |
\@@_debug:n{~ |
| 3612 |
\l_@@_start_beyond_x~to~\l_@@_start_x |
| 3613 |
} |
| 3614 |
\pgfscope |
| 3615 |
\pgfpathrectanglecorners{ |
| 3616 |
\pgfpoint |
| 3617 |
{\l_@@_start_beyond_x} |
| 3618 |
{-\l_@@_bar_half_thickness_pgf} |
| 3619 |
}{ |
| 3620 |
\pgfpoint |
| 3621 |
{\l_@@_start_x} |
| 3622 |
{\l_@@_bar_half_thickness_pgf} |
| 3623 |
} |
| 3624 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3625 |
\pgfsetfillopacity |
| 3626 |
{\l_@@_interval_startrange_start_level_pgf} |
| 3627 |
\pgfusepath{fill} |
| 3628 |
\endpgfscope |
| 3629 |
} |
| 3630 |
% \end{macrocode} |
| 3631 |
% \end{macro} |
| 3632 |
% |
| 3633 |
% \begin{macro}{\@@_interval_startrange_finish_beyond_draw_fade:} |
| 3634 |
% Draw a `faded' beyond indicator for a startrange that extends beyond the timechart finish. |
| 3635 |
% \begin{macrocode} |
| 3636 |
\cs_new:Npn\@@_interval_startrange_finish_beyond_draw_fade: |
| 3637 |
{ |
| 3638 |
\@@_debug:n{Drawing:~startrange,~pseudofade~beyond~finish} |
| 3639 |
\@@_debug:n{~ |
| 3640 |
\l_@@_finish_beyond_x~to~\l_@@_finish_x |
| 3641 |
} |
| 3642 |
\pgfscope |
| 3643 |
\pgfpathrectanglecorners{ |
| 3644 |
\pgfpoint |
| 3645 |
{\l_@@_finish_x} |
| 3646 |
{-\l_@@_bar_half_thickness_pgf} |
| 3647 |
}{ |
| 3648 |
\pgfpoint |
| 3649 |
{\l_@@_finish_beyond_x} |
| 3650 |
{\l_@@_bar_half_thickness_pgf} |
| 3651 |
} |
| 3652 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3653 |
\pgfsetfillopacity |
| 3654 |
{\l_@@_interval_startrange_finish_level_pgf} |
| 3655 |
\pgfusepath{fill} |
| 3656 |
\endpgfscope |
| 3657 |
} |
| 3658 |
% \end{macrocode} |
| 3659 |
% \end{macro} |
| 3660 |
% |
| 3661 |
% |
| 3662 |
% |
| 3663 |
% \begin{macro}{\@@_interval_finishrange_draw_pseudofade:} |
| 3664 |
% Draw a fading startrange and excess indicators |
| 3665 |
% \begin{macrocode} |
| 3666 |
\cs_new:Npn\@@_interval_finishrange_draw_pseudofade: |
| 3667 |
{ |
| 3668 |
\@@_debug:n{Drawing:~finishrange,~pseudofade} |
| 3669 |
\@@_debug:n{~ |
| 3670 |
\l_@@_interval_finishrange_start_x~ |
| 3671 |
(\l_@@_interval_finishrange_start_level_pgf)~ |
| 3672 |
to~\l_@@_interval_finishrange_finish_x~ |
| 3673 |
(\l_@@_interval_finishrange_finish_level_pgf) |
| 3674 |
} |
| 3675 |
\@@_interval_draw_pseudofade:nnnnn |
| 3676 |
{\l_@@_interval_finishrange_start_x} |
| 3677 |
{\l_@@_interval_finishrange_finish_x} |
| 3678 |
{\l_@@_bar_color} |
| 3679 |
{\l_@@_interval_finishrange_start_level_pgf} |
| 3680 |
{\l_@@_interval_finishrange_finish_level_pgf} |
| 3681 |
\bool_if:NT\l_@@_interval_finish_beyond_bool |
| 3682 |
{ \@@_interval_finishrange_finish_beyond_draw_fade: } |
| 3683 |
\bool_if:NT\l_@@_interval_finishrange_start_beyond_bool |
| 3684 |
{ \@@_interval_finishrange_start_beyond_draw_fade: } |
| 3685 |
} |
| 3686 |
% \end{macrocode} |
| 3687 |
% \end{macro} |
| 3688 |
% |
| 3689 |
% \begin{macro}{\@@_interval_finishrange_finish_beyond_draw_fade:} |
| 3690 |
% Draw a `faded' beyond indicator for a finishrange that extends beyond the timechart finish. |
| 3691 |
% \begin{macrocode} |
| 3692 |
|
| 3693 |
\cs_new:Npn\@@_interval_finishrange_finish_beyond_draw_fade: |
| 3694 |
{ |
| 3695 |
\@@_debug:n{Drawing:~finishrange,~pseudofade~beyond~finish} |
| 3696 |
\@@_debug:n{~ |
| 3697 |
\l_@@_finish_beyond_x~to~\l_@@_finish_x |
| 3698 |
} |
| 3699 |
\pgfscope |
| 3700 |
\pgfpathrectanglecorners{ |
| 3701 |
\pgfpoint |
| 3702 |
{\l_@@_finish_beyond_x} |
| 3703 |
{-\l_@@_bar_half_thickness_pgf} |
| 3704 |
}{ |
| 3705 |
\pgfpoint |
| 3706 |
{\l_@@_finish_x} |
| 3707 |
{\l_@@_bar_half_thickness_pgf} |
| 3708 |
} |
| 3709 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3710 |
\pgfsetfillopacity |
| 3711 |
{\l_@@_interval_finishrange_finish_level_pgf} |
| 3712 |
\pgfusepath{fill} |
| 3713 |
\endpgfscope |
| 3714 |
} |
| 3715 |
% \end{macrocode} |
| 3716 |
% \end{macro} |
| 3717 |
% |
| 3718 |
% \begin{macro}{\@@_interval_finishrange_start_beyond_draw_fade:} |
| 3719 |
% Draw a `faded' beyond indicator for a finishrange that extends beyond the timechart start. |
| 3720 |
% \begin{macrocode} |
| 3721 |
\cs_new:Npn\@@_interval_finishrange_start_beyond_draw_fade: |
| 3722 |
{ |
| 3723 |
\@@_debug:n{Drawing:~finishrange,~pseudofade~beyond~start} |
| 3724 |
\@@_debug:n{~ |
| 3725 |
\l_@@_start_beyond_x~to~\l_@@_start_x |
| 3726 |
} |
| 3727 |
\pgfscope |
| 3728 |
\pgfpathrectanglecorners{ |
| 3729 |
\pgfpoint |
| 3730 |
{\l_@@_start_x} |
| 3731 |
{-\l_@@_bar_half_thickness_pgf} |
| 3732 |
}{ |
| 3733 |
\pgfpoint |
| 3734 |
{\l_@@_start_beyond_x} |
| 3735 |
{\l_@@_bar_half_thickness_pgf} |
| 3736 |
} |
| 3737 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3738 |
\pgfsetfillopacity |
| 3739 |
{\l_@@_interval_finishrange_start_level_pgf} |
| 3740 |
\pgfusepath{fill} |
| 3741 |
\endpgfscope |
| 3742 |
} |
| 3743 |
% \end{macrocode} |
| 3744 |
% \end{macro} |
| 3745 |
% |
| 3746 |
% \begin{macro}{\@@_interval_draw_pseudofade:nnnnn} |
| 3747 |
% Draw an imitation fading from \param{1} to \param {2} with color \param{3}, starting with opacity \param{4} and |
| 3748 |
% ending with opacity \param{5}. |
| 3749 |
% \begin{macrocode} |
| 3750 |
\pgfmathsetmacro{\l_@@_fadestep_pgf}{1} |
| 3751 |
\cs_new:Npn\@@_interval_draw_pseudofade:nnnnn #1#2#3#4#5 |
| 3752 |
{ |
| 3753 |
\@@_debug:n{Pseudofade:~#1~to~#2,~color~#3,~opacity~#4~to~#5} |
| 3754 |
\group_begin: |
| 3755 |
\pgfmathsetmacro{\start}{#1} |
| 3756 |
\pgfmathsetmacro{\stop}{#2} |
| 3757 |
\pgfmathsetmacro{\fadestep} |
| 3758 |
{(\stop-\start)/(floor((\stop-\start)/\l_@@_fadestep_pgf)+1)} |
| 3759 |
\pgfmathsetmacro{\startnext}{\start+\fadestep} |
| 3760 |
\pgfmathsetmacro{\stopprev}{\stop-\fadestep} |
| 3761 |
\pgfmathsetmacro{\denominator}{abs(\stop-\start)+\fadestep} |
| 3762 |
\foreach \xa in {\start,\startnext,...,\stopprev} { |
| 3763 |
\pgfmathsetlengthmacro{\o} |
| 3764 |
{((\stop-\xa)*#4+(\xa-\start+\fadestep)*#5)/\denominator} |
| 3765 |
\pgfscope |
| 3766 |
\pgfpathrectanglecorners{ |
| 3767 |
\pgfpoint{\xa}{-\l_@@_bar_half_thickness_pgf} |
| 3768 |
}{ |
| 3769 |
\pgfpoint{\xa+\fadestep}{\l_@@_bar_half_thickness_pgf} |
| 3770 |
} |
| 3771 |
\pgfsetfillcolor{#3} |
| 3772 |
\pgfsetfillopacity{\o} |
| 3773 |
\pgfusepath{fill} |
| 3774 |
\endpgfscope |
| 3775 |
} |
| 3776 |
\group_end: |
| 3777 |
} |
| 3778 |
% \end{macrocode} |
| 3779 |
% \end{macro} |
| 3780 |
% |
| 3781 |
% |
| 3782 |
% |
| 3783 |
% \paragraph{Start/finish range slant} |
| 3784 |
% |
| 3785 |
% \begin{macro}{\@@_interval_startfinishrange_draw_slant:} |
| 3786 |
% Draw an already-clipped slanted start/finishrange and beyond indicators. This macro will only be called when there |
| 3787 |
% is no `solid' part to drawn (for otherwise the solid part is extended to fill the start/finishrange), and so the |
| 3788 |
% only thing to draw is the start/finishrange. Hence the macro can simply fill everything |
| 3789 |
% \begin{macrocode} |
| 3790 |
\cs_new:Npn\@@_interval_startfinishrange_draw_slant: |
| 3791 |
{ |
| 3792 |
\pgfpathrectanglecorners{ |
| 3793 |
\pgfpoint |
| 3794 |
{\l_@@_start_beyond_x} |
| 3795 |
{-\l_@@_bar_half_thickness_pgf} |
| 3796 |
}{ |
| 3797 |
\pgfpoint |
| 3798 |
{\l_@@_finish_beyond_x} |
| 3799 |
{\l_@@_bar_half_thickness_pgf} |
| 3800 |
} |
| 3801 |
\pgfsetfillcolor{\l_@@_bar_color} |
| 3802 |
\pgfusepath{fill} |
| 3803 |
} |
| 3804 |
% \end{macrocode} |
| 3805 |
% \end{macro} |
| 3806 |
% |
| 3807 |
% |
| 3808 |
% |
| 3809 |
% \subsubsection{Clipping} |
| 3810 |
% |
| 3811 |
% |
| 3812 |
% |
| 3813 |
% \paragraph{Start/finish no-clipping paths} |
| 3814 |
% |
| 3815 |
% \begin{macro}{\c_@@_left_far_x,\c_@@_right_far_x} |
| 3816 |
% No-clipping paths actually use the following \(x\)-coordinates, which are large in the positive and negative |
| 3817 |
% direction. |
| 3818 |
% \begin{macrocode} |
| 3819 |
\pgfmathsetmacro{\c_@@_left_far_x}{-16000pt} |
| 3820 |
\pgfmathsetmacro{\c_@@_right_far_x}{16000pt} |
| 3821 |
% \end{macrocode} |
| 3822 |
% \end{macro} |
| 3823 |
% |
| 3824 |
% \begin{macro}{\@@_interval_start_clip_path_none:} |
| 3825 |
% No clip path for start. |
| 3826 |
% \begin{macrocode} |
| 3827 |
\cs_new:Npn\@@_interval_start_clip_path_none: |
| 3828 |
{ |
| 3829 |
\@@_debug:n{~Start~clip~path:~none} |
| 3830 |
\pgfpathlineto{ |
| 3831 |
\pgfpoint |
| 3832 |
{\c_@@_left_far_x} |
| 3833 |
{-\l_@@_bar_thickness_pgf} |
| 3834 |
} |
| 3835 |
\pgfpathlineto{ |
| 3836 |
\pgfpoint |
| 3837 |
{\c_@@_left_far_x} |
| 3838 |
{\l_@@_bar_thickness_pgf} |
| 3839 |
} |
| 3840 |
} |
| 3841 |
% \end{macrocode} |
| 3842 |
% \end{macro} |
| 3843 |
% |
| 3844 |
% \begin{macro}{\@@_interval_finish_clip_path_none:} |
| 3845 |
% No clip path for finish. |
| 3846 |
% \begin{macrocode} |
| 3847 |
\cs_new:Npn\@@_interval_finish_clip_path_none: |
| 3848 |
{ |
| 3849 |
\@@_debug:n{~Finish~clip~path:~none} |
| 3850 |
\pgfpathmoveto{ |
| 3851 |
\pgfpoint |
| 3852 |
{\c_@@_right_far_x} |
| 3853 |
{\l_@@_bar_thickness_pgf} |
| 3854 |
} |
| 3855 |
\pgfpathlineto{ |
| 3856 |
\pgfpoint |
| 3857 |
{\c_@@_right_far_x} |
| 3858 |
{-\l_@@_bar_thickness_pgf} |
| 3859 |
} |
| 3860 |
} |
| 3861 |
% \end{macrocode} |
| 3862 |
% \end{macro} |
| 3863 |
% |
| 3864 |
% |
| 3865 |
% |
| 3866 |
% \paragraph{Start/finish beyond indicator clipping paths} |
| 3867 |
% |
| 3868 |
% \begin{macro}{\@@_interval_start_clip_path_beyond:} |
| 3869 |
% Clip path for start beyond indicator. |
| 3870 |
% \begin{macrocode} |
| 3871 |
\cs_new:Npn\@@_interval_start_clip_path_beyond: |
| 3872 |
{ |
| 3873 |
\@@_debug:n{~Start~clip~path:~beyond} |
| 3874 |
\pgfpathlineto{ |
| 3875 |
\pgfpoint |
| 3876 |
{\l_@@_start_beyond_x} |
| 3877 |
{-\l_@@_bar_thickness_pgf} |
| 3878 |
} |
| 3879 |
\pgfpathlineto{ |
| 3880 |
\pgfpoint |
| 3881 |
{\l_@@_start_beyond_x} |
| 3882 |
{-\l_@@_bar_half_thickness_pgf} |
| 3883 |
} |
| 3884 |
\pgfpatharc |
| 3885 |
{-90} |
| 3886 |
{90} |
| 3887 |
{\l_@@_start_beyond_x_radius_pgf |
| 3888 |
~and~\l_@@_bar_half_thickness_pgf} |
| 3889 |
\pgfpathlineto{ |
| 3890 |
\pgfpoint |
| 3891 |
{\l_@@_start_beyond_x} |
| 3892 |
{\l_@@_bar_thickness_pgf} |
| 3893 |
} |
| 3894 |
} |
| 3895 |
% \end{macrocode} |
| 3896 |
% \end{macro} |
| 3897 |
% |
| 3898 |
% \begin{macro}{\@@_interval_finish_clip_path_beyond:} |
| 3899 |
% Clip path for finish beyond indicator. |
| 3900 |
% \begin{macrocode} |
| 3901 |
\cs_new:Npn\@@_interval_finish_clip_path_beyond: |
| 3902 |
{ |
| 3903 |
\@@_debug:n{~Finish~clip~path:~beyond} |
| 3904 |
\pgfpathmoveto{ |
| 3905 |
\pgfpoint |
| 3906 |
{\l_@@_finish_beyond_x} |
| 3907 |
{\l_@@_bar_thickness_pgf} |
| 3908 |
} |
| 3909 |
\pgfpathlineto{ |
| 3910 |
\pgfpoint |
| 3911 |
{\l_@@_finish_beyond_x} |
| 3912 |
{\l_@@_bar_half_thickness_pgf} |
| 3913 |
} |
| 3914 |
\pgfpatharc |
| 3915 |
{90} |
| 3916 |
{270} |
| 3917 |
{\l_@@_finish_beyond_x_radius_pgf |
| 3918 |
~and~\l_@@_bar_half_thickness_pgf} |
| 3919 |
\pgfpathlineto{ |
| 3920 |
\pgfpoint |
| 3921 |
{\l_@@_finish_beyond_x} |
| 3922 |
{-\l_@@_bar_thickness_pgf} |
| 3923 |
} |
| 3924 |
} |
| 3925 |
% \end{macrocode} |
| 3926 |
% \end{macro} |
| 3927 |
% |
| 3928 |
% |
| 3929 |
% |
| 3930 |
% \paragraph{Startrange/finishrange clipping paths} |
| 3931 |
% |
| 3932 |
% \begin{macro}{\@@_interval_startrange_clip_path_start:} |
| 3933 |
% Clip path for startrange. |
| 3934 |
% \begin{macrocode} |
| 3935 |
\cs_new:Npn\@@_interval_startrange_clip_path_start: |
| 3936 |
{ |
| 3937 |
\@@_debug:n{~Start~clip~path:~startrange} |
| 3938 |
\pgfpathlineto{ |
| 3939 |
\pgfpoint |
| 3940 |
{\l_@@_interval_startrange_start_x} |
| 3941 |
{-\l_@@_bar_thickness_pgf} |
| 3942 |
} |
| 3943 |
\pgfpathlineto{ |
| 3944 |
\pgfpoint |
| 3945 |
{\l_@@_interval_startrange_start_x} |
| 3946 |
{-\l_@@_bar_half_thickness_pgf} |
| 3947 |
} |
| 3948 |
\pgfpathlineto{ |
| 3949 |
\pgfpoint |
| 3950 |
{\l_@@_interval_startrange_finish_x} |
| 3951 |
{\l_@@_bar_half_thickness_pgf} |
| 3952 |
} |
| 3953 |
\pgfpathlineto{ |
| 3954 |
\pgfpoint |
| 3955 |
{\l_@@_interval_startrange_finish_x} |
| 3956 |
{\l_@@_bar_thickness_pgf} |
| 3957 |
} |
| 3958 |
} |
| 3959 |
% \end{macrocode} |
| 3960 |
% \end{macro} |
| 3961 |
% |
| 3962 |
% \begin{macro}{\@@_interval_finishrange_clip_path_finish:} |
| 3963 |
% Clip path for finishrange. |
| 3964 |
% \begin{macrocode} |
| 3965 |
\cs_new:Npn\@@_interval_finishrange_clip_path_finish: |
| 3966 |
{ |
| 3967 |
\@@_debug:n{~Finish~clip~path:~finishrange} |
| 3968 |
\pgfpathmoveto{ |
| 3969 |
\pgfpoint |
| 3970 |
{\l_@@_interval_finishrange_finish_x} |
| 3971 |
{\l_@@_bar_thickness_pgf} |
| 3972 |
} |
| 3973 |
\pgfpathlineto{ |
| 3974 |
\pgfpoint |
| 3975 |
{\l_@@_interval_finishrange_finish_x} |
| 3976 |
{\l_@@_bar_half_thickness_pgf} |
| 3977 |
} |
| 3978 |
\pgfpathlineto{ |
| 3979 |
\pgfpoint |
| 3980 |
{\l_@@_interval_finishrange_start_x} |
| 3981 |
{-\l_@@_bar_half_thickness_pgf} |
| 3982 |
} |
| 3983 |
\pgfpathlineto{ |
| 3984 |
\pgfpoint |
| 3985 |
{\l_@@_interval_finishrange_start_x} |
| 3986 |
{-\l_@@_bar_thickness_pgf} |
| 3987 |
} |
| 3988 |
} |
| 3989 |
% \end{macrocode} |
| 3990 |
% \end{macro} |
| 3991 |
% |
| 3992 |
% |
| 3993 |
% |
| 3994 |
% \paragraph{Startrange/finishrange clipping paths with `same side' beyond indicator} |
| 3995 |
% |
| 3996 |
% \begin{macro}{\@@_interval_startrange_clip_path_beyond_start:} |
| 3997 |
% Clip path for startrange with start beyond indicator. |
| 3998 |
% \begin{macrocode} |
| 3999 |
\cs_new:Npn \@@_interval_startrange_clip_path_beyond_start: |
| 4000 |
{ |
| 4001 |
\@@_debug:n{~Start~clip~path:~startrange,~beyond~start} |
| 4002 |
\pgfmathsetmacro{\l_@@_tmpa_pgf}{ |
| 4003 |
\l_@@_bar_thickness_pgf |
| 4004 |
*\l_@@_interval_startrange_start_level_pgf |
| 4005 |
} |
| 4006 |
\pgfmathsetmacro{\l_@@_tmpb_pgf}{ |
| 4007 |
.5*\l_@@_tmpa_pgf |
| 4008 |
} |
| 4009 |
\pgfpathlineto{ |
| 4010 |
\pgfpoint |
| 4011 |
{\l_@@_start_beyond_x} |
| 4012 |
{-\l_@@_bar_thickness_pgf} |
| 4013 |
} |
| 4014 |
\pgfpathlineto{ |
| 4015 |
\pgfpoint |
| 4016 |
{\l_@@_start_beyond_x} |
| 4017 |
{-\l_@@_bar_half_thickness_pgf} |
| 4018 |
} |
| 4019 |
\pgfpatharc |
| 4020 |
{-90} |
| 4021 |
{90} |
| 4022 |
{\l_@@_start_beyond_x_radius_pgf |
| 4023 |
~and~\l_@@_tmpb_pgf} |
| 4024 |
\pgfpathlineto{ |
| 4025 |
\pgfpointadd{ |
| 4026 |
\pgfpoint |
| 4027 |
{\l_@@_start_x} |
| 4028 |
{-\l_@@_bar_half_thickness_pgf} |
| 4029 |
}{ |
| 4030 |
\pgfpoint{0}{\l_@@_tmpa_pgf} |
| 4031 |
} |
| 4032 |
} |
| 4033 |
\pgfpathlineto{ |
| 4034 |
\pgfpoint |
| 4035 |
{\l_@@_interval_start_max_x} |
| 4036 |
{\l_@@_bar_half_thickness_pgf} |
| 4037 |
} |
| 4038 |
\pgfpathlineto{ |
| 4039 |
\pgfpoint |
| 4040 |
{\l_@@_interval_start_max_x} |
| 4041 |
{\l_@@_bar_thickness_pgf} |
| 4042 |
} |
| 4043 |
} |
| 4044 |
% \end{macrocode} |
| 4045 |
% \end{macro} |
| 4046 |
% |
| 4047 |
% \begin{macro}{\@@_interval_finishrange_clip_path_beyond_finish:} |
| 4048 |
% Clip path for finishrange with finish beyond indicator. |
| 4049 |
% \begin{macrocode} |
| 4050 |
\cs_new:Npn\@@_interval_finishrange_clip_path_beyond_finish: |
| 4051 |
{ |
| 4052 |
\@@_debug:n{~Finish~clip~path:~finishrange,~beyond~finish} |
| 4053 |
\pgfmathsetmacro{\l_@@_tmpa_pgf}{ |
| 4054 |
\l_@@_bar_thickness_pgf |
| 4055 |
*\l_@@_interval_finishrange_finish_level_pgf |
| 4056 |
} |
| 4057 |
\pgfmathsetmacro{\l_@@_tmpb_pgf}{ |
| 4058 |
.5*\l_@@_tmpa_pgf |
| 4059 |
} |
| 4060 |
\pgfpathmoveto{ |
| 4061 |
\pgfpoint |
| 4062 |
{\l_@@_finish_beyond_x} |
| 4063 |
{\l_@@_bar_thickness_pgf} |
| 4064 |
} |
| 4065 |
\pgfpathlineto{ |
| 4066 |
\pgfpoint |
| 4067 |
{\l_@@_finish_beyond_x} |
| 4068 |
{\l_@@_bar_half_thickness_pgf} |
| 4069 |
} |
| 4070 |
\pgfpatharc |
| 4071 |
{90} |
| 4072 |
{270} |
| 4073 |
{\l_@@_finish_beyond_x_radius_pgf |
| 4074 |
~and~\l_@@_tmpb_pgf} |
| 4075 |
\pgfpathlineto{ |
| 4076 |
\pgfpointadd{ |
| 4077 |
\pgfpoint |
| 4078 |
{\l_@@_finish_x} |
| 4079 |
{\l_@@_bar_half_thickness_pgf} |
| 4080 |
}{ |
| 4081 |
\pgfpoint{0}{-\l_@@_tmpa_pgf} |
| 4082 |
} |
| 4083 |
} |
| 4084 |
\pgfpathlineto{ |
| 4085 |
\pgfpoint |
| 4086 |
{\l_@@_interval_finish_min_x} |
| 4087 |
{-\l_@@_bar_half_thickness_pgf} |
| 4088 |
} |
| 4089 |
\pgfpathlineto{ |
| 4090 |
\pgfpoint |
| 4091 |
{\l_@@_interval_finish_min_x} |
| 4092 |
{-\l_@@_bar_thickness_pgf} |
| 4093 |
} |
| 4094 |
} |
| 4095 |
% \end{macrocode} |
| 4096 |
% \end{macro} |
| 4097 |
% |
| 4098 |
% |
| 4099 |
% |
| 4100 |
% \paragraph{Startrange/finishrange clipping paths with `opposite side' beyond indicator} |
| 4101 |
% |
| 4102 |
% \begin{macro}{\@@_interval_startrange_clip_path_beyond_finish:} |
| 4103 |
% Clip path for startrange with finish beyond indicator. This macro should only be executed as |
| 4104 |
% \cs{@@_interval_both_clip_path:} and specifies a complete path. |
| 4105 |
% \begin{macrocode} |
| 4106 |
\cs_new:Npn\@@_interval_startrange_clip_path_beyond_finish: |
| 4107 |
{ |
| 4108 |
\@@_debug:n{~Two-sided~clip~path:~startrange,~beyond~finish} |
| 4109 |
\pgfmathsetmacro{\l_@@_tmpc_pgf}{ |
| 4110 |
\l_@@_bar_thickness_pgf |
| 4111 |
*\l_@@_interval_startrange_finish_level_pgf |
| 4112 |
} |
| 4113 |
\pgfmathsetmacro{\l_@@_tmpd_pgf}{ |
| 4114 |
.5*\l_@@_tmpc_pgf |
| 4115 |
} |
| 4116 |
\pgfpathmoveto{ |
| 4117 |
\pgfpointadd{ |
| 4118 |
\pgfpoint |
| 4119 |
{\l_@@_finish_beyond_x} |
| 4120 |
{-\l_@@_bar_half_thickness_pgf} |
| 4121 |
}{ |
| 4122 |
\pgfpoint{0}{\l_@@_tmpc_pgf} |
| 4123 |
} |
| 4124 |
} |
| 4125 |
\pgfpatharc |
| 4126 |
{90} |
| 4127 |
{270} |
| 4128 |
{\l_@@_start_beyond_x_radius_pgf |
| 4129 |
~and~\l_@@_tmpd_pgf} |
| 4130 |
\pgfpathlineto{ |
| 4131 |
\pgfpoint |
| 4132 |
{\l_@@_finish_beyond_x} |
| 4133 |
{-\l_@@_bar_thickness_pgf} |
| 4134 |
} |
| 4135 |
\pgfpathlineto{ |
| 4136 |
\pgfpoint |
| 4137 |
{\l_@@_interval_start_min_x} |
| 4138 |
{-\l_@@_bar_thickness_pgf} |
| 4139 |
} |
| 4140 |
\pgfpathlineto{ |
| 4141 |
\pgfpoint |
| 4142 |
{\l_@@_interval_start_min_x} |
| 4143 |
{-\l_@@_bar_half_thickness_pgf} |
| 4144 |
} |
| 4145 |
\pgfpathlineto{ |
| 4146 |
\pgfpointadd{ |
| 4147 |
\pgfpoint |
| 4148 |
{\l_@@_finish_x} |
| 4149 |
{-\l_@@_bar_half_thickness_pgf} |
| 4150 |
}{ |
| 4151 |
\pgfpoint{0}{\l_@@_tmpc_pgf} |
| 4152 |
} |
| 4153 |
} |
| 4154 |
} |
| 4155 |
% \end{macrocode} |
| 4156 |
% \end{macro} |
| 4157 |
% |
| 4158 |
% \begin{macro}{\@@_interval_finishrange_clip_path_beyond_start:} |
| 4159 |
% Clip path for finishrange with start beyond indicator. This macro should only be executed as |
| 4160 |
% \cs{@@_interval_both_clip_path:} and specifies a complete path. |
| 4161 |
% \begin{macrocode} |
| 4162 |
\cs_new:Npn\@@_interval_finishrange_clip_path_beyond_start: |
| 4163 |
{ |
| 4164 |
\@@_debug:n{~Two-sided~clip~path:~finishrange,~beyond~start} |
| 4165 |
\pgfmathsetmacro{\l_@@_tmpc_pgf}{ |
| 4166 |
\l_@@_bar_thickness_pgf |
| 4167 |
*\l_@@_interval_finishrange_start_level_pgf |
| 4168 |
} |
| 4169 |
\pgfmathsetmacro{\l_@@_tmpd_pgf}{ |
| 4170 |
.5*\l_@@_tmpc_pgf |
| 4171 |
} |
| 4172 |
\pgfpathmoveto{ |
| 4173 |
\pgfpointadd{ |
| 4174 |
\pgfpoint |
| 4175 |
{\l_@@_start_beyond_x} |
| 4176 |
{\l_@@_bar_half_thickness_pgf} |
| 4177 |
}{ |
| 4178 |
\pgfpoint{0}{-\l_@@_tmpc_pgf} |
| 4179 |
} |
| 4180 |
} |
| 4181 |
\pgfpatharc |
| 4182 |
{-90} |
| 4183 |
{90} |
| 4184 |
{\l_@@_start_beyond_x_radius_pgf |
| 4185 |
~and~\l_@@_tmpd_pgf} |
| 4186 |
\pgfpathlineto{ |
| 4187 |
\pgfpoint |
| 4188 |
{\l_@@_start_beyond_x} |
| 4189 |
{\l_@@_bar_thickness_pgf} |
| 4190 |
} |
| 4191 |
\pgfpathlineto{ |
| 4192 |
\pgfpoint |
| 4193 |
{\l_@@_interval_finish_max_x} |
| 4194 |
{\l_@@_bar_thickness_pgf} |
| 4195 |
} |
| 4196 |
\pgfpathlineto{ |
| 4197 |
\pgfpoint |
| 4198 |
{\l_@@_interval_finish_max_x} |
| 4199 |
{\l_@@_bar_half_thickness_pgf} |
| 4200 |
} |
| 4201 |
\pgfpathlineto{ |
| 4202 |
\pgfpointadd{ |
| 4203 |
\pgfpoint |
| 4204 |
{\l_@@_start_x} |
| 4205 |
{\l_@@_bar_half_thickness_pgf} |
| 4206 |
}{ |
| 4207 |
\pgfpoint{0}{-\l_@@_tmpc_pgf} |
| 4208 |
} |
| 4209 |
} |
| 4210 |
} |
| 4211 |
% \end{macrocode} |
| 4212 |
% \end{macro} |
| 4213 |
% |
| 4214 |
% |
| 4215 |
% |
| 4216 |
% \paragraph{Startrange/finishrange clipping paths with `both sides' beyond indicator} |
| 4217 |
% |
| 4218 |
% \begin{macro}{\@@_interval_startrange_clip_path_beyond_both:} |
| 4219 |
% Clip path for startrange with start and finish beyond indicators. This macro should only be executed as |
| 4220 |
% \cs{@@_interval_both_clip_path:} and specifies a complete path. |
| 4221 |
% \begin{macrocode} |
| 4222 |
\cs_new:Npn\@@_interval_startrange_clip_path_beyond_both: |
| 4223 |
{ |
| 4224 |
\@@_debug:n{~Two-sided~clip~path:~startrange,~beyond~both} |
| 4225 |
\pgfmathsetmacro{\l_@@_tmpa_pgf}{ |
| 4226 |
\l_@@_bar_thickness_pgf |
| 4227 |
*\l_@@_interval_startrange_start_level_pgf |
| 4228 |
} |
| 4229 |
\pgfmathsetmacro{\l_@@_tmpb_pgf}{ |
| 4230 |
.5*\l_@@_tmpa_pgf |
| 4231 |
} |
| 4232 |
\pgfmathsetmacro{\l_@@_tmpc_pgf}{ |
| 4233 |
\l_@@_bar_thickness_pgf |
| 4234 |
*\l_@@_interval_startrange_finish_level_pgf |
| 4235 |
} |
| 4236 |
\pgfmathsetmacro{\l_@@_tmpd_pgf}{ |
| 4237 |
.5*\l_@@_tmpc_pgf |
| 4238 |
} |
| 4239 |
\pgfpathmoveto{ |
| 4240 |
\pgfpointadd{ |
| 4241 |
\pgfpoint |
| 4242 |
{\l_@@_finish_beyond_x} |
| 4243 |
{-\l_@@_bar_half_thickness_pgf} |
| 4244 |
}{ |
| 4245 |
\pgfpoint{0}{\l_@@_tmpc_pgf} |
| 4246 |
} |
| 4247 |
} |
| 4248 |
\pgfpatharc |
| 4249 |
{90} |
| 4250 |
{270} |
| 4251 |
{\l_@@_finish_beyond_x_radius_pgf |
| 4252 |
~and~\l_@@_tmpd_pgf} |
| 4253 |
\pgfpathlineto{ |
| 4254 |
\pgfpoint |
| 4255 |
{\l_@@_finish_beyond_x} |
| 4256 |
{-\l_@@_bar_thickness_pgf} |
| 4257 |
} |
| 4258 |
\pgfpathlineto{ |
| 4259 |
\pgfpoint |
| 4260 |
{\l_@@_start_beyond_x} |
| 4261 |
{-\l_@@_bar_thickness_pgf} |
| 4262 |
} |
| 4263 |
\pgfpathlineto{ |
| 4264 |
\pgfpoint |
| 4265 |
{\l_@@_start_beyond_x} |
| 4266 |
{-\l_@@_bar_half_thickness_pgf} |
| 4267 |
} |
| 4268 |
\pgfpatharc |
| 4269 |
{-90} |
| 4270 |
{90} |
| 4271 |
{\l_@@_start_beyond_x_radius_pgf |
| 4272 |
~and~\l_@@_tmpb_pgf} |
| 4273 |
\pgfpathlineto{ |
| 4274 |
\pgfpointadd{ |
| 4275 |
\pgfpoint |
| 4276 |
{\l_@@_start_x} |
| 4277 |
{-\l_@@_bar_half_thickness_pgf} |
| 4278 |
}{ |
| 4279 |
\pgfpoint{0}{\l_@@_tmpa_pgf} |
| 4280 |
} |
| 4281 |
} |
| 4282 |
\pgfpathlineto{ |
| 4283 |
\pgfpointadd{ |
| 4284 |
\pgfpoint |
| 4285 |
{\l_@@_finish_x} |
| 4286 |
{-\l_@@_bar_half_thickness_pgf} |
| 4287 |
}{ |
| 4288 |
\pgfpoint{0}{\l_@@_tmpc_pgf} |
| 4289 |
} |
| 4290 |
} |
| 4291 |
} |
| 4292 |
% \end{macrocode} |
| 4293 |
% \end{macro} |
| 4294 |
% |
| 4295 |
% \begin{macro}{\@@_interval_finishrange_clip_path_beyond_both:} |
| 4296 |
% Clip path for finishrange with start and finish beyond indicators. This macro should only be executed as |
| 4297 |
% \cs{@@_interval_both_clip_path:} and specifies a complete path. |
| 4298 |
% \begin{macrocode} |
| 4299 |
\cs_new:Npn\@@_interval_finishrange_clip_path_beyond_both: |
| 4300 |
{ |
| 4301 |
\@@_debug:n{~Two-sided~clip~path:~finishrange,~beyond~both} |
| 4302 |
\pgfmathsetmacro{\l_@@_tmpa_pgf}{ |
| 4303 |
\l_@@_bar_thickness_pgf |
| 4304 |
*\l_@@_interval_finishrange_finish_level_pgf |
| 4305 |
} |
| 4306 |
\pgfmathsetmacro{\l_@@_tmpb_pgf}{ |
| 4307 |
.5*\l_@@_tmpa_pgf |
| 4308 |
} |
| 4309 |
\pgfmathsetmacro{\l_@@_tmpc_pgf}{ |
| 4310 |
\l_@@_bar_thickness_pgf |
| 4311 |
*\l_@@_interval_finishrange_start_level_pgf |
| 4312 |
} |
| 4313 |
\pgfmathsetmacro{\l_@@_tmpd_pgf}{ |
| 4314 |
.5*\l_@@_tmpc_pgf |
| 4315 |
} |
| 4316 |
\pgfpathmoveto{ |
| 4317 |
\pgfpointadd{ |
| 4318 |
\pgfpoint |
| 4319 |
{\l_@@_start_beyond_x} |
| 4320 |
{\l_@@_bar_half_thickness_pgf} |
| 4321 |
}{ |
| 4322 |
\pgfpoint{0}{-\l_@@_tmpc_pgf} |
| 4323 |
} |
| 4324 |
} |
| 4325 |
\pgfpatharc |
| 4326 |
{-90} |
| 4327 |
{90} |
| 4328 |
{\l_@@_start_beyond_x_radius_pgf |
| 4329 |
~and~\l_@@_tmpd_pgf} |
| 4330 |
\pgfpathlineto{ |
| 4331 |
\pgfpoint |
| 4332 |
{\l_@@_start_beyond_x} |
| 4333 |
{\l_@@_bar_thickness_pgf} |
| 4334 |
} |
| 4335 |
\pgfpathlineto{ |
| 4336 |
\pgfpoint |
| 4337 |
{\l_@@_finish_beyond_x} |
| 4338 |
{\l_@@_bar_thickness_pgf} |
| 4339 |
} |
| 4340 |
\pgfpathlineto{ |
| 4341 |
\pgfpoint |
| 4342 |
{\l_@@_finish_beyond_x} |
| 4343 |
{\l_@@_bar_half_thickness_pgf} |
| 4344 |
} |
| 4345 |
\pgfpatharc |
| 4346 |
{90} |
| 4347 |
{270} |
| 4348 |
{\l_@@_finish_beyond_x_radius_pgf |
| 4349 |
~and~\l_@@_tmpb_pgf} |
| 4350 |
\pgfpathlineto{ |
| 4351 |
\pgfpointadd{ |
| 4352 |
\pgfpoint |
| 4353 |
{\l_@@_finish_x} |
| 4354 |
{\l_@@_bar_half_thickness_pgf} |
| 4355 |
}{ |
| 4356 |
\pgfpoint{0}{-\l_@@_tmpa_pgf} |
| 4357 |
} |
| 4358 |
} |
| 4359 |
\pgfpathlineto{ |
| 4360 |
\pgfpointadd{ |
| 4361 |
\pgfpoint |
| 4362 |
{\l_@@_start_x} |
| 4363 |
{\l_@@_bar_half_thickness_pgf} |
| 4364 |
}{ |
| 4365 |
\pgfpoint{0}{-\l_@@_tmpc_pgf} |
| 4366 |
} |
| 4367 |
} |
| 4368 |
} |
| 4369 |
% \end{macrocode} |
| 4370 |
% \end{macro} |
| 4371 |
% |
| 4372 |
% |
| 4373 |
% |
| 4374 |
% \paragraph{Core clipping macros} |
| 4375 |
% |
| 4376 |
% \begin{macro}{\@@_interval_clip:} |
| 4377 |
% Clip the interval. The internal macro \cs{@@_interval_both_clip_path:} may be redefined from its default. |
| 4378 |
% \begin{macrocode} |
| 4379 |
\cs_new:Npn\@@_interval_clip: |
| 4380 |
{ |
| 4381 |
\@@_debug:n{Clipping:} |
| 4382 |
\pgfinterruptboundingbox |
| 4383 |
\@@_interval_both_clip_path: |
| 4384 |
\pgfpathclose |
| 4385 |
\pgfusepath{clip} |
| 4386 |
\endpgfinterruptboundingbox |
| 4387 |
} |
| 4388 |
% \end{macrocode} |
| 4389 |
% \end{macro} |
| 4390 |
% |
| 4391 |
% \begin{macro}{\@@_interval_both_clip_path:} |
| 4392 |
% Specify a clipping path for the interval. If either of the macros \cs{@@_interval_start_clip_path:} is |
| 4393 |
% \cs{@@_interval_finish_clip_path:} is defined, it is used, otherwise the respective defaults are used. |
| 4394 |
% \begin{macrocode} |
| 4395 |
\cs_new:Npn\@@_interval_both_clip_path: |
| 4396 |
{ |
| 4397 |
\cs_if_exist_use:NF\@@_interval_finish_clip_path: |
| 4398 |
{ \@@_interval_finish_clip_path_none: } |
| 4399 |
\cs_if_exist_use:NF\@@_interval_start_clip_path: |
| 4400 |
{ \@@_interval_start_clip_path_none: } |
| 4401 |
} |
| 4402 |
% \end{macrocode} |
| 4403 |
% \end{macro} |
| 4404 |
% |
| 4405 |
% |
| 4406 |
% |
| 4407 |
% \subsubsection{Marks} |
| 4408 |
% |
| 4409 |
% \begin{macrocode} |
| 4410 |
\msg_new:nnn{timechart}{interval_mark_outside} |
| 4411 |
{ Ignoring~mark~outside~interval~definite~part~at~date~#1 } |
| 4412 |
% \end{macrocode} |
| 4413 |
% |
| 4414 |
% \begin{macro}{\@@_interval_mark:} |
| 4415 |
% Draw marks on an interval. |
| 4416 |
% \begin{macrocode} |
| 4417 |
\cs_new:Npn\@@_interval_mark: |
| 4418 |
{ |
| 4419 |
\pgfscope |
| 4420 |
\bool_if:NTF\l_@@_interval_start_beyond_bool |
| 4421 |
{ |
| 4422 |
\pgfmathsetmacro{\l_@@_interval_mark_min_x} |
| 4423 |
{ max(\l_@@_interval_start_max_x,\l_@@_start_x) } |
| 4424 |
} |
| 4425 |
{ |
| 4426 |
\cs_set_eq:NN\l_@@_interval_mark_min_x\l_@@_interval_start_max_x |
| 4427 |
} |
| 4428 |
\bool_if:NTF\l_@@_interval_finish_beyond_bool |
| 4429 |
{ |
| 4430 |
\pgfmathsetmacro{\l_@@_interval_mark_max_x} |
| 4431 |
{ min(\l_@@_interval_finish_min_x,\l_@@_finish_x) } |
| 4432 |
} |
| 4433 |
{ |
| 4434 |
\cs_set_eq:NN\l_@@_interval_mark_max_x\l_@@_interval_finish_min_x |
| 4435 |
} |
| 4436 |
\pgfsetstrokecolor{\l_@@_mark_color} |
| 4437 |
\foreach \year in \l_@@_mark_text |
| 4438 |
{ |
| 4439 |
\pgfmathsetmacro{\l_@@_mark_x}{yeartox(\year)} |
| 4440 |
\@@_pgfmathsetbool:nn{\l_@@_tmpa_bool} |
| 4441 |
{ |
| 4442 |
and ( |
| 4443 |
\l_@@_mark_x >= \l_@@_interval_mark_min_x, |
| 4444 |
\l_@@_mark_x <= \l_@@_interval_mark_max_x |
| 4445 |
) |
| 4446 |
} |
| 4447 |
\bool_if:NTF\l_@@_tmpa_bool |
| 4448 |
{ |
| 4449 |
\pgfpathmoveto{ |
| 4450 |
\pgfpoint |
| 4451 |
{\l_@@_mark_x} |
| 4452 |
{-\l_@@_bar_half_thickness_pgf} |
| 4453 |
} |
| 4454 |
\pgfpathlineto{ |
| 4455 |
\pgfpoint |
| 4456 |
{\l_@@_mark_x} |
| 4457 |
{\l_@@_bar_half_thickness_pgf} |
| 4458 |
} |
| 4459 |
\pgfusepath{draw} |
| 4460 |
} |
| 4461 |
{ \msg_warning:nne{timechart}{interval_mark_outside}{\year} } |
| 4462 |
} |
| 4463 |
\endpgfscope |
| 4464 |
} |
| 4465 |
% \end{macrocode} |
| 4466 |
% \end{macro} |
| 4467 |
% |
| 4468 |
% |
| 4469 |
% |
| 4470 |
% \subsubsection{Bar node} |
| 4471 |
% |
| 4472 |
% \begin{macro}{\@@_interval_define_bar_node:} |
| 4473 |
% Define a node with into which the bar fits exactly. |
| 4474 |
% \begin{macrocode} |
| 4475 |
\cs_new:Npn\@@_interval_define_bar_node: |
| 4476 |
{ |
| 4477 |
\@@_make_rectangle_node:nnnn |
| 4478 |
{ |
| 4479 |
\pgfpoint |
| 4480 |
{\l_@@_interval_start_min_x} |
| 4481 |
{-\l_@@_bar_half_thickness_pgf} |
| 4482 |
}{ |
| 4483 |
\pgfpoint |
| 4484 |
{\l_@@_interval_finish_max_x} |
| 4485 |
{\l_@@_bar_half_thickness_pgf} |
| 4486 |
} |
| 4487 |
{\pgfkeysvalueof{/timechart/interval~bar~node~name}} |
| 4488 |
{\c_false_bool} |
| 4489 |
} |
| 4490 |
% \end{macrocode} |
| 4491 |
% \end{macro} |
| 4492 |
% |
| 4493 |
% |
| 4494 |
% |
| 4495 |
% \subsubsection{Label} |
| 4496 |
% |
| 4497 |
% \begin{macro}{\@@_interval_label:} |
| 4498 |
% Place the label for the item. |
| 4499 |
% \begin{macrocode} |
| 4500 |
\cs_new:Npn\@@_interval_label: |
| 4501 |
{ |
| 4502 |
\str_if_empty:NF \l_@@_label_text |
| 4503 |
{ |
| 4504 |
\pgfinterruptboundingbox |
| 4505 |
\int_case:nn {\l_@@_label_pos_int} |
| 4506 |
{ |
| 4507 |
{0}{ \@@_interval_label_left: } |
| 4508 |
{1}{ \@@_interval_label_center: } |
| 4509 |
{2}{ \@@_interval_label_right: } |
| 4510 |
} |
| 4511 |
\endpgfinterruptboundingbox |
| 4512 |
} |
| 4513 |
} |
| 4514 |
% \end{macrocode} |
| 4515 |
% \end{macro} |
| 4516 |
% |
| 4517 |
% \begin{macro}{\@@_interval_label_left:} |
| 4518 |
% Place the label on the left of the interval. |
| 4519 |
% \begin{macrocode} |
| 4520 |
\cs_new:Npn\@@_interval_label_left: |
| 4521 |
{ |
| 4522 |
\@@_if_x_in_bounds:nT{\l_@@_interval_start_min_x} |
| 4523 |
{ |
| 4524 |
\group_begin: |
| 4525 |
\pgftransformshift{ |
| 4526 |
\pgfpoint |
| 4527 |
{\l_@@_interval_start_min_x} |
| 4528 |
{\l_@@_text_baseline_pgf} |
| 4529 |
} |
| 4530 |
\node[/timechart/interval~label,anchor=base~east] |
| 4531 |
(\l_@@_interval_label_node_name) |
| 4532 |
at (0,0) |
| 4533 |
{ |
| 4534 |
\@@_make_ref:NN |
| 4535 |
\l_@@_ref_text |
| 4536 |
\l_@@_label_text |
| 4537 |
}; |
| 4538 |
\group_end: |
| 4539 |
} |
| 4540 |
} |
| 4541 |
% \end{macrocode} |
| 4542 |
% \end{macro} |
| 4543 |
% |
| 4544 |
% \begin{macro}{\@@_interval_label_right:} |
| 4545 |
% Place the label on the right of the interval. |
| 4546 |
% \begin{macrocode} |
| 4547 |
\cs_new:Npn\@@_interval_label_right: |
| 4548 |
{ |
| 4549 |
\@@_if_x_in_bounds:nT{\l_@@_interval_finish_max_x} |
| 4550 |
{ |
| 4551 |
\group_begin: |
| 4552 |
\pgftransformshift{ |
| 4553 |
\pgfpoint |
| 4554 |
{\l_@@_interval_finish_max_x} |
| 4555 |
{\l_@@_text_baseline_pgf} |
| 4556 |
} |
| 4557 |
\node[/timechart/interval~label,anchor=base~west] |
| 4558 |
(\l_@@_interval_label_node_name) |
| 4559 |
at (0,0) |
| 4560 |
{ |
| 4561 |
\@@_make_ref:NN |
| 4562 |
\l_@@_ref_text |
| 4563 |
\l_@@_label_text |
| 4564 |
}; |
| 4565 |
\group_end: |
| 4566 |
} |
| 4567 |
} |
| 4568 |
% \end{macrocode} |
| 4569 |
% \end{macro} |
| 4570 |
% |
| 4571 |
% \begin{macro}{\@@_interval_label_center:} |
| 4572 |
% Place the label at the center of the interval. |
| 4573 |
% \begin{macrocode} |
| 4574 |
\cs_new:Npn\@@_interval_label_center: |
| 4575 |
{ |
| 4576 |
\pgfmathsetlengthmacro{\l_@@_label_anchor_x} |
| 4577 |
{ |
| 4578 |
.5*max(\l_@@_interval_start_max_x,\l_@@_start_x) |
| 4579 |
+ .5*min(\l_@@_interval_finish_min_x,\l_@@_finish_x) |
| 4580 |
} |
| 4581 |
% \end{macrocode} |
| 4582 |
% First draw the `background label' on the layer below the bar. |
| 4583 |
% \begin{macrocode} |
| 4584 |
\group_begin: |
| 4585 |
\pgftransformshift{ |
| 4586 |
\pgfpoint |
| 4587 |
{\l_@@_label_anchor_x} |
| 4588 |
{\l_@@_text_baseline_pgf} |
| 4589 |
} |
| 4590 |
\pgfonlayer{labelbg} |
| 4591 |
\node[ |
| 4592 |
/timechart/interval~label~centered~background, |
| 4593 |
anchor=base |
| 4594 |
] |
| 4595 |
at (0,0) |
| 4596 |
{ \l_@@_label_text }; |
| 4597 |
\endpgfonlayer |
| 4598 |
\group_end: |
| 4599 |
% \end{macrocode} |
| 4600 |
% Then draw the label on top of the bar, clipping it to the bar outline. |
| 4601 |
% \begin{macrocode} |
| 4602 |
\pgfscope |
| 4603 |
\pgfpathrectanglecorners{ |
| 4604 |
\pgfpoint |
| 4605 |
{\l_@@_interval_start_min_x} |
| 4606 |
{-\l_@@_bar_half_thickness_pgf} |
| 4607 |
}{ |
| 4608 |
\pgfpoint |
| 4609 |
{\l_@@_interval_finish_max_x} |
| 4610 |
{\l_@@_bar_half_thickness_pgf} |
| 4611 |
} |
| 4612 |
\pgfusepath{clip} |
| 4613 |
\group_begin: |
| 4614 |
\pgftransformshift{ |
| 4615 |
\pgfpoint |
| 4616 |
{\l_@@_label_anchor_x} |
| 4617 |
{\l_@@_text_baseline_pgf} |
| 4618 |
} |
| 4619 |
\node[ |
| 4620 |
/timechart/interval~label~centered, |
| 4621 |
anchor=base |
| 4622 |
] |
| 4623 |
(\l_@@_interval_label_node_name) |
| 4624 |
at (0,0) |
| 4625 |
{ |
| 4626 |
\@@_make_ref:NN |
| 4627 |
\l_@@_ref_text |
| 4628 |
\l_@@_label_text |
| 4629 |
}; |
| 4630 |
\group_end: |
| 4631 |
\endpgfscope |
| 4632 |
} |
| 4633 |
% \end{macrocode} |
| 4634 |
% \end{macro} |
| 4635 |
% |
| 4636 |
% |
| 4637 |
% |
| 4638 |
% \subsection{Text} |
| 4639 |
% |
| 4640 |
% \begin{macro}{\@@_text_user:Omm} |
| 4641 |
% Place text. This macro will be made available as \cs{timecharttext} inside the \env{timechart} environment. |
| 4642 |
% \begin{arguments} |
| 4643 |
% \item PGF keys under \key{/timechart/} to apply. |
| 4644 |
% \item Year at which to place text. |
| 4645 |
% \item Text. |
| 4646 |
% \end{arguments} |
| 4647 |
% \begin{macrocode} |
| 4648 |
\NewDocumentCommand{\@@_text_user:Omm}{ O{} m m } |
| 4649 |
{ |
| 4650 |
\str_if_empty:nF{#3}{ |
| 4651 |
\group_begin: |
| 4652 |
\pgfmathsetmacro{\l_@@_text_x}{yeartox(#2)} |
| 4653 |
% \end{macrocode} |
| 4654 |
% Process keys supplied locally and retrieve initially needed keys. |
| 4655 |
% \begin{macrocode} |
| 4656 |
\pgfqkeys{/timechart}{ |
| 4657 |
#1, |
| 4658 |
tolerance~start/.get=\l_@@_start_tolerance_pgf, |
| 4659 |
tolerance~finish/.get=\l_@@_finish_tolerance_pgf, |
| 4660 |
} |
| 4661 |
\@@_if_x_in_bounds:nT{\l_@@_text_x} |
| 4662 |
{ |
| 4663 |
% \end{macrocode} |
| 4664 |
% Retrieve other needed keys. |
| 4665 |
% \begin{macrocode} |
| 4666 |
\pgfqkeys{/timechart}{ |
| 4667 |
ref/.get=\l_@@_ref_text, |
| 4668 |
text~node~name/.get=\l_@@_node_name_text, |
| 4669 |
text~baseline/.get=\l_@@_text_baseline_pgf, |
| 4670 |
} |
| 4671 |
% \end{macrocode} |
| 4672 |
% Shift to the correct vertical coordinate and place the text. |
| 4673 |
% \begin{macrocode} |
| 4674 |
\pgftransformshift{ |
| 4675 |
\pgfpoint{0}{\l_@@_current_y} |
| 4676 |
} |
| 4677 |
\pgfinterruptboundingbox |
| 4678 |
\group_begin: |
| 4679 |
\pgftransformshift{ |
| 4680 |
\pgfpoint{\l_@@_text_x}{\l_@@_text_baseline_pgf} |
| 4681 |
} |
| 4682 |
\cs_set:Npn\l_@@_text{#3} |
| 4683 |
\int_case:nn {\l_@@_text_pos_int} |
| 4684 |
{ |
| 4685 |
{0}{ \cs_set:Npn\l_@@_node_anchor_text{base~east} } |
| 4686 |
{1}{ \cs_set:Npn\l_@@_node_anchor_text{base} } |
| 4687 |
{2}{ \cs_set:Npn\l_@@_node_anchor_text{base~west} } |
| 4688 |
} |
| 4689 |
\node[/timechart/text,anchor=\l_@@_node_anchor_text] |
| 4690 |
(\l_@@_node_name_text) |
| 4691 |
at (0,0) |
| 4692 |
{ |
| 4693 |
\@@_make_ref:NN |
| 4694 |
\l_@@_ref_text |
| 4695 |
\l_@@_text |
| 4696 |
}; |
| 4697 |
\group_end: |
| 4698 |
\endpgfinterruptboundingbox |
| 4699 |
} |
| 4700 |
\group_end: |
| 4701 |
} |
| 4702 |
% \end{macrocode} |
| 4703 |
% Since the text itself does not affect the bounding box, create a space (which will handle the automatic step). |
| 4704 |
% \begin{macrocode} |
| 4705 |
\@@_space_user:O[#1] |
| 4706 |
} |
| 4707 |
% \end{macrocode} |
| 4708 |
% \end{macro} |
| 4709 |
% |
| 4710 |
% |
| 4711 |
% |
| 4712 |
% \subsection{Space} |
| 4713 |
% |
| 4714 |
% \begin{macro}{\@@_space_user:O} |
| 4715 |
% Create a vertical space as if there were an interval at the current coordinate. This macro will be made available as |
| 4716 |
% \cs{timechartspace} inside the \env{timechart} environment. |
| 4717 |
% \begin{macrocode} |
| 4718 |
\NewDocumentCommand{\@@_space_user:O}{ O{} } |
| 4719 |
{ |
| 4720 |
\group_begin: |
| 4721 |
% \end{macrocode} |
| 4722 |
% Process keys supplied locally and retreive the one needed value. |
| 4723 |
|
| 4724 |
% \begin{macrocode} |
| 4725 |
\pgfqkeys{/timechart}{ |
| 4726 |
#1, |
| 4727 |
interval~bar~thickness/.get=\l_@@_bar_thickness_pgf, |
| 4728 |
} |
| 4729 |
\pgfmathsetlengthmacro{\l_@@_bar_half_thickness_pgf} |
| 4730 |
{ .5*\l_@@_bar_thickness_pgf } |
| 4731 |
% \end{macrocode} |
| 4732 |
% Shift to the correct vertical coordinate and create the space. |
| 4733 |
% \begin{macrocode} |
| 4734 |
\pgftransformshift{ |
| 4735 |
\pgfpoint{0}{\l_@@_current_y} |
| 4736 |
} |
| 4737 |
\pgfpathmoveto{ |
| 4738 |
\pgfpoint{0}{-\l_@@_bar_half_thickness_pgf} |
| 4739 |
} |
| 4740 |
\pgfpathmoveto{ |
| 4741 |
\pgfpoint{0}{\l_@@_bar_half_thickness_pgf} |
| 4742 |
} |
| 4743 |
\pgfusepath{discard} |
| 4744 |
\group_end: |
| 4745 |
\bool_if:NT\l_@@_autostep_bool{ |
| 4746 |
\@@_step_y_user:O |
| 4747 |
} |
| 4748 |
} |
| 4749 |
% \end{macrocode} |
| 4750 |
% \end{macro} |
| 4751 |
% |
| 4752 |
% |
| 4753 |
% |
| 4754 |
% \subsection{Legends} |
| 4755 |
% |
| 4756 |
% \begin{macro}{\timechartlegenditem} |
| 4757 |
% Draw a bar suitable for use in a legend, applying style in \param{1}. |
| 4758 |
% \begin{macrocode} |
| 4759 |
\NewDocumentCommand{\timechartlegenditem}{ O{} } |
| 4760 |
{ |
| 4761 |
\@@_legend_aux:nn{#1}{ |
| 4762 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_start_x}{0} |
| 4763 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_finish_x} |
| 4764 |
{\l_@@_legenditem_width_pgf} |
| 4765 |
\@@_interval_solid_draw: |
| 4766 |
} |
| 4767 |
} |
| 4768 |
% \end{macrocode} |
| 4769 |
% \end{macro} |
| 4770 |
% |
| 4771 |
% \begin{macro}{\timechartlegendstartrange,\timechartlegendfinishrange} |
| 4772 |
% Draw a bar with start/finish range, suitable for use in a legend, applying style in \param{1}. |
| 4773 |
% \begin{macrocode} |
| 4774 |
\NewDocumentCommand{\timechartlegendstartrange}{ O{} } |
| 4775 |
{ |
| 4776 |
\@@_legend_aux:nn{#1}{ |
| 4777 |
\pgfmathsetlengthmacro |
| 4778 |
{\l_@@_interval_startrange_start_x}{0} |
| 4779 |
\pgfmathsetlengthmacro{\l_@@_interval_startrange_finish_x} |
| 4780 |
{\l_@@_legenditem_range_width_pgf} |
| 4781 |
\pgfmathsetlengthmacro |
| 4782 |
{\l_@@_interval_startrange_start_level_pgf}{0} |
| 4783 |
\pgfmathsetlengthmacro |
| 4784 |
{\l_@@_interval_startrange_finish_level_pgf}{1} |
| 4785 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_finish_x} |
| 4786 |
{\l_@@_legenditem_width_pgf} |
| 4787 |
\int_case:nn {\l_@@_start_range_type_int} |
| 4788 |
{ |
| 4789 |
{0}{ |
| 4790 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_start_x} |
| 4791 |
{\l_@@_legenditem_range_width_pgf} |
| 4792 |
\@@_interval_startrange_draw_pseudofade: |
| 4793 |
} |
| 4794 |
{1}{ |
| 4795 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_start_x} |
| 4796 |
{\l_@@_interval_startrange_start_x} |
| 4797 |
\pgfinterruptboundingbox |
| 4798 |
\@@_interval_finish_clip_path_none: |
| 4799 |
\@@_interval_startrange_clip_path_start: |
| 4800 |
\pgfpathclose |
| 4801 |
\pgfusepath{clip} |
| 4802 |
\endpgfinterruptboundingbox |
| 4803 |
} |
| 4804 |
} |
| 4805 |
\@@_interval_solid_draw: |
| 4806 |
} |
| 4807 |
} |
| 4808 |
\NewDocumentCommand{\timechartlegendfinishrange}{ O{} } |
| 4809 |
{ |
| 4810 |
\@@_legend_aux:nn{#1}{ |
| 4811 |
\pgfmathsetlengthmacro{\l_@@_interval_finishrange_start_x} |
| 4812 |
{ |
| 4813 |
\l_@@_legenditem_width_pgf |
| 4814 |
-\l_@@_legenditem_range_width_pgf |
| 4815 |
} |
| 4816 |
\pgfmathsetlengthmacro{\l_@@_interval_finishrange_finish_x} |
| 4817 |
{\l_@@_legenditem_width_pgf} |
| 4818 |
\pgfmathsetlengthmacro |
| 4819 |
{\l_@@_interval_finishrange_start_level_pgf}{1} |
| 4820 |
\pgfmathsetlengthmacro |
| 4821 |
{\l_@@_interval_finishrange_finish_level_pgf}{0} |
| 4822 |
\pgfmathsetlengthmacro |
| 4823 |
{\l_@@_interval_solid_start_x}{0} |
| 4824 |
\pgfmathsetlengthmacro{\l_@@_interval_finish_max_x} |
| 4825 |
{\l_@@_legenditem_width_pgf} |
| 4826 |
\int_case:nn {\l_@@_finish_range_type_int} |
| 4827 |
{ |
| 4828 |
{0}{ |
| 4829 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_finish_x} |
| 4830 |
{ |
| 4831 |
\l_@@_legenditem_width_pgf |
| 4832 |
-\l_@@_legenditem_range_width_pgf |
| 4833 |
} |
| 4834 |
\@@_interval_finishrange_draw_pseudofade: |
| 4835 |
} |
| 4836 |
{1}{ |
| 4837 |
\pgfmathsetlengthmacro{\l_@@_interval_solid_finish_x} |
| 4838 |
{\l_@@_interval_finishrange_finish_x} |
| 4839 |
\pgfinterruptboundingbox |
| 4840 |
\@@_interval_finishrange_clip_path_finish: |
| 4841 |
\@@_interval_start_clip_path_none: |
| 4842 |
\pgfpathclose |
| 4843 |
\pgfusepath{clip} |
| 4844 |
\endpgfinterruptboundingbox |
| 4845 |
} |
| 4846 |
} |
| 4847 |
\@@_interval_solid_draw: |
| 4848 |
} |
| 4849 |
} |
| 4850 |
% \end{macrocode} |
| 4851 |
% \end{macro} |
| 4852 |
% |
| 4853 |
% \begin{macro}{\@@_legend_aux:nn} |
| 4854 |
% Auxiliary command for legend items. Draw a \TikZ\ picture, applying PGF keys \param{1} under \key{/timechart/} |
| 4855 |
% and using \TikZ\ code \param{2}. |
| 4856 |
% \begin{macrocode} |
| 4857 |
\cs_new:Npn\@@_legend_aux:nn #1#2 |
| 4858 |
{ |
| 4859 |
\@@_debug:n{Legend~auxiliary} |
| 4860 |
\tikzpicture |
| 4861 |
% \end{macrocode} |
| 4862 |
% Process supplied PGF keys and retrieve only those necessary. |
| 4863 |
% \begin{macrocode} |
| 4864 |
\pgfkeys{ |
| 4865 |
/timechart/.cd, |
| 4866 |
#1, |
| 4867 |
interval~bar~thickness/.get=\l_@@_bar_thickness_pgf, |
| 4868 |
interval~bar~color/.get=\l_@@_bar_color, |
| 4869 |
interval~minimum~width/.get=\l_@@_minimum_width_pgf, |
| 4870 |
beyond~length~start/.get=\l_@@_start_beyond_length_pgf, |
| 4871 |
beyond~length~finish/.get=\l_@@_finish_beyond_length_pgf, |
| 4872 |
legend~item~width/.get=\l_@@_legenditem_width_pgf, |
| 4873 |
legend~item~range~width/.get=\l_@@_legenditem_range_width_pgf, |
| 4874 |
} |
| 4875 |
\pgfmathsetlengthmacro{\l_@@_bar_half_thickness_pgf} |
| 4876 |
{.5*\l_@@_bar_thickness_pgf} |
| 4877 |
\pgfmathsetmacro{\l_@@_start_x}{0} |
| 4878 |
\pgfmathsetmacro{\l_@@_finish_x} |
| 4879 |
{\l_@@_legenditem_width_pgf} |
| 4880 |
\pgfmathsetlengthmacro{\l_@@_start_beyond_x} |
| 4881 |
{\l_@@_start_x-\l_@@_start_beyond_length_pgf} |
| 4882 |
\pgfmathsetlengthmacro{\l_@@_finish_beyond_x} |
| 4883 |
{\l_@@_finish_x+\l_@@_finish_beyond_length_pgf} |
| 4884 |
\pgfmathsetmacro{\l_@@_current_y}{0} |
| 4885 |
% \end{macrocode} |
| 4886 |
% Ensure that the legend is `visible' from the perspective of the drawing macros. |
| 4887 |
% \begin{macrocode} |
| 4888 |
\pgfmathsetmacro{\l_@@_start_tolerance_x} |
| 4889 |
{\l_@@_start_x-10mm} |
| 4890 |
\pgfmathsetmacro{\l_@@_finish_tolerance_x} |
| 4891 |
{\l_@@_finish_x+10mm} |
| 4892 |
\pgfscope |
| 4893 |
#2 |
| 4894 |
\endpgfscope |
| 4895 |
\endtikzpicture% |
| 4896 |
} |
| 4897 |
% \end{macrocode} |
| 4898 |
% \end{macro} |
| 4899 |
% |
| 4900 |
% |
| 4901 |
% |
| 4902 |
% \begin{macrocode} |
| 4903 |
%</package> |
| 4904 |
% \end{macrocode} |
| 4905 |
% |
| 4906 |
% \end{implementation} |
| 4907 |
% |
| 4908 |
% \PrintIndex |
| 4909 |
% |
| 4910 |
% |
| 4911 |
% |
| 4912 |
% \iffalse |
| 4913 |
%<*metadriver> |
| 4914 |
\input{timechart.dtx} |
| 4915 |
%</metadriver> |
| 4916 |
% \fi |