My goal is to have a year calendar with boxes instead of days that get filled according to the type of exercise I did that day. These exercise would be loaded from a .csv file in a format such as:
2020-01-01;2020-01-01;2020-01-03
2020-01-02; ...
where each column is a particular type of activity and I just need to add the date and the code will do the rest.
This is my work so far:
\documentclass{article}
\usepackage[a4paper, total={8.5in, 11in}]{geometry}
\usepackage{csvsimple}
\usepackage{tikz}
\usetikzlibrary{calendar}
\usepackage{pgfcalendar}
\begin{document}
\def\s{0.85} %size of box around day
\def\ss{6.3ex} %space between days
\def\ds{0.02}
\def\nexer{0.75} %1-1/number of exercise to be put into calendar
\def\cardio{red}
\def\str{blue}
\def\spo{green}
\def\oth{orange}
\begin{tikzpicture}[every calendar/.style={
week list, month label above centered, day xshift=\ss, day yshift=\ss,
day code = {
\draw (-0.5*\s,0.5*\s) -- (0.5*\s,0.5*\s) -- (0.5*\s,-0.5*\s) -- (-0.5*\s,-0.5*\s) -- cycle;
}
}]
\csvreader[no head, separator=semicolon]{cal.csv}{1=\dcar,2=\dstr,3=\dspo,4=\doth}{
\calendar
[dates=2020-01-01 to 2020-01-last]
if (equals=\dcar) {\filldraw[\cardio] (-0.5*\s+\ds,0.5*\s-\ds) --
(0.5*\s-\ds,0.5*\s-\ds) --
(0.5*\s-\ds,-0.5*\s+\s*\nexer+\ds) --
(-0.5*\s+\ds,-0.5*\s+\s*\nexer+\ds) -- cycle;}
if (equals=\dstr) {\filldraw[\str,yshift=-5] (-0.5*\s+\ds,0.5*\s-\ds) --
(0.5*\s-\ds,0.5*\s-\ds) --
(0.5*\s-\ds,-0.5*\s+\s*\nexer+\ds) --
(-0.5*\s+\ds,-0.5*\s+\s*\nexer+\ds) -- cycle;}
if (equals=\dspo) {\filldraw[\spo,yshift=-10] (-0.5*\s+\ds,0.5*\s-\ds) --
(0.5*\s-\ds,0.5*\s-\ds) --
(0.5*\s-\ds,-0.5*\s+\s*\nexer+\ds) --
(-0.5*\s+\ds,-0.5*\s+\s*\nexer+\ds) -- cycle;}
if (equals=\doth) {\filldraw[\oth,yshift=-15] (-0.5*\s+\ds,0.5*\s-\ds) --
(0.5*\s-\ds,0.5*\s-\ds) --
(0.5*\s-\ds,-0.5*\s+\s*\nexer+\ds) --
(-0.5*\s+\ds,-0.5*\s+\s*\nexer+\ds) -- cycle;};}
\end{tikzpicture}
\end{document}
I have run into couple of problems, first of all this code won't work if there are different number of days for each activity, meaning the .csv columns are not the same length. Also csvreader creates this weird effect that the calendar is "doubled" because it draws over itself and I do not know how to get rid of it.
Any help appreciated.