+#define TIMELINE_BAR_HEIGHT 0.6
+
+/* Draw the given dataset as a timeline. Each (X,Y) point (potentially
+ * with a name) specifies the (start,stop) of a single timeline bar.
+ *
+ * Each independent timeline dataset in the chart is given its own
+ * vertical position, as specified by 'y_position'.
+ */
+static void
+_draw_data_timeline (acre_t *acre, acre_data_t *data, int y_position)
+{
+ unsigned i;
+ cairo_t *cr = acre->cr;
+ PangoLayout *timeline_label_layout;
+ double ignored, label_offset;
+ int labels_within_bar;
+
+ cairo_save (cr);
+
+ timeline_label_layout = _create_layout (acre, "Timeline");
+ pango_layout_set_font_description (timeline_label_layout, acre->font);
+
+ ignored = 0.0;
+ label_offset = ACRE_FONT_SIZE;
+ cairo_device_to_user_distance (cr, &ignored, &label_offset);
+
+ labels_within_bar = TIMELINE_BAR_HEIGHT / fabs (label_offset);
+
+ for (i = 0; i < data->num_points; i++) {
+ cairo_rectangle (cr,
+ data->points[i].x,
+ y_position - TIMELINE_BAR_HEIGHT / 2.0,
+ data->points[i].y - data->points[i].x,
+ TIMELINE_BAR_HEIGHT);
+
+ cairo_save (cr);
+ cairo_identity_matrix (cr);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke_preserve (cr);
+ cairo_restore (cr);
+
+ cairo_new_path (cr);
+
+ if (i <= data->num_names && data->names[i]) {
+ cairo_save (cr);
+
+ cairo_move_to (cr, data->points[i].x,
+ y_position + TIMELINE_BAR_HEIGHT / 2.0 +
+ (i % labels_within_bar) * label_offset);
+ pango_layout_set_text (timeline_label_layout, data->names[i], -1);
+ cairo_identity_matrix (cr);
+ pango_cairo_show_layout (cr, timeline_label_layout);
+
+ cairo_restore (cr);
+ } else {
+ cairo_new_path (cr);
+ }
+
+ }
+
+ _destroy_layout (timeline_label_layout);
+
+ cairo_restore (cr);
+}
+