struct hmap cells;
struct hmap domains[N_CTDTS];
- enum pivot_axis_type slabels_position;
+ enum pivot_axis_type slabels_axis;
bool slabels_visible;
enum ctables_label_position row_labels;
struct msg_location *loc = lex_ofs_location (ctx->lexer, start_ofs,
lex_ofs (ctx->lexer) - 1);
- printf ("add %s\n", ctables_summary_function_name (function));
add_summary_spec (sub, function, percentile, label, formatp, loc, sv);
free (label);
msg_location_destroy (loc);
struct merge_item
{
- size_t tiebreaker;
const struct ctables_summary_spec_set *set;
size_t ofs;
};
&cell->axes[a].cvs[k].value));
if (k == nest->n - 1)
{
- if (a == t->summary_axis)
+ if (a == t->slabels_axis)
{
if (label)
parent = pivot_category_create_group__ (parent, label);
- const struct ctables_summary_spec_set *specs = &nest->specs[cell->sv];
+ const struct ctables_summary_spec_set *specs = &t->summary_specs;
for (size_t m = 0; m < specs->n; m++)
{
int leaf = pivot_category_create_leaf (
}
else
{
- /* This assertion is true as long as the summary axis
- is the axis where the summaries are displayed. */
- assert (label);
-
- prev_leaf = pivot_category_create_leaf (parent, label);
+ prev_leaf = pivot_category_create_leaf (parent, label ? label : pivot_value_new_user_text ("text", SIZE_MAX));
}
break;
}
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[3];
- size_t n_dindexes = 0;
-
- 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)
- 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);
}
for (size_t j = 0; j < stack->n; j++)
{
const struct ctables_nest *nest = &stack->nests[j];
- if (!nest->n)
- continue;
-
- for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
- {
- items[n_left] = (struct merge_item) {
- .tiebreaker = n_left,
- .set = &nest->specs[sv]
- };
- n_left++;
- }
+ if (nest->n)
+ for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
+ items[n_left++] = (struct merge_item) { .set = &nest->specs[sv] };
}
while (n_left > 0)
if (merge_item_compare_3way (&items[j], &min) < 0)
min = items[j];
- /* XXX Add to 'merged' */
if (merged->n >= merged->allocated)
merged->specs = x2nrealloc (merged->specs, &merged->allocated,
sizeof *merged->specs);
}
}
+#if 0
for (size_t j = 0; j < merged->n; j++)
printf ("%s\n", ctables_summary_function_name (merged->specs[j].function));
printf ("\n");
}
}
+#endif
}
struct casereader *input = casereader_create_filter_weight (proc_open (ds),
for (size_t i = 0; i < ct->n_tables; i++)
{
struct ctables_table *t = ct->tables[i];
- if (t->summary_axis == t->slabels_position)
+ if (t->summary_axis == t->slabels_axis)
ctables_table_output_same_axis (ct, ct->tables[i]);
else
ctables_table_output_different_axis (ct, ct->tables[i]);
struct ctables_table *t = xmalloc (sizeof *t);
*t = (struct ctables_table) {
.cells = HMAP_INITIALIZER (t->cells),
- .slabels_position = PIVOT_AXIS_COLUMN,
+ .slabels_axis = PIVOT_AXIS_COLUMN,
.slabels_visible = true,
.row_labels = CTLP_NORMAL,
.col_labels = CTLP_NORMAL,
{
if (lex_match_id (lexer, "SLABELS"))
{
- while (lex_token (lexer) != T_SLASH)
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "POSITION"))
{
lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "COLUMN"))
- t->slabels_position = PIVOT_AXIS_COLUMN;
+ t->slabels_axis = PIVOT_AXIS_COLUMN;
else if (lex_match_id (lexer, "ROW"))
- t->slabels_position = PIVOT_AXIS_ROW;
+ t->slabels_axis = PIVOT_AXIS_ROW;
else if (lex_match_id (lexer, "LAYER"))
- t->slabels_position = PIVOT_AXIS_LAYER;
+ t->slabels_axis = PIVOT_AXIS_LAYER;
else
{
lex_error_expecting (lexer, "COLUMN", "ROW", "LAYER");
}
else if (lex_match_id (lexer, "CLABELS"))
{
- while (lex_token (lexer) != T_SLASH)
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "AUTO"))
t->row_labels = t->col_labels = CTLP_NORMAL;