1

I am using the Tikz chronology package from Levi Wiseman. Specifically, I have used the code presented here and added some own commands in order to avoid rotation, etc. However, I would like to add vertical lines connecting each event date with the respective event tag, e.g. a line connecting "35" and "Clearing Shares". Your help is highly appreciated.

Screenshot

\documentclass[11pt]{article}
\usepackage{chronology}

%\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
%\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
%\newlength{\xstart}\newlength{\xstop}%
%\newlength{\unit}\newlength{\timelinewidth}%
%\newsavebox{\timelinebox}%

\renewenvironment{chronology}[5][5]{%
  \setcounter{step}{#1}%
  \setcounter{yearstart}{#2}\setcounter{yearstop}{#3}%
  \setcounter{deltayears}{\theyearstop-\theyearstart}%
  \setlength{\unit}{#4}%
  \setlength{\timelinewidth}{#5}%
  \pgfmathsetcounter{stepstart}%
    {\theyearstart+\thestep-mod(\theyearstart,\thestep)}%
  \pgfmathsetcounter{stepstop}{\theyearstop-mod(\theyearstop,\thestep)}%
  \addtocounter{step}{\thestepstart}%
  \begin{lrbox}{\timelinebox}%
    \begin{tikzpicture}[baseline={(current bounding box.north)}]%
      \draw [|->] (0,0) -- (\thedeltayears*\unit+\unit, 0);%
      \foreach \x in {1,...,\thedeltayears}%
        \draw[xshift=\x*\unit] (0,-.1\unit) -- (0,.1\unit);%
      \addtocounter{deltayears}{1}%
      \foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
        \pgfmathsetlength\xstop{(\x-\theyearstart)*\unit}%
        \draw[xshift=\xstop] (0,-.3\unit) -- (0,.3\unit);%
        \node at (\xstop,0) [below=.2\unit] {\x};}%
}
{%
    \end{tikzpicture}%
  \end{lrbox}%
  \raisebox{2ex}{\resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}}}%
\renewcommand{\event}[3][e]{%
  \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
    \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
      (\xstart,-.2\unit) rectangle%
      node[opacity=1,rotate=45,right=.5\unit] {#3} (\xstop,.2\unit);%
}%

\newcommand{\action}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=red,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0,right=.5\unit] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=red,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,right=-2.0\unit,above=.0\unit] {#3} (\xstop,.2\unit);%
    \fi}%

\newcommand{\multirowevent}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=black,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0,right=.5\unit] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,right=-2.0\unit,above=.9\unit] {#3} (\xstop,.2\unit);%
    \fi}%

\newcommand{\agm}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=black,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0,right=.5\unit] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,right=-2.0\unit,below=1.0\unit] {#3} (\xstop,.2\unit);%
    \fi}%

\begin{document}
    \begin{figure}[htbp]\centering
    \noindent\begin{chronology}[7]{1}{42}{3ex}{\textwidth}
        \multirowevent[5]{5}{\color{black}\parbox{3cm}{\centering AGM\linebreak Announcement}}
        \multirowevent[14]{14}{\color{black}\parbox{3cm}{\centering Asking for share\linebreak registration}}
        \multirowevent[28]{28}{\color{black}\parbox{3cm}{\centering ``Starting\linebreak registration''}}
        \action[28]{35}{\color{red}Monitoring}
        \multirowevent[35]{35}{\color{black}\parbox{3cm}{\centering Clearing\linebreak Shares}}

        \agm[7]{7}{\color{black}AGM-35}
        \agm[14]{14}{\color{black}AGM-28}
        \agm[21]{21}{\color{black}AGM-21}
        \agm[28]{28}{\color{black}AGM-14}
        \agm[35]{35}{\color{black}AGM-7}
        \agm[42]{42}{\color{black}AGM}
    \end{chronology}
    \caption{\textbf{Timeline AGM registration:} ....}
        \label{fig:timeline}
    \end{figure}
