output: Make chart geometry the responsibility of the output driver.
[pspp] / src / output / charts / np-plot.c
index df91add5d5d70b62f27dcf34094540e0629a9251..dba20bac56a7dfdd40c377ae389e7d5a0fc1db7c 100644 (file)
@@ -121,60 +121,54 @@ dnp_plot_create (const struct np *np, const struct casereader *reader,
 }
 
 static void
-np_plot_chart_draw (const struct chart *chart, plPlotter *lp)
+np_plot_chart_draw (const struct chart *chart, plPlotter *lp,
+                    struct chart_geometry *geom)
 {
   const struct np_plot_chart *npp = (struct np_plot_chart *) chart;
-  struct chart_geometry geom;
   struct casereader *data;
   struct ccase *c;
 
-  chart_geometry_init (lp, &geom);
-  chart_write_title (lp, &geom, _("Normal Q-Q Plot of %s"), npp->label);
-  chart_write_xlabel (lp, &geom, _("Observed Value"));
-  chart_write_ylabel (lp, &geom, _("Expected Normal"));
-  chart_write_xscale (lp, &geom,
+  chart_write_title (lp, geom, _("Normal Q-Q Plot of %s"), npp->label);
+  chart_write_xlabel (lp, geom, _("Observed Value"));
+  chart_write_ylabel (lp, geom, _("Expected Normal"));
+  chart_write_xscale (lp, geom,
                       npp->x_lower - npp->slack,
                       npp->x_upper + npp->slack, 5);
-  chart_write_yscale (lp, &geom, npp->y_first, npp->y_last, 5);
+  chart_write_yscale (lp, geom, npp->y_first, npp->y_last, 5);
 
   data = casereader_clone (npp->data);
   for (; (c = casereader_read (data)) != NULL; case_unref (c))
-    chart_datum (lp, &geom, 0,
+    chart_datum (lp, geom, 0,
                  case_data_idx (c, NP_IDX_Y)->f,
                  case_data_idx (c, NP_IDX_NS)->f);
   casereader_destroy (data);
 
-  chart_line (lp, &geom, npp->slope, npp->intercept,
+  chart_line (lp, geom, npp->slope, npp->intercept,
               npp->y_first, npp->y_last, CHART_DIM_Y);
-
-  chart_geometry_free (lp);
 }
 
 static void
-dnp_plot_chart_draw (const struct chart *chart, plPlotter *lp)
+dnp_plot_chart_draw (const struct chart *chart, plPlotter *lp,
+                     struct chart_geometry *geom)
 {
   const struct np_plot_chart *dnpp = (struct np_plot_chart *) chart;
-  struct chart_geometry geom;
   struct casereader *data;
   struct ccase *c;
 
-  chart_geometry_init (lp, &geom);
-  chart_write_title (lp, &geom, _("Detrended Normal Q-Q Plot of %s"),
+  chart_write_title (lp, geom, _("Detrended Normal Q-Q Plot of %s"),
                      dnpp->label);
-  chart_write_xlabel (lp, &geom, _("Observed Value"));
-  chart_write_ylabel (lp, &geom, _("Dev from Normal"));
-  chart_write_xscale (lp, &geom, dnpp->y_min, dnpp->y_max, 5);
-  chart_write_yscale (lp, &geom, dnpp->dns_min, dnpp->dns_max, 5);
+  chart_write_xlabel (lp, geom, _("Observed Value"));
+  chart_write_ylabel (lp, geom, _("Dev from Normal"));
+  chart_write_xscale (lp, geom, dnpp->y_min, dnpp->y_max, 5);
+  chart_write_yscale (lp, geom, dnpp->dns_min, dnpp->dns_max, 5);
 
   data = casereader_clone (dnpp->data);
   for (; (c = casereader_read (data)) != NULL; case_unref (c))
-    chart_datum (lp, &geom, 0, case_data_idx (c, NP_IDX_Y)->f,
+    chart_datum (lp, geom, 0, case_data_idx (c, NP_IDX_Y)->f,
                  case_data_idx (c, NP_IDX_DNS)->f);
   casereader_destroy (data);
 
-  chart_line (lp, &geom, 0, 0, dnpp->y_min, dnpp->y_max, CHART_DIM_X);
-
-  chart_geometry_free (lp);
+  chart_line (lp, geom, 0, 0, dnpp->y_min, dnpp->y_max, CHART_DIM_X);
 }
 
 static void