+ const struct pivot_axis *layer_axis = &pt->axes[PIVOT_AXIS_LAYER];
+ struct table_item_layers *layers = NULL;
+ for (size_t i = 0; i < layer_axis->n_dimensions; i++)
+ {
+ const struct pivot_dimension *d = layer_axis->dimensions[i];
+ if (d->n_leaves)
+ {
+ if (!layers)
+ {
+ layers = xzalloc (sizeof *layers);
+ layers->style = area_style_override (
+ NULL, &pt->areas[PIVOT_AREA_LAYERS], NULL, NULL);
+ layers->layers = xnmalloc (layer_axis->n_dimensions,
+ sizeof *layers->layers);
+ }
+
+ const struct pivot_value *name
+ = d->data_leaves[layer_indexes[i]]->name;
+ struct table_item_layer *layer = &layers->layers[layers->n_layers++];
+ struct string s = DS_EMPTY_INITIALIZER;
+ pivot_value_format_body (name, pt->show_values, pt->show_variables,
+ &s);
+ layer->content = ds_steal_cstr (&s);
+ layer->n_footnotes = name->n_footnotes;
+ layer->footnotes = xnmalloc (layer->n_footnotes,
+ sizeof *layer->footnotes);
+ for (size_t i = 0; i < name->n_footnotes; i++)
+ layer->footnotes[i] = footnotes[name->footnotes[i]->idx];
+ }
+ }
+ if (layers)