/* PSPP - a program for statistical analysis.
- Copyright (C) 2004, 2009, 2010, 2011, 2014, 2015 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2009, 2010, 2011, 2014, 2015,
+ 2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
pango_font_description_free (desc);
}
-static void
+static bool
xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom,
double smin, double smax, enum tick_orientation orient)
{
char *tick_format_string;
bool tickoversize = false;
+ if (smax == smin)
+ return false;
+
chart_get_scale (smax, smin, &lower, &interval, &ticks);
tick_format_string = chart_get_ticks_format (lower, interval, ticks, &tickscale);
pos += interval;
}
free(tick_format_string);
+
+ return true;
}
/* Set the scale for the ordinate */
-void
+bool
xrchart_write_yscale (cairo_t *cr, struct xrchart_geometry *geom,
double smin, double smax)
{
- xrchart_write_scale (cr, geom, smin, smax, SCALE_ORDINATE);
+ return xrchart_write_scale (cr, geom, smin, smax, SCALE_ORDINATE);
}
/* Set the scale for the abscissa */
-void
+bool
xrchart_write_xscale (cairo_t *cr, struct xrchart_geometry *geom,
double smin, double smax)
{
- xrchart_write_scale (cr, geom, smin, smax, SCALE_ABSCISSA);
+ return xrchart_write_scale (cr, geom, smin, smax, SCALE_ABSCISSA);
}
PRINTF_FORMAT (3, 4);
/* Set the scale for the abscissa */
-void xrchart_write_xscale (cairo_t *, struct xrchart_geometry *,
- double min, double max);
-
+bool xrchart_write_xscale (cairo_t *, struct xrchart_geometry *,
+ double min, double max) WARN_UNUSED_RESULT;
/* Set the scale for the ordinate */
-void xrchart_write_yscale (cairo_t *, struct xrchart_geometry *,
- double smin, double smax);
+bool xrchart_write_yscale (cairo_t *, struct xrchart_geometry *,
+ double smin, double smax) WARN_UNUSED_RESULT;
void xrchart_write_xlabel (cairo_t *, const struct xrchart_geometry *,
const char *label) ;
xrchart_write_ylabel (cr, geom, bc->ylabel);
xrchart_write_xlabel (cr, geom, chart_item_get_title (chart_item));
- if (bc->percent)
- xrchart_write_yscale (cr, geom, 0, bc->largest * 100.0 / bc->total_count);
- else
- xrchart_write_yscale (cr, geom, 0, bc->largest);
+ if (! xrchart_write_yscale (cr, geom, 0,
+ bc->percent ? bc->largest * 100.0 / bc->total_count : bc->largest))
+ return;
const double abscale = geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min;
const double width = abscale / (double) (bc->n_nzcats + bc->n_pcats);
double box_width;
size_t i;
- xrchart_write_yscale (cr, geom, boxplot->y_min, boxplot->y_max);
+ if (! xrchart_write_yscale (cr, geom, boxplot->y_min, boxplot->y_max))
+ return;
+
xrchart_write_title (cr, geom, "%s", chart_item->title);
box_width = (geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min) / boxplot->n_boxes / 2.0;
xrchart_write_title (cr, geom, _("Normal Q-Q Plot of %s"), chart_item->title);
xrchart_write_xlabel (cr, geom, _("Observed Value"));
xrchart_write_ylabel (cr, geom, _("Expected Normal"));
- xrchart_write_xscale (cr, geom,
+ if (! xrchart_write_xscale (cr, geom,
npp->x_lower - npp->slack,
- npp->x_upper + npp->slack);
- xrchart_write_yscale (cr, geom, npp->y_first, npp->y_last);
+ npp->x_upper + npp->slack))
+ return;
+
+ if (! xrchart_write_yscale (cr, geom, npp->y_first, npp->y_last))
+ return;
data = casereader_clone (npp->data);
for (; (c = casereader_read (data)) != NULL; case_unref (c))
xrchart_write_title (cr, geom, _("Detrended Normal Q-Q Plot of %s"), chart_item->title);
xrchart_write_xlabel (cr, geom, _("Observed Value"));
xrchart_write_ylabel (cr, geom, _("Dev from Normal"));
- xrchart_write_xscale (cr, geom, dnpp->y_min, dnpp->y_max);
- xrchart_write_yscale (cr, geom, dnpp->dns_min, dnpp->dns_max);
+ if (! xrchart_write_xscale (cr, geom, dnpp->y_min, dnpp->y_max))
+ return;
+ if (! xrchart_write_yscale (cr, geom, dnpp->dns_min, dnpp->dns_max))
+ return;
data = casereader_clone (dnpp->data);
for (; (c = casereader_read (data)) != NULL; case_unref (c))
return;
}
- xrchart_write_yscale (cr, geom, 0, gsl_histogram_max_val (h->gsl_hist));
- xrchart_write_xscale (cr, geom, gsl_histogram_min (h->gsl_hist),
- gsl_histogram_max (h->gsl_hist));
+ if (! xrchart_write_yscale (cr, geom, 0, gsl_histogram_max_val (h->gsl_hist)))
+ return;
+ if (! xrchart_write_xscale (cr, geom, gsl_histogram_min (h->gsl_hist),
+ gsl_histogram_max (h->gsl_hist)))
+ return;
/* Draw the ticks and compute if the rendered tick text is wider than the bin */
xrchart_write_xlabel (cr, geom, _("1 - Specificity"));
xrchart_write_ylabel (cr, geom, _("Sensitivity"));
- xrchart_write_xscale (cr, geom, 0, 1);
- xrchart_write_yscale (cr, geom, 0, 1);
+ if (! xrchart_write_xscale (cr, geom, 0, 1))
+ return;
+ if (! xrchart_write_yscale (cr, geom, 0, 1))
+ return;
if (rc->reference)
{
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);
+ 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_item->title);
xrchart_write_xlabel (cr, geom, spc->xlabel);
xrchart_write_ylabel (cr, geom, spc->ylabel);
else
max = fabs (min);
- xrchart_write_yscale (cr, geom, 0, max);
- xrchart_write_xscale (cr, geom, 0, rc->eval->size + 1);
+ if (! xrchart_write_yscale (cr, geom, 0, max))
+ return;
+ if (! xrchart_write_xscale (cr, geom, 0, rc->eval->size + 1))
+ return;
xrchart_vector_start (cr, geom, "");
for (i = 0 ; i < rc->eval->size; ++i)
xrchart_write_ylabel (cr, geom, _("Spread"));
- xrchart_write_xscale (cr, geom, sl->x_lower, sl->x_upper);
- xrchart_write_yscale (cr, geom, sl->y_lower, sl->y_upper);
+ if (! xrchart_write_xscale (cr, geom, sl->x_lower, sl->x_upper))
+ return;
+
+ if (! xrchart_write_yscale (cr, geom, sl->y_lower, sl->y_upper))
+ return;
for (i = 0 ; i < sl->n_data; ++i)
{