refactoring
[pspp] / src / output / charts / scatterplot-cairo.c
index 211d2d60dcdf8b2fca15713f0da53ad952f9c1ae..a6a499b868c2144dce9145ca46958970858b1b32 100644 (file)
 static const struct xrchart_colour black = {0,0,0};
 
 void
-xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
+xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr,
                          struct xrchart_geometry *geom)
 {
-  const struct scatterplot_chart *spc = to_scatterplot_chart (chart_item);
+  const struct scatterplot_chart *spc = to_scatterplot_chart (chart);
   struct casereader *data;
   struct ccase *c;
   /* While reading the cases, a list with categories of the byvar is build */
@@ -46,13 +46,15 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
   int byvar_width = 0;
   int i = 0;
   const struct xrchart_colour *colour;
-  
+
   if (spc->byvar)
     byvar_width = var_get_width (spc->byvar);
 
-  xrchart_write_xscale (cr, geom, spc->x_min, spc->x_max);
-  xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max);
-  xrchart_write_title (cr, geom, _("Scatterplot %s"), chart_item->title);
+  if (! xrchart_write_xscale (cr, geom, spc->x_min, spc->x_max))
+    return;
+  if (! xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max))
+    return;
+  xrchart_write_title (cr, geom, _("Scatterplot %s"), chart->title);
   xrchart_write_xlabel (cr, geom, spc->xlabel);
   xrchart_write_ylabel (cr, geom, spc->ylabel);
 
@@ -70,7 +72,7 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
                {
                  struct string label;
                  ds_init_empty (&label);
-                 if (var_is_value_missing (spc->byvar,val,MV_ANY))
+                 if (var_is_value_missing (spc->byvar,val))
                    ds_put_cstr (&label,"missing");
                  else
                    var_append_value_name (spc->byvar,val,&label);
@@ -97,10 +99,10 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
                             colour->red / 255.0,
                             colour->green / 255.0,
                             colour->blue / 255.0);
-    
+
       xrchart_datum (cr, geom, 0,
-                    case_data_idx (c, SP_IDX_X)->f,
-                    case_data_idx (c, SP_IDX_Y)->f);
+                    case_num_idx (c, SP_IDX_X),
+                    case_num_idx (c, SP_IDX_Y));
     }
   casereader_destroy (data);
   cairo_restore (cr);