% This file is embedded in datatool-user.pdf version 3.4.2 2025-11-06
% Example 140 Bar Chart With Rotated Tick Labels
% Label: "ex:barchartrotateyticlabels"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
% sample CSV file:
\begin{filecontents}[noheader,overwrite]{profits.csv}
Year,Profit,Units
1999,"-\$4,673",12467
2000,"\$2,525.49",8965
2001,"\$1,673.52",14750
2002,"-\$1,320.01",14572
2003,"\$5,694.83",13312
2004,"\$-451.67",9764
2005,"\$6,785.20",11235
\end{filecontents}


\usepackage{databar}
% Load data from profits.csv file:
\DTLsetup{store-datum,default-name=profits}
\DTLread[csv-content=tex]{profits.csv} 
\begin{document}
\renewcommand{\DTLbardisplayYticklabel}[1]{\rotatebox{45}{#1}}
\DTLbarchart
{
 variable=\theProfit,
 horizontal,
 color-style=single,
 max-depth=-5000,
 max=10000,
 bar-width=20pt,bar-gap=0.5,
 axes,y-ticks,y-tick-gap=1000,
 ylabel={Loss / Profits},
 ylabel-position=zero,
 bar-label={\theYear},
 upper-bar-label={\DTLbarvalue},
 round=2,
 y-tick-round=0,
 ytic-label-align={right,top}
}
{profits}% database
 {% assignment list
 \theYear=Year,
 \theProfit=Profit
} 
\end{document}
