Fix bug #58664
[pspp] / src / output / cairo-chart.c
index f3accda3fb504745e4ed083ef8f21a2222b8003a..c5bffcd761c891597ec2f2b462eb9b4cac36dbbd 100644 (file)
@@ -19,7 +19,6 @@
 #include "output/cairo-chart.h"
 #include "math/chart-geometry.h"
 
-#include <assert.h>
 #include <cairo/cairo.h>
 #include <pango/pango.h>
 #include <pango/pangocairo.h>
@@ -99,8 +98,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] =
   {
@@ -309,7 +308,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);
@@ -385,12 +384,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 +406,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)
@@ -469,7 +469,7 @@ xrchart_write_legend (cairo_t *cr, const struct xrchart_geometry *geom)
   const int swatch = 20;
   const int legend_top = geom->axis[SCALE_ORDINATE].data_max;
   const int legend_bottom = legend_top -
-    (vstep * geom->n_datasets + 2 * ypad );
+    (vstep * geom->n_datasets + 2 * ypad);
 
   cairo_save (cr);
 
@@ -478,7 +478,7 @@ xrchart_write_legend (cairo_t *cr, const struct xrchart_geometry *geom)
                    legend_bottom - legend_top);
   cairo_stroke (cr);
 
-  for (i = 0 ; i < geom->n_datasets ; ++i )
+  for (i = 0 ; i < geom->n_datasets ; ++i)
     {
       const int ypos = legend_top - vstep * (i + 1);
       const int xpos = geom->legend_left + xpad;
@@ -578,10 +578,10 @@ xrchart_line(cairo_t *cr, const struct xrchart_geometry *geom,
   double x1, y1;
   double x2, y2;
 
-  if ( lim_dim == XRCHART_DIM_Y )
+  if (lim_dim == XRCHART_DIM_Y)
     {
-      x1 = ( limit1 - intercept ) / slope;
-      x2 = ( limit2 - intercept ) / slope;
+      x1 = (limit1 - intercept) / slope;
+      x2 = (limit2 - intercept) / slope;
       y1 = limit1;
       y2 = limit2;
     }