\end{document}
  • 1
    I've never used chronology but I think there's something wrong in \begin{chronology}[7]{1}{42}{3ex}{\textwidth} because it doesn't compile for me. Is it correct? – Ignasi Feb 04 '15 at 10:28
  • Dear @Ignasi have you tried the example from (http://tex.stackexchange.com/questions/109382/chronology-adds-arbitrary-gaps)

    It uses more or less the same syntax, e.g. \begin{chronology}[5]{0}{30}{4ex}{\textwidth}

    – ScoobyDoo84 Feb 04 '15 at 10:35
  • I've tried now and it doesn't work although due to some other reasons. If Gonzalo's code works for you, forget my comments. – Ignasi Feb 04 '15 at 11:02
  • Let me know what is the exact error message, maybe I can help you. – ScoobyDoo84 Feb 04 '15 at 11:25
  • 1
    I've found it, your example is missing all \renewenvironment{chronology} part from Gonzalo's code. May be you already integrated it inside chronology.sty, but MiKTEX didn't do it. Now your example works for me. – Ignasi Feb 04 '15 at 11:35
  • I added the \renewenvironment{chronology} part from Gonzalo's code to my orginial post. Hope that helps. – ScoobyDoo84 Feb 04 '15 at 11:46

1 Answers1

1

With your code I could not get your results, so I've deleted all right=... nodes option in commands \agm, \action, ...

In \multirowevent, a command for drawing the vertical line between all events and date has been added.

\draw[->, shorten >=3pt] (auxnode.south) -- (\xstop,0);

You can adjust all parameters according your taste. The result looks like:

enter image description here

\documentclass[11pt]{article}
\usepackage{chronology}

\usepackage{chronology} 

%\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
%\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
%\newlength{\xstart}\newlength{\xstop}%
%\newlength{\unit}\newlength{\timelinewidth}%
%\newsavebox{\timelinebox}%

\renewenvironment{chronology}[5][5]{%
  \setcounter{step}{#1}%
  \setcounter{yearstart}{#2}\setcounter{yearstop}{#3}%
  \setcounter{deltayears}{\theyearstop-\theyearstart}%
  \setlength{\unit}{#4}%
  \setlength{\timelinewidth}{#5}%
  \pgfmathsetcounter{stepstart}%
    {\theyearstart+\thestep-mod(\theyearstart,\thestep)}%
  \pgfmathsetcounter{stepstop}{\theyearstop-mod(\theyearstop,\thestep)}%
  \addtocounter{step}{\thestepstart}%
  \begin{lrbox}{\timelinebox}%
    \begin{tikzpicture}[baseline={(current bounding box.north)}]%
      \draw [|->] (0,0) -- (\thedeltayears*\unit+\unit, 0);%
      \foreach \x in {1,...,\thedeltayears}%
        \draw[xshift=\x*\unit] (0,-.1\unit) -- (0,.1\unit);%
      \addtocounter{deltayears}{1}%
      \foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
        \pgfmathsetlength\xstop{(\x-\theyearstart)*\unit}%
        \draw[xshift=\xstop] (0,-.3\unit) -- (0,.3\unit);%
        \node at (\xstop,0) [below=.2\unit] {\x};}%
}
{%
    \end{tikzpicture}%
  \end{lrbox}%
  \raisebox{2ex}{\resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}}}%
\renewcommand{\event}[3][e]{%
  \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
    \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
      (\xstart,-.2\unit) rectangle%
      node[opacity=1,rotate=45,right=.5\unit] {#3} (\xstop,.2\unit);%
}%

\newcommand{\action}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=red,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=red,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,above=.0\unit] {#3} (\xstop,.2\unit);%
    \fi}%

\newcommand{\multirowevent}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=black,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,above=.9\unit] (auxnode) {#3} (\xstop,.2\unit);% <------ inserted nodes name
       \draw[->, shorten >=3pt] (auxnode.south) -- (\xstop,0);% <- draws a vertical line from event to date
    \fi}%

\newcommand{\agm}[3][e]{%
    \pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
    \ifx #1e%
        \draw[fill=black,draw=none,opacity=0.5]%
            (\xstop, 0) circle (.2\unit)%
            node[opacity=1,rotate=0, draw] {#3};%
    \else%
        \pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
        \draw[fill=black,draw=none,opacity=0.5,rounded corners=.2\unit]%
            (\xstart,-.2\unit) rectangle%
            node[opacity=1,rotate=0,below=1.0\unit] {#3} (\xstop,.2\unit);%
    \fi}%

\begin{document}
    \begin{figure}[htbp]\centering
    \noindent\begin{chronology}[7]{1}{42}{3ex}{\textwidth}
        \multirowevent[5]{5}{\color{black}\parbox{3cm}{\centering AGM\linebreak Announcement}}
        \multirowevent[14]{14}{\color{black}\parbox{3cm}{\centering Asking for share\linebreak registration}}
        \multirowevent[28]{28}{\color{black}\parbox{3cm}{\centering ``Starting\linebreak registration''}}
        \action[28]{35}{\color{red}Monitoring}
        \multirowevent[35]{35}{\color{black}\parbox{3cm}{\centering Clearing\linebreak Shares}}

        \agm[7]{7}{\color{black}AGM-35}
        \agm[14]{14}{\color{black}AGM-28}
        \agm[21]{21}{\color{black}AGM-21}
        \agm[28]{28}{\color{black}AGM-14}
        \agm[35]{35}{\color{black}AGM-7}
        \agm[42]{42}{\color{black}AGM}
    \end{chronology}
    \caption{\textbf{Timeline AGM registration:} ....}
        \label{fig:timeline}
    \end{figure}
\end{document}
Ignasi
  • 136,588
  • Dear Ignasi, thank you very much! Almost perfect. In case you know how to add a small white space between the \draw[->, shorten >=3pt] (auxnode.south) -- (\xstop,0); and the chronology, i.e. the timeline so that the arrow does not hit the timeline, please let me know. – ScoobyDoo84 Feb 04 '15 at 12:09
  • 1
    @ScoobyDoo84, increase shorten value or change y component of destination end (\xstop, 0). – Ignasi Feb 04 '15 at 13:16