initial release version

This commit is contained in:
Drudoo 2014-05-23 20:31:59 +02:00
parent bb67feb91e
commit faab7a8c12
3 changed files with 361 additions and 104 deletions

View File

@ -105,7 +105,7 @@
\node[label={[label distance=0.5cm,text depth=-1ex,rotate=-90]right:\barclabel}] at ($($\barcmin*(0,\barcrange/\barcrange) + (\barcwidth+\barcpos-5mm,0)$)!0.5!(\barcpos,1.5) $) {}; \node[label={[label distance=0.5cm,text depth=-1ex,rotate=-90]right:\barclabel}] at ($($\barcmin*(0,\barcrange/\barcrange) + (\barcwidth+\barcpos-5mm,0)$)!0.5!(\barcpos,1.5) $) {};
} }
\ifthenelse{\equal{\barcrotation}{false}}{true}{ \ifthenelse{\equal{\barcrotation}{false}}{true}{
\node[label={[label distance=0.5cm,text depth=-1ex,rotate=-45]right:\barclabel}] at ($($\barcmin*(0,\barcrange/\barcrange) + (\barcwidth+\barcpos-10mm,0)$)!0.5!(\barcpos,1) $) {}; \node[label={[label distance=0.5cm,text depth=-1ex,rotate=-45]right:\barclabel}] at ($($\barcmin*(0,\barcrange/\barcrange) + (\barcwidth+\barcpos-15mm,0)$)!0.5!(\barcpos,1) $) {};
} }
\addtolength{\barcpos}{\dimexpr(\barcwidth-20pt) \relax} \addtolength{\barcpos}{\dimexpr(\barcwidth-20pt) \relax}
@ -155,7 +155,7 @@
\ifthenelse{\equal{\barcy}{}}{}{ \ifthenelse{\equal{\barcy}{}}{}{
%\node[label={[label distance=0.5cm,align=center,text depth=-1ex,rotate=-90]left:\barcy}] at ($(-0.75,\barcmax) !0.5! (0,\barcmin)$){}; %\node[label={[label distance=0.5cm,align=center,text depth=-1ex,rotate=-90]left:\barcy}] at ($(-0.75,\barcmax) !0.5! (0,\barcmin)$){};
\node[rotate=-90] at ($(-0.75-\barcmax/100,\barcmax) !0.5! (0,\barcmin)$){\barcy}; \node[rotate=-90] at ($(-1.25-\barcmax/100,\barcmax) !0.5! (0,\barcmin)$){\barcy};
} }
\end{tikzpicture}% \end{tikzpicture}%

Binary file not shown.

View File

