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,11 +24,14 @@
\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{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart} \begin{barchart}
@ -27,15 +41,16 @@
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \end{minipage}
\begin{figure}[ht] \quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart} \begin{barchart}
\barc{5} \barc{5}
\barc{7} \barc{7}
\barc{3} \barc{3}
\end{barchart} \end{barchart}
\end{figure} \end{minipage}
\end{quote} \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}.
@ -49,13 +64,11 @@ The only arguments that are mandatory is the bar value. The charts can be change
\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,6 +78,8 @@ 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{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart}[step = 2] \begin{barchart}[step = 2]
@ -74,18 +89,21 @@ Each bar can be customized to your liking. This can be done using \texttt{color}
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \end{minipage}
\begin{figure}[ht] \quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[step = 2] \begin{barchart}[step = 2]
\barc[color=yellow!60]{5} \barc[color=yellow!60]{5}
\barc[color=orange!60]{7} \barc[color=orange!60]{7}
\barc[color=cyan!60]{3} \barc[color=cyan!60]{3}
\end{barchart} \end{barchart}
\end{figure} \end{minipage}
\end{quote} \end{center}
\texttt{width} changes the width of each bar: \texttt{width} changes the width of each bar:
\begin{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart}[step = 2] \begin{barchart}[step = 2]
@ -96,18 +114,22 @@ Each bar can be customized to your liking. This can be done using \texttt{color}
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \end{minipage}
\begin{figure}[ht] \quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[step = 2] \begin{barchart}[step = 2]
\barc[width=40pt]{5} \barc[width=40pt]{5}
\barc[width=30pt]{7} \barc[width=30pt]{7}
\barc[width=50pt]{3} \barc[width=50pt]{3}
\barc[width=20pt]{3} \barc[width=20pt]{3}
\end{barchart} \end{barchart}
\end{figure} \end{minipage}
\end{quote} \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{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart}[steps = {1,3,5,7,10}] \begin{barchart}[steps = {1,3,5,7,10}]
@ -117,17 +139,21 @@ Using less than \texttt{20pt} is not recommended. Instead of using pre-defined s
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \end{minipage}
\begin{figure}[ht] \quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart}[steps = {1,3,5,7,10}] \begin{barchart}[steps = {1,3,5,7,10}]
\barc{5} \barc{5}
\barc{7} \barc{7}
\barc{3} \barc{3}
\end{barchart} \end{barchart}
\end{figure} \end{minipage}
\end{quote} \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{center}
\begin{minipage}[l][][c]{0.45\linewidth}
\begin{quote}\small \begin{quote}\small
\begin{verbatim} \begin{verbatim}
\begin{barchart} \begin{barchart}
@ -137,23 +163,254 @@ Using less than \texttt{20pt} is not recommended. Instead of using pre-defined s
\end{barchart} \end{barchart}
\end{verbatim} \end{verbatim}
\end{quote} \end{quote}
\begin{quote}\small \end{minipage}
\begin{figure}[ht] \quad
\begin{minipage}[r][][c]{0.45\linewidth}
\begin{barchart} \begin{barchart}
\barc{5} \barc{5}
\barc[plain=true]{7} \barc[plain=true]{7}
\barc[plain=true]{3} \barc[plain=true]{3}
\end{barchart} \end{barchart}
\end{figure} \end{minipage}
\end{quote} \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}