}
}
-static double UNUSED
+static double
ctables_summary_value (const struct ctables_cell *cell,
union ctables_summary *s,
const struct ctables_summary_spec *ss)
}
static void
-ctables_table_output_different_axis (struct ctables *ct, struct ctables_table *t)
+ctables_table_output (struct ctables *ct, struct ctables_table *t)
{
struct pivot_table *pt = pivot_table_create__ (
(t->title
pivot_table_set_caption (
pt, pivot_value_new_user_text (t->corner, SIZE_MAX));
- if (t->summary_axis != t->slabels_axis)
+ bool summary_dimension = t->summary_axis != t->slabels_axis;
+ if (summary_dimension)
{
struct pivot_dimension *d = pivot_dimension_create (
pt, t->slabels_axis, N_("Summaries"));
d->root, pivot_value_new_text (specs->specs[i].label));
}
- if (t->clabels_example)
+ bool categories_dimension = t->clabels_example != NULL;
+ if (categories_dimension)
{
struct pivot_dimension *d = pivot_dimension_create (
pt, t->label_axis[t->clabels_from_axis],
{
const struct ctables_summary_spec_set *specs = &t->summary_specs;
for (size_t m = 0; m < specs->n; m++)
- pivot_category_create_leaf (
- parent, pivot_value_new_text (specs->specs[m].label));
+ {
+ int leaf = pivot_category_create_leaf (
+ parent, pivot_value_new_text (specs->specs[m].label));
+ if (!m)
+ prev_leaf = leaf;
+ }
}
else
{
NOT_REACHED ();
if (k == n_levels - 1)
- pivot_category_create_leaf (parent, label);
+ prev_leaf = pivot_category_create_leaf (parent, label);
else
groups[k] = pivot_category_create_group__ (parent, label);
}
free (sorted);
free (groups);
}
+
+ struct ctables_cell *cell;
+ HMAP_FOR_EACH (cell, struct ctables_cell, node, &t->cells)
+ {
+ if (cell->hide)
+ continue;
+
+ const struct ctables_nest *nest = &t->stacks[t->summary_axis].nests[cell->axes[t->summary_axis].stack_idx];
+ const struct ctables_summary_spec_set *specs = &nest->specs[cell->sv];
+ for (size_t j = 0; j < specs->n; j++)
+ {
+ size_t dindexes[5];
+ size_t n_dindexes = 0;
+
+ if (summary_dimension)
+ dindexes[n_dindexes++] = specs->specs[j].axis_idx;
+
+ if (categories_dimension)
+ {
+ dindexes[n_dindexes++] = 0; /* XXX */
+ }
+
+ for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
+ if (d[a])
+ {
+ int leaf = cell->axes[a].leaf;
+ if (a == t->summary_axis && !summary_dimension)
+ leaf += j;
+ dindexes[n_dindexes++] = leaf;
+ }
+
+ double d = ctables_summary_value (cell, &cell->summaries[j], &specs->specs[j]);
+ struct pivot_value *value = pivot_value_new_number (d);
+ value->numeric.format = specs->specs[j].format;
+ pivot_table_put (pt, dindexes, n_dindexes, value);
+ }
+ }
+
pivot_table_submit (pt);
}
if (t->clabels_example)
ctables_sort_clabels_values (t);
- ctables_table_output_different_axis (ct, ct->tables[i]);
+ ctables_table_output (ct, ct->tables[i]);
}
return proc_commit (ds);
}