Skip to main content

17  Timelines

library(rtemis.draw)

draw_gantt() draws one horizontal bar per task, positioned by start and end and grouped into rows by label. The chart is built by @rtemis/draw’s Gantt builder, which rtemislive’s execution timeline also uses, and each bar is an ECharts custom series item. With height unset, the chart takes 20 pixels per task row plus 96 pixels, at least 220.

The input is a data frame with label, start, and end columns. Repeated label values put several bars on the same row:

tasks <- data.frame(
  label = c("read", "preprocess", "tune", "tune", "train", "evaluate"),
  start = c(0, 140, 420, 420, 1500, 2100),
  end = c(120, 400, 1480, 1180, 2050, 2300),
  stage = c("io", "prep", "model", "model", "model", "eval"),
  failed = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE)
)

draw_gantt(tasks, xlab = "ms")

group names a column whose values color the bars and produce a legend, and border names a logical column whose TRUE rows get an outline without changing their fill — enough to flag failures while the fill still encodes the stage:

draw_gantt(
  tasks,
  group = "stage",
  border = "failed",
  xlab = "Elapsed (ms)",
  title = "Run timeline"
)

17.1 Absolute Time

Set axis_type = "time" for timestamps. POSIXct and Date columns are placed and labeled in UTC:

start <- as.POSIXct("2026-08-18 09:00:00", tz = "UTC")

schedule <- data.frame(
  label = c("ingest", "features", "model A", "model B", "report"),
  start = start + c(0, 900, 2700, 2700, 6300) ,
  end = start + c(840, 2600, 6200, 5400, 7200),
  team = c("data", "data", "ml", "ml", "ops")
)

draw_gantt(schedule, group = "team", axis_type = "time")

zoom = TRUE (the default) enables Shift+scroll zoom, drag-to-pan, and top-right box-zoom, undo, and reset buttons; guides = TRUE shows an axis pointer that follows the mouse. tooltip names a column to use as the bar’s tooltip text, and bar_height and bar_radius set thickness and corner radius:

tasks$detail <- paste0(tasks$label, " — ", tasks$end - tasks$start, " ms")

draw_gantt(
  tasks,
  group = "stage",
  tooltip = "detail",
  bar_height = 0.45,
  bar_radius = 4,
  xlab = "ms"
)

rtemis models carry an execution timeline of the same shape, which is plotted with this chart type; see the rtemis documentation for that.

17.2 Configuration

setup_GanttConfig() describes a timeline by its task columns:

config <- setup_GanttConfig(label = "label", start = "start", end = "end",
                            group = "stage", xlab = "ms")
draw(config, data = tasks)
© 2026 E.D. Gennatas