Boxplot: Do not attempt to draw whiskers if they are not defined
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 16 Feb 2016 11:35:17 +0000 (12:35 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 16 Feb 2016 13:47:10 +0000 (14:47 +0100)
src/output/charts/boxplot-cairo.c

index a35b277b8cfa97154399b7a4f9018acfa07c7886..d798bc2abbdbd6abd3f2de087d7549634fdb9539 100644 (file)
@@ -113,14 +113,20 @@ boxplot_draw_box (cairo_t *cr, const struct xrchart_geometry *geom,
 
   /* Draw centre line.
      (bottom half) */
-  cairo_move_to (cr, box_centre, bottom_whisker);
-  cairo_line_to (cr, box_centre, box_bottom);
-  cairo_stroke (cr);
+  if (! isnan (whisker[0]))
+    {
+      cairo_move_to (cr, box_centre, bottom_whisker);
+      cairo_line_to (cr, box_centre, box_bottom);
+      cairo_stroke (cr);
+    }
 
-  /* (top half) */
-  cairo_move_to (cr, box_centre, top_whisker);
-  cairo_line_to (cr, box_centre, box_top);
-  cairo_stroke (cr);
+  if (! isnan (whisker[1]))
+    {
+      /* (top half) */
+      cairo_move_to (cr, box_centre, top_whisker);
+      cairo_line_to (cr, box_centre, box_top);
+      cairo_stroke (cr);
+    }
 
   outliers = box_whisker_outliers (bw);
   for (ll = ll_head (outliers);