cairo-chart: Make it clear that fabs() of integer values is intended.
[pspp] / src / output / cairo-chart.c
index 9c68eb13f88ba8356e7af18cd0918009c1acecf1..db8eb67ecf45f65625bb2df0229a8b3335d6a17e 100644 (file)
@@ -99,8 +99,8 @@ pango_layout_get_baseline (PangoLayout    *layout)
 }
 #endif
 
-/*  
-    These colours come from: 
+/*
+    These colours come from:
     http://tango.freedesktop.org/static/cvs/tango-art-tools/palettes/Tango-Palette.gpl */
 const struct xrchart_colour data_colour[XRCHART_N_COLOURS] =
   {
@@ -178,7 +178,7 @@ xrchart_label_rotate (cairo_t *cr, int horz_justify, int vert_justify,
   PangoLayout *layout;
   double x, y;
 
-  desc = pango_font_description_from_string ("sans serif");
+  desc = pango_font_description_from_string ("Sans");
   if (desc == NULL)
     {
       cairo_new_path (cr);
@@ -309,7 +309,7 @@ draw_tick_internal (cairo_t *cr, const struct xrchart_geometry *geom,
 
       if (orientation == SCALE_ABSCISSA)
        {
-         if ( rotated) 
+         if ( rotated)
            xrchart_label_rotate (cr, 'l', 'c', geom->font_size, s, -G_PI_4);
          else
            xrchart_label (cr, 'c', 't', geom->font_size, s);
@@ -352,7 +352,7 @@ xrchart_text_extents (cairo_t *cr, const struct xrchart_geometry *geom,
   int width_pango;
   int height_pango;
 
-  desc = pango_font_description_from_string ("sans serif");
+  desc = pango_font_description_from_string ("Sans");
   if (desc == NULL)
       return;
   pango_font_description_set_absolute_size (desc, geom->font_size * PANGO_SCALE);
@@ -385,12 +385,13 @@ xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom,
   tick_format_string = chart_get_ticks_format (lower, interval, ticks, &tickscale);
 
   upper = lower + interval * (ticks+1);
-   
+
   geom->axis[orient].max = upper;
   geom->axis[orient].min = lower;
-  
-  geom->axis[orient].scale = (fabs (geom->axis[orient].data_max - geom->axis[orient].data_min)
-                             / fabs (geom->axis[orient].max - geom->axis[orient].min));
+
+  struct xrchart_axis *axis = &geom->axis[orient];
+  geom->axis[orient].scale = (fabs ((double) axis->data_max - axis->data_min)
+                             / fabs (axis->max - axis->min));
 
   if (orient == SCALE_ABSCISSA)
     {
@@ -406,7 +407,7 @@ xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom,
       tickoversize = width > 0.9 *
        ((double)(geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min))/(ticks+1);
     }
-  
+
   double pos = lower;
 
   for (s = 0 ; s <= ticks; ++s)
@@ -602,3 +603,4 @@ xrchart_line(cairo_t *cr, const struct xrchart_geometry *geom,
   cairo_line_to (cr, x2, y2);
   cairo_stroke (cr);
 }
+