@ -1,10 +1,21 @@
\documentclass[]{article} \documentclass[]{article}
\usepackage{barchart} \usepackage{barchart}
\usepackage{vmargin}
\setmarginsrb { 1.0in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 0.8in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\title{\texttt{barchart}: Easy Bar Chart in \LaTeX \title{\texttt{barchart}: Easy Bar Chart in \LaTeX
\medskip\\ \medskip\\
\large Version 0.1.0 \large Version 0.1.0
} }
\author{Frederik Vanggaard} \author{Frederik Vanggaard}
\date{\today} \date{\today}
@ -13,49 +24,51 @@
\maketitle \maketitle
\section{Introduction} \section{Introduction}
\texttt{barchart} is a \LaTeX\space package for creating simple and easy to use bar-chart. The package is heavily inspired by \texttt{bchart} by Tobias Kuhn. \texttt{barchart} provides an easy way to create vertical barcharts using Tikz. \texttt{barchart} is a \LaTeX\space package for creating simple and easy to use bar-chart. The package is inspired by \texttt{bchart} by Tobias Kuhn. \texttt{barchart} provides an easy way to create vertical barcharts using Tikz.
\section{Charts} \section{Charts}
\texttt{barchart} comes with a variety of customization options for both the overall chart and for each individual bar. A simple chart can be done like this: \texttt{barchart} comes with a variety of customization options for both the overall chart and for each individual bar. A simple chart can be done like this:
\begin{quote}\small
\begin{verbatim} \begin{center}
\begin{barchart} \begin{minipage}[l][][c]{0.45\linewidth}
\barc{5} \begin{quote}\small
\barc{7} \begin{verbatim}
\barc{3} \begin{barchart}
\end{barchart} \barc{5}
\end{verbatim} \barc{7}
\end{quote} \barc{3}
\begin{quote}\small \end{barchart}
\begin{figure}[ht] \end{verbatim}
\begin{barchart} \end{quote}
\barc{5} \end{minipage}
\barc{7} \quad
\barc{3} \begin{minipage}[r][][c]{0.45\linewidth}
\end{barchart} \begin{barchart}
\end{figure} \barc{5}
\end{quote} \barc{7}
\barc{3}
\end{barchart}
\end{minipage}
\end{center}
The only arguments that are mandatory is the bar value. The charts can be changed using a few simple options such as \texttt{min}, \texttt{max} and \texttt{step}. The only arguments that are mandatory is the bar value. The charts can be changed using a few simple options such as \texttt{min}, \texttt{max} and \texttt{step}.
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart}[min = 0, max = 60, step = 10, height=0.25em] \begin{barchart}[min = 0, max = 60, step = 10, height=0.25em]
\barc{30} \barc{30}
\barc{20} \barc{20}
\barc{50} \barc{50}
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \begin{quote}\small
\begin{figure}[ht]
\begin{barchart}[min = 0, max = 60, step = 10, height=0.25em] \begin{barchart}[min = 0, max = 60, step = 10, height=0.25em]
\barc{30} \barc{30}
\barc{20} \barc{20}
\barc{50} \barc{50}
\end{barchart} \end{barchart}
\end{figure}
\end{quote} \end{quote}
\texttt{height} is used to set the height of the whole chart. Omitting a height on charts with large \texttt{max} values will make the chart enormous. \texttt{height} is used to set the height of the whole chart. Omitting a height on charts with large \texttt{max} values will make the chart enormous.
@ -65,95 +78,339 @@ Each bar can be customized to your liking. This can be done using \texttt{color}
\texttt{color} changes the color of each bar like: \texttt{color} changes the color of each bar like:
\begin{quote}\small \begin{center}
\begin{verbatim} \begin{minipage}[l][][c]{0.45\linewidth}
\begin{barchart}[step = 2] \begin{quote}\small
\barc[color=yellow!60]{5} \begin{verbatim}
\barc[color=orange!60]{7} \begin{barchart}[step = 2]
\barc[color=cyan!60]{3} \barc[color=yellow!60]{5}
\end{barchart} \barc[color=orange!60]{7}
\end{verbatim} \barc[color=cyan!60]{3}
\end{quote} \end{barchart}
\begin{quote}\small \end{verbatim}
\begin{figure}[ht] \end{quote}
\begin{barchart}[step = 2] \end{minipage}
\barc[color=yellow!60]{5} \quad
\barc[color=orange!60]{7} \begin{minipage}[r][][c]{0.45\linewidth}
\barc[color=cyan!60]{3} \begin{barchart}[step = 2]
\end{barchart} \barc[color=yellow!60]{5}
\end{figure} \barc[color=orange!60]{7}
\end{quote} \barc[color=cyan!60]{3}
\end{barchart}
\end{minipage}
\end{center}
\texttt{width} changes the width of each bar: \texttt{width} changes the width of each bar:
\begin{quote}\small \begin{center}
\begin{verbatim} \begin{minipage}[l][][c]{0.45\linewidth}
\begin{barchart}[step = 2] \begin{quote}\small
\barc[width=40pt]{5} \begin{verbatim}
\barc[width=30pt]{7} \begin{barchart}[step = 2]
\barc[width=50pt]{3} \barc[width=40pt]{5}
\barc[width=20pt]{3} \barc[width=30pt]{7}
\end{barchart} \barc[width=50pt]{3}
\end{verbatim} \barc[width=20pt]{3}
\end{quote} \end{barchart}
\begin{quote}\small \end{verbatim}
\begin{figure}[ht] \end{quote}
\begin{barchart}[step = 2] \end{minipage}
\barc[width=40pt]{5} \quad
\barc[width=30pt]{7} \begin{minipage}[r][][c]{0.45\linewidth}
\barc[width=50pt]{3} \begin{barchart}[step = 2]
\barc[width=20pt]{3} \barc[width=40pt]{5}
\end{barchart} \barc[width=30pt]{7}
\end{figure} \barc[width=50pt]{3}
\end{quote} \barc[width=20pt]{3}
\end{barchart}
\end{minipage}
\end{center}
Using less than \texttt{20pt} is not recommended. Instead of using pre-defined step as the examples have shown so far, \texttt{steps} can be used. Using less than \texttt{20pt} is not recommended. Instead of using pre-defined step as the examples have shown so far, \texttt{steps} can be used.
\begin{quote}\small \begin{center}
\begin{verbatim} \begin{minipage}[l][][c]{0.45\linewidth}
\begin{barchart}[steps = {1,3,5,7,10}] \begin{quote}\small
\barc{5} \begin{verbatim}
\barc{7} \begin{barchart}[steps = {1,3,5,7,10}]
\barc{3} \barc{5}
\end{barchart} \barc{7}
\end{verbatim} \barc{3}
\end{quote} \end{barchart}
\begin{quote}\small \end{verbatim}
\begin{figure}[ht] \end{quote}
\begin{barchart}[steps = {1,3,5,7,10}] \end{minipage}
\barc{5} \quad
\barc{7} \begin{minipage}[r][][c]{0.45\linewidth}
\barc{3} \begin{barchart}[steps = {1,3,5,7,10}]
\end{barchart} \barc{5}
\end{figure} \barc{7}
\end{quote} \barc{3}
\end{barchart}
\end{minipage}
\end{center}
\texttt{plain} is a boolean which can either be \texttt{true} or \texttt{false} and removes the label on the bar. \texttt{plain} is a boolean which can either be \texttt{true} or \texttt{false} and removes the label on the bar.
\begin{quote}\small
\begin{verbatim} \begin{center}
\begin{barchart} \begin{minipage}[l][][c]{0.45\linewidth}
\barc{5} \begin{quote}\small
\barc[plain=true]{7} \begin{verbatim}
\barc[plain=true]{3} \begin{barchart}
\end{barchart} \barc{5}
\end{verbatim} \barc[plain=true]{7}
\end{quote} \barc[plain=true]{3}
\begin{quote}\small \end{barchart}
\begin{figure}[ht] \end{verbatim}
\begin{barchart} \end{quote}
\barc{5} \end{minipage}
\barc[plain=true]{7} \quad
\barc[plain=true]{3} \begin{minipage}[r][][c]{0.45\linewidth}
\end{barchart} \begin{barchart}
\end{figure} \barc{5}
\end{quote} \barc[plain=true]{7}
\barc[plain=true]{3}
\end{barchart}
\end{minipage}
\end{center}
\section{Skips} \section{Skips}
Between each bar a skip can be implemented to have more or less room. This is done using \texttt{\textbackslash barcskip\{\}}.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}
\barc{5}
\barcskip{10pt}
\barc{7}
\barcskip{20pt}
\barc{3}
\barcskip{30pt}
\barc{2}
\barcskip{-5pt}
\barc{6}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}
\barc{5}
\barcskip{10pt}
\barc{7}
\barcskip{20pt}
\barc{3}
\barcskip{30pt}
\barc{2}
\barcskip{-5pt}
\barc{6}
\end{barchart}
\end{minipage}
\end{center}
The skips can either be made with positive or negative \texttt{pt} or using default skip sizes as \texttt{\textbackslash smallskip}, \texttt{\textbackslash medskip} and \texttt{\textbackslash bigskip}.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}
\barc{5}
\smallskip
\barc{7}
\medskip
\barc{3}
\bigskip
\barc{2}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}
\barc{5}
\smallskip
\barc{7}
\medskip
\barc{3}
\bigskip
\barc{2}
\end{barchart}
\end{minipage}
\end{center}
\section{Labels} \section{Labels}
The package also include various ways of labeling the charts. Both the chart and its individual bars can be labeled.
The chart can be labeled using:
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}[label= A nice chart]
\barc{5}
\barc{7}
\barc{3}
\barc{2}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[label= A nice chart]
\barc{5}
\barc{7}
\barc{3}
\barc{2}
\end{barchart}
\end{minipage}
\end{center}
Each bar can also have their own label. These labels are positioned below the x-axis.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}[label=A nice chart]
\barc[label=Some]{5}
\barc[label=Nice]{7}
\barc[label=Labels]{3}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[label=A nice chart]
\barc[label=Some]{5}
\barc[label=Nice]{7}
\barc[label=Labels]{3}
\end{barchart}
\end{minipage}
\end{center}
These labels can also be rotated, so they are easier to read using \texttt{rotation=true}.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}
\barc[label=Some, rotation=true]{5}
\barc[label=Nice, rotation=true]{7}
\barc[label=Labels, rotation=true]{3}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}
\barc[label=Som, rotation=truee]{5}
\barc[label=Nice, rotation=true]{7}
\barc[label=Labels, rotation=true]{3}
\end{barchart}
\end{minipage}
\end{center}
\section{Scaling} \section{Scaling}
If the charts become too big or small, it is possible to scale them using \texttt{scale}.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}[scale = 0.5]
\barc{5}
\barc{7}
\barc{3}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[scale=0.5]
\barc{5}
\barc{7}
\barc{3}
\end{barchart}
\end{minipage}
\end{center}
But sometimes it is not enough to just scale the chart. Using \texttt{height} it is possible to set a fixed height of the chart.
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small
\begin{verbatim}
\begin{barchart}[min=0, max=500,
step = 100, height=0.05ex]
\barc{500}
\barc{70}
\barc{300}
\end{barchart}
\end{verbatim}
\end{quote}
\end{minipage}
\quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[min=0, max=500, step = 100, height=0.05ex]
\barc{500}
\barc{70}
\barc{300}
\end{barchart}
\end{minipage}
\end{center}
\section{Known Issues} \section{Known Issues}
When using large values for each bar, it is important to set a fixed height like:
\begin{quote}\small
\begin{verbatim}
\begin{barchart}[label= A nice chart, min=0, max=100, height=0.2ex, step=20]
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\end{barchart}
\end{verbatim}
\end{quote}
\begin{quote}\small
\begin{barchart}[label= A nice chart, min=0, max=100, height=0.2ex, step=20]
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\barc{50}
\barc{70}
\barc{30}
\barc{20}
\end{barchart}
\end{quote}
\end{document} \end{document}