X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fboxplot-cairo.c;h=8448b2d6c411d41431a91a99cf561700071d2a01;hb=refs%2Fheads%2Fctables7;hp=d798bc2abbdbd6abd3f2de087d7549634fdb9539;hpb=61048d83fca0063d3205ccabe0c610346fca905b;p=pspp diff --git a/src/output/charts/boxplot-cairo.c b/src/output/charts/boxplot-cairo.c index d798bc2abb..8448b2d6c4 100644 --- a/src/output/charts/boxplot-cairo.c +++ b/src/output/charts/boxplot-cairo.c @@ -57,17 +57,17 @@ boxplot_draw_box (cairo_t *cr, const struct xrchart_geometry *geom, const double box_right = box_centre + box_width / 2.0; - double box_bottom ; - double box_top ; - double bottom_whisker ; - double top_whisker ; + double box_bottom; + double box_top; + double bottom_whisker; + double top_whisker; box_whisker_whiskers (bw, whisker); box_whisker_hinges (bw, hinge); - box_bottom = geom->axis[SCALE_ORDINATE].data_min + (hinge[0] - geom->axis[SCALE_ORDINATE].min ) * geom->axis[SCALE_ORDINATE].scale; + box_bottom = geom->axis[SCALE_ORDINATE].data_min + (hinge[0] - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale; - box_top = geom->axis[SCALE_ORDINATE].data_min + (hinge[2] - geom->axis[SCALE_ORDINATE].min ) * geom->axis[SCALE_ORDINATE].scale; + box_top = geom->axis[SCALE_ORDINATE].data_min + (hinge[2] - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale; bottom_whisker = geom->axis[SCALE_ORDINATE].data_min + (whisker[0] - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale; @@ -107,20 +107,23 @@ boxplot_draw_box (cairo_t *cr, const struct xrchart_geometry *geom, cairo_stroke (cr); /* Draw top whisker */ - cairo_move_to (cr, box_left, top_whisker); - cairo_line_to (cr, box_right, top_whisker); - cairo_stroke (cr); + if (! isnan (top_whisker)) + { + cairo_move_to (cr, box_left, top_whisker); + cairo_line_to (cr, box_right, top_whisker); + cairo_stroke (cr); + } - /* Draw centre line. - (bottom half) */ - if (! isnan (whisker[0])) + /* Draw centre line. */ + if (! isnan (bottom_whisker) && ! isnan (box_bottom)) { + /* (bottom half) */ cairo_move_to (cr, box_centre, bottom_whisker); cairo_line_to (cr, box_centre, box_bottom); cairo_stroke (cr); } - if (! isnan (whisker[1])) + if (! isnan (top_whisker) && ! isnan (box_top)) { /* (top half) */ cairo_move_to (cr, box_centre, top_whisker); @@ -142,15 +145,17 @@ boxplot_draw_box (cairo_t *cr, const struct xrchart_geometry *geom, } void -xrchart_draw_boxplot (const struct chart_item *chart_item, cairo_t *cr, +xrchart_draw_boxplot (const struct chart *chart, cairo_t *cr, struct xrchart_geometry *geom) { - const struct boxplot *boxplot = to_boxplot (chart_item); + const struct boxplot *boxplot = to_boxplot (chart); double box_width; size_t i; - xrchart_write_yscale (cr, geom, boxplot->y_min, boxplot->y_max); - xrchart_write_title (cr, geom, "%s", chart_item->title); + if (! xrchart_write_yscale (cr, geom, boxplot->y_min, boxplot->y_max)) + return; + + xrchart_write_title (cr, geom, "%s", chart->title); box_width = (geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min) / boxplot->n_boxes / 2.0; for (i = 0; i < boxplot->n_boxes; i++)