output-item: Collapse the inheritance hierarchy into a single struct.
[pspp] / src / output / charts / piechart-cairo.c
index bd0452ca3bfe8ae9ea55e2b2449458b44b192d70..6c43670806696888896b689de4f5350a8069a3f4 100644 (file)
@@ -46,10 +46,10 @@ draw_segment(cairo_t *cr,
 }
 
 void
-xrchart_draw_piechart (const struct chart_item *chart_item, cairo_t *cr,
+xrchart_draw_piechart (const struct chart *chart, cairo_t *cr,
                        struct xrchart_geometry *geom)
 {
-  const struct piechart *pie = to_piechart (chart_item);
+  const struct piechart *pie = to_piechart (chart);
   double total_magnitude;
   double left_label, right_label;
   double centre_x, centre_y;
@@ -66,10 +66,7 @@ xrchart_draw_piechart (const struct chart_item *chart_item, cairo_t *cr,
   radius = MIN (5.0 / 12.0 * (geom->axis[SCALE_ORDINATE].data_max - geom->axis[SCALE_ORDINATE].data_min),
                 1.0 / 4.0 * (geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ORDINATE].data_min));
 
-  radius = MIN (5.0 / 12.0 * (geom->axis[SCALE_ORDINATE].data_max - geom->axis[SCALE_ORDINATE].data_min),
-                1.0 / 4.0 * (geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ORDINATE].data_min));
-
-  xrchart_write_title (cr, geom, "%s", chart_item_get_title (chart_item));
+  xrchart_write_title (cr, geom, "%s", chart_get_title (chart));
 
   total_magnitude = 0.0;
   for (i = 0; i < pie->n_slices; i++)
@@ -78,7 +75,7 @@ xrchart_draw_piechart (const struct chart_item *chart_item, cairo_t *cr,
 
   /* Draw the segments */
   angle = 0.0;
-  for (i = 0; i < pie->n_slices ; ++i )
+  for (i = 0; i < pie->n_slices ; ++i)
     {
       const double segment_angle =
        pie->slices[i].magnitude / total_magnitude * 2 * M_PI ;
@@ -99,7 +96,7 @@ xrchart_draw_piechart (const struct chart_item *chart_item, cairo_t *cr,
      obscure them.
    */
   angle = 0.0;
-  for (i = 0; i < pie->n_slices ; ++i )
+  for (i = 0; i < pie->n_slices ; ++i)
     {
       const double segment_angle =
        pie->slices[i].magnitude / total_magnitude * 2 * M_PI ;
@@ -110,7 +107,7 @@ xrchart_draw_piechart (const struct chart_item *chart_item, cairo_t *cr,
       const double label_y = centre_y +
        radius * sin (angle + segment_angle/2.0);
 
-      if ( label_x < centre_x )
+      if (label_x < centre_x)
        {
           cairo_move_to (cr, label_x, label_y);
           cairo_line_to (cr, left_label, label_y);