Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example137.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 137 Horizontal Bar Chart with Upper Labels Over the Bars (negative upper-label-offset)
3 % Label: "ex:barchartupperlabelsalign"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 % sample CSV file:
9 \begin{filecontents}[noheader,overwrite]{profits.csv}
10 Year,Profit,Units
11 1999,"-\$4,673",12467
12 2000,"\$2,525.49",8965
13 2001,"\$1,673.52",14750
14 2002,"-\$1,320.01",14572
15 2003,"\$5,694.83",13312
16 2004,"\$-451.67",9764
17 2005,"\$6,785.20",11235
18 \end{filecontents}
19
20
21 \usepackage{databar}
22 % Load data from profits.csv file:
23 \DTLsetup{store-datum,default-name=profits}
24 \DTLread[csv-content=tex]{profits.csv}
25 \begin{document}
26 Beware of short bars!
27
28 \DTLbarchart
29 {
30 variable=\theProfit,
31 horizontal,
32 bar-width=20pt,
33 bar-label=\theYear,
34 round=0,
35 upper-bar-label=\DTLbarvalue,
36 upper-label-offset={ -\DTLbarlabeloffset },
37 upper-label-align={[left]right}
38 }
39 {profits}% database name
40 {% assignment list
41 \theYear=Year,
42 \theProfit=Profit
43 }
44 \end{document}