added automake.mk files in src/language
[pspp] / src / plot-hist.c
index 85fb3700e6985b41b7878eddeb37b046035a001b..fd1a88d8a69cfbb325723522707eaf8471ff565c 100644 (file)
 #include <gsl/gsl_histogram.h>
 #include <gsl/gsl_randist.h>
 #include <assert.h>
-
 #include "hash.h"
-
 #include "var.h"
 #include "chart.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 /* Write the legend of the chart */
 void
 histogram_write_legend(struct chart *ch, const struct normal_curve *norm)
 {
   char buf[100];
   if ( !ch )
-         return ;
+    return ;
 
   pl_savestate_r(ch->lp);
 
@@ -120,14 +121,22 @@ histogram_plot(const gsl_histogram *hist,
   
   struct chart *ch;
 
-  bins = gsl_histogram_bins(hist);
-
   ch = chart_create();
   chart_write_title(ch, _("HISTOGRAM"));
 
   chart_write_ylabel(ch, _("Frequency"));
   chart_write_xlabel(ch, factorname);
 
+  if ( ! hist ) /* If this happens, probably all values are SYSMIS */
+    {
+      chart_submit(ch);
+      return ;
+    }
+  else
+    {
+      bins = gsl_histogram_bins(hist);
+    }
+
   chart_write_yscale(ch, 0, gsl_histogram_max_val(hist), 5);
 
   for ( i = 0 ; i < bins ; ++i )