table_vline (t, rule, a, b0, b1);
}
+/* Fills row or column headings into T.
+
+ This function uses terminology and variable names for column headings, but
+ it also applies to row headings because it uses variables for the
+ differences, e.g. when for column headings it would use the H axis, it
+ instead uses 'h', which is set to H for column headings and V for row
+ headings. */
static void
compose_headings (struct table *t,
const struct pivot_axis *a_axis, enum table_axis a,
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
*/
bool *vrules = xzalloc (n_columns + 1);
+ vrules[0] = vrules[n_columns] = true;
for (int dim_index = a_axis->n_dimensions; --dim_index >= 0; )
{
const struct pivot_dimension *d = a_axis->dimensions[dim_index];
label_style, label_style_idx, c->name, footnotes,
show_values, show_variables, rotate);
- if (pivot_category_is_leaf (c) && x2 + 1 <= n_columns)
+ /* Draw all the vertical lines in our running example, other
+ than the far left and far right ones. Only the ones that
+ start in the last row of the heading are drawn with the
+ "category" style, the rest with the "dimension" style,
+ e.g. only the # below are category style:
+
+ +-----------------------------------------------------+
+ | bbbb |
+ +-----------------+-----------------+-----------------+
+ | bbbb1 | bbbb2 | bbbb3 |
+ +-----------------+-----------------+-----------------+
+ | aaaa | aaaa | aaaa |
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ |aaaa1#aaaa2#aaaa3|aaaa1#aaaa2#aaaa3|aaaa1#aaaa2#aaaa3|
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ */
+ enum pivot_border style
+ = (y1 == b_size - 1 ? cat_col_vert : dim_col_vert);
+ if (!vrules[x2])
{
- enum pivot_border style
- = (y1 == 0 && a_axis->label_depth > d->label_depth
- ? dim_col_vert
- : cat_col_vert);
draw_line (t, borders, style, b, x2 + a_ofs, y1,
t->n[b] - 1);
vrules[x2] = true;
}
- if (pivot_category_is_leaf (c) && x1 > 0)
+ if (!vrules[x1])
{
- enum pivot_border style
- = (y1 == 0 && a_axis->label_depth > d->label_depth
- ? dim_col_vert
- : cat_col_vert);
draw_line (t, borders, style, b, x1 + a_ofs, y1,
t->n[b] - 1);
vrules[x1] = true;
}
}
+
+ /* Draws the horizontal lines within a dimension, that is, those
+ that separate a separating a category (or group) from its
+ parent group or dimension's label. Our running example
+ doesn't have groups but the ==== lines below show the
+ separators between categories and their dimension label:
+
+ +-----------------------------------------------------+
+ | bbbb |
+ +=================+=================+=================+
+ | bbbb1 | bbbb2 | bbbb3 |
+ +-----------------+-----------------+-----------------+
+ | aaaa | aaaa | aaaa |
+ +=====+=====+=====+=====+=====+=====+=====+=====+=====+
+ |aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ */
if (c->parent && c->parent->show_label)
draw_line (t, borders, cat_col_horz, a, y1,
x1 + a_ofs, x2 + a_ofs - 1);
show_values, show_variables, false);
}
- if (dim_index > 1)
+ /* Draw the horizontal line between dimensions, e.g. the ===== line here:
+
+ +-----------------------------------------------------+ __
+ | bbbb | |
+ +-----------------+-----------------+-----------------+ |dim "bbbb"
+ | bbbb1 | bbbb2 | bbbb3 | _|
+ +=================+=================+=================+ __
+ | aaaa | aaaa | aaaa | |
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+ |dim "aaaa"
+ |aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3| _|
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ */
+ if (dim_index != a_axis->n_dimensions - 1)
draw_line (t, borders, dim_col_horz, a, top_row, a_ofs,
t->n[a] - 1);
top_row += d->label_depth;