# Gantt chart with milliseconds as input

I want to create a diagram very similar to a Gantt chart. But it is in face run times from a workflow execution and they can be from milliseconds up to weeks...

I am looking at pgfgant but I am not really sure how to give my times. My first thought was to jsut use the milliseconds like this:

\begin{ganttchart}{1}{1530176220-1530175200}
\ganttbar{fooer}{0}{1530175800-1530175200} \\
\ganttbar{foo2bar}{1530175800-1530175200}{1530176220-1530175200} \\
\end{ganttchart}


But this gives: ! Dimension too large., it seems to me like the other supported formats deals with year-month-day, but I also need all the way down to milliseconds pretty much. Can I still use the pgfgantt package in some clever way?

• How would you like the output to look? Some kind of log scale? Otherwise the millisecond entries would be too small to be seen and/or the week-long entries would be too large to fit on the page. Jun 29, 2018 at 11:48
• Well I want to scale the entire picture. If there are things that take weeks then the entire scale would be weeks if it is milliseconds then the entire scale would be in milliseconds. If there are both then of crourse milliseconds will be nothing compared to weeks... Jun 29, 2018 at 11:55

One possible solution in case the numbers are too big is to make them smaller. In the example below the milliseconds are given starting from a predefined time (hh:mm) and divided by 100 (i.e., the unit is 0.1 second). The title list is given in seconds.

For display on the chart the timestamp is (very rudimentary) constructed by printing the number of seconds after the starting time and adding a leading zero if necessary. Of course this computation can be improved by considering minutes, hours, leap seconds etc.

Note that the new command is initially not expanded to prevent the awakening of the Black LaTeX Sorcerer of Doom and Enigmatic Errors.

MWE:

\documentclass{standalone}
\usepackage{pgfgantt}
\newcommand{\showtimestamp}[2]{#1:\pgfmathparse{#2<10?"0":{},#2}\pgfmathresult}
\begin{document}

\begin{ganttchart}{1}{50}
\gantttitle{Thursday 8:36am}{50} \\
\gantttitlelist[
title list options=%
{var=\y, evaluate=\y as \x using "\noexpand\showtimestamp{8:36}{\y}"}
]{0,...,4}{10} \\
\ganttbar{fooer}{2.0}{8.0} \\
\ganttbar{foo2bar}{8.0}{12.2} \\
\ganttbar{baz}{25.0}{40.0}
\end{ganttchart}

\end{document}


Partial result:

• Hm I beginning to realise that the Gantt chart is divided into a given number of pieces and blocks has to start and stop at such a piece. That's the case right? Then I guess I would have to do a bunch of rounding. Have to thinkg about whether that is a problem in practice... Jun 29, 2018 at 14:09
• That's how it works indeed. Note that you don't have to round yourself, pgfgantt will truncate the values automatically (e.g., the 12.2 in my example is drawn at position 12). Jun 29, 2018 at 14:25