Finish first version of document generation
This commit is contained in:
@@ -2,3 +2,6 @@ FROM alpine:3.19
|
||||
|
||||
RUN apk update && apk upgrade
|
||||
RUN apk add make texlive texmf-dist-pictures
|
||||
RUN apk add texmf-dist-fontsextra
|
||||
RUN apk add texmf-dist-latexextra
|
||||
|
||||
|
||||
170
res/report.tex
Normal file
170
res/report.tex
Normal file
@@ -0,0 +1,170 @@
|
||||
\documentclass{article}
|
||||
|
||||
% Packages necessary for common.tex
|
||||
\usepackage{amsmath}
|
||||
\usepackage{pgfplots}
|
||||
\pgfplotsset{compat=newest}
|
||||
|
||||
% Other packages
|
||||
\usepackage[a4paper, total={12cm, 25cm}]{geometry}
|
||||
\usepackage{float}
|
||||
\usepackage{calc}
|
||||
\usepackage{ifthen}
|
||||
\usepackage{tikz}
|
||||
\usepackage[l3]{csvsimple}
|
||||
\usepackage{subcaption}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%% Set common options %%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\input{../lib/latex-common/common.tex}
|
||||
\pgfplotsset{colorscheme/rocket}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%% Define Custom Commands %%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\newcommand{\slice}[6]{
|
||||
\pgfmathparse{0.5*#1+0.5*#2}
|
||||
\let\midangle\pgfmathresult
|
||||
|
||||
% slice
|
||||
\fill[thick,color=#5] (0,0) -- (#1:1) arc (#1:#2+1:1) -- (0,0);
|
||||
|
||||
% outer label
|
||||
\node[label=\midangle:#4] at (\midangle:1) {};
|
||||
|
||||
% inner label
|
||||
\pgfmathparse{min((#2-#1-10)/110*(-0.3),0)}
|
||||
\let\temp\pgfmathresult
|
||||
\pgfmathparse{max(\temp,-0.5) + 0.8}
|
||||
\let\innerpos\pgfmathresult
|
||||
\node[color=#6] at (\midangle:\innerpos) {#3};
|
||||
}
|
||||
|
||||
\newcounter{pieElem}
|
||||
\newcounter{pieSliceA}
|
||||
\newcounter{pieSliceB}
|
||||
\newcommand{\pie}[1]{
|
||||
% Count elements
|
||||
\setcounter{pieElem}{0}%
|
||||
\foreach\pieElem in {#1}{\stepcounter{pieElem}}%
|
||||
\edef\numElements{\arabic{pieElem}}
|
||||
|
||||
% Draw pie chart
|
||||
\setcounter{pieSliceA}{0}%
|
||||
\setcounter{pieSliceB}{0}%
|
||||
\foreach \xi/\t [count=\xk from 0] in {#1} {
|
||||
% Get colors
|
||||
\pgfmathparse{1000 / (\numElements - 1) * \xk}
|
||||
\extractcolormapcolor{pieColor\xk}{\pgfmathresult}
|
||||
\pgfmathparse{(\xk / \numElements < 0.5)*1000}
|
||||
\extractcolormapcolor{pieTextColor\xk}{\pgfmathresult}
|
||||
|
||||
% Draw slice
|
||||
\setcounter{pieSliceA}{\thepieSliceB}
|
||||
\addtocounter{pieSliceB}{\xi}
|
||||
\slice{\thepieSliceA/100*360}{\thepieSliceB/100*360}{\xi\%}{\t}{pieColor\xk}{pieTextColor\xk}
|
||||
}
|
||||
}
|
||||
|
||||
\newcommand{\csvPie}[1]{
|
||||
% Count elements
|
||||
\setcounter{pieElem}{0}%
|
||||
\csvreader[head to column names]{#1}{}{%
|
||||
\stepcounter{pieElem}
|
||||
}
|
||||
\edef\numElements{\arabic{pieElem}}
|
||||
|
||||
% Draw pie chart
|
||||
\setcounter{pieElem}{0}%
|
||||
\setcounter{pieSliceA}{0}%
|
||||
\setcounter{pieSliceB}{0}%
|
||||
\csvreader[head to column names]{#1}{}{%
|
||||
% Get colors
|
||||
\pgfmathparse{1000 / (\numElements - 1) * \thepieElem}
|
||||
\extractcolormapcolor{pieColor\thepieElem}{\pgfmathresult}
|
||||
\pgfmathparse{(\thepieElem / \numElements < 0.5)*1000}
|
||||
\extractcolormapcolor{pieTextColor\thepieElem}{\pgfmathresult}
|
||||
|
||||
% Draw slice
|
||||
\setcounter{pieSliceA}{\thepieSliceB}
|
||||
\addtocounter{pieSliceB}{\value}
|
||||
\slice{\thepieSliceA/100*360}{\thepieSliceB/100*360}{\value\%}{\category}
|
||||
{pieColor\thepieElem}{pieTextColor\thepieElem}
|
||||
|
||||
\stepcounter{pieElem}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%% Actual Document %%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\title{Expense Report\vspace{-1cm}}
|
||||
\author{}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
\vspace{1cm}
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
|
||||
\begin{tikzpicture}[scale=3]
|
||||
\csvPie{category_overview.csv}
|
||||
\end{tikzpicture}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
|
||||
\begin{subfigure}[t]{\textwidth}
|
||||
\centering
|
||||
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
width=\textwidth,
|
||||
height=0.375\textwidth,
|
||||
ylabel={Net income},
|
||||
y label style={at={(-0.1,0.5)},anchor=south},
|
||||
]
|
||||
\addplot+[ybar, color=scol2, fill=scol2, line width=1pt]
|
||||
table[col sep=comma, x=t, y=value, discard if lt={value}{0}]
|
||||
{net_income.csv};
|
||||
\addplot+[ybar, color=scol0, fill=scol0, line width=1pt]
|
||||
table[col sep=comma, x=t, y=value, discard if gt={value}{0}]
|
||||
{net_income.csv};
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{subfigure}
|
||||
\begin{subfigure}[t]{\textwidth}
|
||||
\centering
|
||||
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
width=\textwidth,
|
||||
height=0.375\textwidth,
|
||||
area style,
|
||||
ylabel={Total amount},
|
||||
y label style={at={(-0.1,0.5)},anchor=south},
|
||||
]
|
||||
\addplot+[mark=none, color=scol1, line width=1pt]
|
||||
table[col sep=comma, x=t, y=value]
|
||||
{total_value.csv} \closedcycle;
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{subfigure}
|
||||
\end{figure}
|
||||
|
||||
\end{document}
|
||||
|
||||
Reference in New Issue
Block a user