+ const int stride = MAX (1, h_axis->n_dimensions);
+
+ /* Below, we're going to iterate through the dimensions. Each dimension
+ occupies one or more rows in the heading. 'top_row' is the top row of
+ these (and 'top_row + d->label_depth - 1' is the bottom row). */
+ int top_row = 0;
+
+ /* We're going to iterate through dimensions and the rows that label them
+ from top to bottom (from outer to inner dimensions). As we move downward,
+ we start drawing vertical rules to separate categories and groups. After
+ we start drawing a vertical rule in a particular horizontal position, it
+ continues until the bottom of the heading. vrules[pos] indicates whether,
+ in our current row, we have already started drawing a vertical rule in
+ horizontal position 'pos'. (There are n_columns + 1 horizontal positions.
+ We allocate all of them for convenience below but only the inner n_columns
+ - 1 of them really matter.)
+
+ Here's an example that shows how vertical rules continue all the way
+ downward:
+
+ +-----------------------------------------------------+ __
+ | bbbb | |
+ +-----------------+-----------------+-----------------+ |dimension "bbbb"
+ | bbbb1 | bbbb2 | bbbb3 | _|
+ +-----------------+-----------------+-----------------+ __
+ | aaaa | aaaa | aaaa | |
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+ |dimension "aaaa"
+ |aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3| _|
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+
+ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+ | | | | | | | | | |
+ 0 1 2 3 4 5 6 7 8 9
+ |___________________vrules[] indexes__________________|
+
+ Our data structures are more naturally iterated from bottom to top (inner
+ to outer dimensions). A previous version of this code actually worked
+ like that, but it didn't draw all of the vertical lines correctly as shown
+ above. It ended up rendering the above heading much like shown below,
+ which isn't what users expect. The "aaaa" label really needs to be shown
+ three times for clarity:
+
+ +-----------------------------------------------------+
+ | bbbb |
+ +-----------------+-----------------+-----------------+
+ | bbbb1 | bbbb2 | bbbb3 |
+ +-----------------+-----------------+-----------------+
+ | | aaaa | |
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ |aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|
+ +-----+-----+-----+-----+-----+-----+-----+-----+-----+
+ */
+ bool *vrules = XCALLOC (n_columns + 1, bool);
+ vrules[0] = vrules[n_columns] = true;
+ for (int dim_index = h_axis->n_dimensions; --dim_index >= 0; )