pivot-table: Change the default format to omit empty rows and columns.
[pspp] / src / language / stats / crosstabs.q
index a772034f64c36bdc08e2fc683c7e322dc1193bde..8c1fe5ba2fe505595212d81fa873288f2d2f5065 100644 (file)
@@ -782,10 +782,11 @@ postcalc (struct crosstabs_proc *proc)
         }
       if (proc->barchart)
         {
-          const struct variable **vars = xcalloc (xt->n_vars, sizeof *vars);
-          for (size_t i = 0; i < xt->n_vars; i++)
+          int n_vars = (xt->n_vars > 2 ? 2 : xt->n_vars);
+          const struct variable **vars = xcalloc (n_vars, sizeof *vars);
+          for (size_t i = 0; i < n_vars; i++)
             vars[i] = xt->vars[i].var;
-          chart_item_submit (barchart_create (vars, xt->n_vars, _("Count"),
+          chart_item_submit (barchart_create (vars, n_vars, _("Count"),
                                               false,
                                               xt->entries, xt->n_entries));
           free (vars);
@@ -1246,7 +1247,6 @@ create_crosstab_table (struct crosstabs_proc *proc, struct crosstabulation *xt,
     pivot_value_new_user_text_nocopy (ds_steal_cstr (&title)),
     "Crosstabulation");
   pivot_table_set_weight_format (table, &proc->weight_format);
-  table->omit_empty = true;
 
   struct pivot_dimension *statistics = pivot_dimension_create (
     table, PIVOT_AXIS_ROW, N_("Statistics"));
@@ -1286,7 +1286,6 @@ create_chisq_table (struct crosstabulation *xt)
 {
   struct pivot_table *chisq = pivot_table_create (N_("Chi-Square Tests"));
   pivot_table_set_weight_format (chisq, &xt->weight_format);
-  chisq->omit_empty = true;
 
   pivot_dimension_create (
     chisq, PIVOT_AXIS_ROW, N_("Statistics"),
@@ -1317,7 +1316,6 @@ create_sym_table (struct crosstabulation *xt)
 {
   struct pivot_table *sym = pivot_table_create (N_("Symmetric Measures"));
   pivot_table_set_weight_format (sym, &xt->weight_format);
-  sym->omit_empty = true;
 
   pivot_dimension_create (
     sym, PIVOT_AXIS_COLUMN, N_("Values"),
@@ -1357,12 +1355,12 @@ create_risk_table (struct crosstabulation *xt,
 {
   struct pivot_table *risk = pivot_table_create (N_("Risk Estimate"));
   pivot_table_set_weight_format (risk, &xt->weight_format);
-  risk->omit_empty = true;
 
   struct pivot_dimension *values = pivot_dimension_create (
     risk, PIVOT_AXIS_COLUMN, N_("Values"),
     N_("Value"), PIVOT_RC_OTHER);
   pivot_category_create_group (
+  /* xgettext:no-c-format */
     values->root, N_("95% Confidence Interval"),
     N_("Lower"), PIVOT_RC_OTHER,
     N_("Upper"), PIVOT_RC_OTHER);
@@ -1403,7 +1401,6 @@ create_direct_table (struct crosstabulation *xt)
 {
   struct pivot_table *direct = pivot_table_create (N_("Directional Measures"));
   pivot_table_set_weight_format (direct, &xt->weight_format);
-  direct->omit_empty = true;
 
   pivot_dimension_create (
     direct, PIVOT_AXIS_COLUMN, N_("Values"),