Closed renard closed 7 years ago
The colored bars is a good idea. Unfortunately it's not easy to implement. Sorry, I have not enough time.
@rolfn Fair enough. Meanwhile I have made small changes to achieve this goal using the following patch. This is not an one-size-fits-all but works for me. I just drop it here if someone might file it useful. Anyway if you prefer a PR let me know.
modified tikz-kalender.cls
@@ -33,6 +33,9 @@
\newcommand*\RN@tempa{}
\newcommand*\RN@tempb{}
+\newcommand*\RN@holidays{}
+\newcommand*\RN@holidays@I{}
+\newcommand*\RN@holidays@II{}
\newcommand*\RN@titleColor{dark}
\newcommand*\RN@eventColor{medium}
\newcommand*\RN@monthBGcolor{dark}
@@ -186,12 +189,48 @@
color/.estore in = \RN@eventColor
}
+\pgfkeys{%
+ /RN/.is family,
+ %
+ /RN/zones/A/.cd,
+ name/.initial = {\small\ Zone A {\tiny Besançon -- Bordeaux -- Clermont-Ferrand -- Dijon -- Grenoble -- Limoges -- Lyon -- Poitiers}},
+ style/.style = {
+ /tikz,
+ line width=2pt,
+ color=green,
+ transform canvas={xshift = -5pt},
+ },
+ %
+ /RN/zones/B/.cd,
+ name/.initial = {\small\ Zone B {\tiny Aix-Marseille -- Amiens -- Caen -- Lille -- Nancy-Metz -- Nantes -- Nice -- Orléans-Tours -- Reims -- Rennes -- Rouen -- Strasbourg}},
+ style/.style = {
+ /tikz,
+ line width=2pt,
+ color=blue,
+ transform canvas={xshift = -3pt}
+ },
+ %
+ /RN/zones/C/.cd,
+ name/.initial = {\small\ Zone C {\tiny Créteil -- Montpellier -- Paris -- Toulouse -- Versailles}},
+ style/.style = {
+ /tikz,
+ line width=2pt,
+ color=red,
+ transform canvas={xshift = -1pt}
+ },
+}
+
+\newcommand{\square}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0) rectangle (0.2cm,0.2cm);}}%
+
\newcommand\RN@formatTitle[3]{%
\raisebox{-.3\height}{\parbox[b]{#1}{%
\color{\RN@titleColor}%
- \makebox[0pt][l]{\RN@yearFont#2}\hfill
- \RN@titleFont#3\hfill\mbox{}%
- }}%
+ \makebox[0pt][l]{\RN@yearFont#2}\hfill%
+ \RN@titleFont#3\hfill\mbox{}\small\\%
+ \square{green}\pgfkeysvalueof{/RN/zones/A/name}\hfill%
+ \square{blue}\pgfkeysvalueof{/RN/zones/B/name}\hfill%
+ \square{red}\pgfkeysvalueof{/RN/zones/C/name}\hfill%
+ }}
}
\newcommand*\RN@formatDayNb[1]{%
\RN@dayNbFont#1\hspace{50\RN@xunit}%
@@ -269,7 +308,7 @@
\pgfcalendarifdate{#1}{Monday}{\@tempdima=\RN@eventwidthS}{}%
\fi
\protected@edef\@tempa{\noexpand\@ifundefined{pgf@sh@ns@cal-#1}{}{%
- \noexpand\node[anchor=south west,inner sep=0pt] at (cal-#1.south east){%
+ \noexpand\node[anchor=south west,inner sep=0pt,transform canvas={xshift = -6pt}] at (cal-#1.south east){%
\noexpand\RN@formatEvent{\the\@tempdima}{#2}};}%
}%
\expandafter\gdef\csname event@#1\endcsname{#2}%
@@ -288,6 +327,36 @@
}
\let\RN@event@ii@orig=\RN@event@ii
+\newcommand\RN@lineholiday[3]{%
+ \edef\@tempa{%
+ \noexpand\draw [/RN/zones/#2/style,#3] (cal-#1.north east) -- (cal-#1.south east);%
+ }%
+ \pgfcalendarifdate{#1}{at most=06-last}{%
+ \expandafter\g@addto@macro\expandafter\RN@holidays@I\expandafter{\@tempa}%
+ }{%
+ \expandafter\g@addto@macro\expandafter\RN@holidays@II\expandafter{\@tempa}%
+ }%
+}
+
+\newcommand*\holidays[3]{%
+ \@ifnextchar[{\RN@holidays@i{#1}{#2}{#3}}{\RN@holidays@i{#1}{#2}{#3}[]}%
+}
+
+\newcommand*\RN@holidays@i{}%
+\def\RN@holidays@i#1#2#3[#4]{%
+ \edef\@tempa{%
+ \noexpand\calendar[dates=#2 to #3,
+ day code={
+ \noexpand\RN@lineholiday{%
+ \noexpand\pgfcalendarcurrentyear-\noexpand\pgfcalendarcurrentmonth-\noexpand\pgfcalendarcurrentday%
+ }{#1}{#4}
+ }];
+ }%
+ %
+ \expandafter\g@addto@macro\expandafter\RN@holidays\expandafter{\@tempa}%
+}
+
+
\newcommand\RN@makeKalender[2]{%
\sbox\RN@tempbox{%
\begin{tikzpicture}[every day/.style={anchor=north}]%
@@ -326,6 +395,8 @@
}%
];%
\pgfcalendarifdate{#1}{at most=06-last}{\RN@events@I}{\RN@events@II}%
+ \RN@holidays%
+ \pgfcalendarifdate{#1}{at most=06-last}{\RN@holidays@I}{\RN@holidays@II}%
\end{tikzpicture}%
}%
\parbox[c][\RN@calheight]{\RN@calwidth}{%
The holidays input is done:
% noel
\holidays{A}{\year-01-01}{\year-01-02}
\holidays{B}{\year-01-01}{\year-01-02}
\holidays{C}{\year-01-01}{\year-01-02}
% hiver
\holidays{A}{\year-02-19}{\year-03-05}
\holidays{B}{\year-02-12}{\year-02-26}
\holidays{C}{\year-02-05}{\year-02-19}
% printemps
\holidays{A}{\year-04-16}{\year-04-30}
\holidays{B}{\year-04-09}{\year-04-23}
\holidays{C}{\year-04-02}{\year-04-16}
% ete
\holidays{A}{\year-07-09}{\year-09-03}
\holidays{B}{\year-07-09}{\year-09-03}
\holidays{C}{\year-07-09}{\year-09-03}
% Toussaint
\holidays{A}{\year-10-22}{\year-11-05}
\holidays{B}{\year-10-22}{\year-11-05}
\holidays{C}{\year-10-22}{\year-11-05}
% Noel
\holidays{A}{\year-12-24}{\year-12-31}
\holidays{B}{\year-12-24}{\year-12-31}
\holidays{C}{\year-12-24}{\year-12-31}
\endinput
Only a short hint. You should not use absolute length like "-5pt". For vertically length use multiples of \RN@yunit and for horizontal length multiples of \RN@xunit.
This project is AWESOME. Now it's very easy to create calendars.
Anyway is it possible to ass a function to specify date ranges for holidays. The following is a very good example of what I am looking for:
Thanks in advance.
Edit: I just saw the
period
command can do the job. Meanwhile is it possible to add something to just draw a small bar like in the given picture instead of filling the whole days?TIA