X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fbarchart-cairo.c;h=c3cc2f3ca14225c29875e5a8d28b6031345e371d;hb=c2c8832630ad1619cd8e1769da3a294a1d35d1ed;hp=397715ff386d38884ce4ca9838ec39a1bb648c74;hpb=0df9cdd3df66caf4353128feff3008289cda8115;p=pspp diff --git a/src/output/charts/barchart-cairo.c b/src/output/charts/barchart-cairo.c index 397715ff38..c3cc2f3ca1 100644 --- a/src/output/charts/barchart-cairo.c +++ b/src/output/charts/barchart-cairo.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2015 Free Software Foundation, Inc. + Copyright (C) 2015, 2016 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 @@ -67,7 +67,10 @@ xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr, xrchart_write_ylabel (cr, geom, bc->ylabel); xrchart_write_xlabel (cr, geom, chart_item_get_title (chart_item)); - xrchart_write_yscale (cr, geom, 0, bc->largest); + 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); 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); @@ -122,6 +125,8 @@ xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr, for (i = 0; i < bc->n_nzcats; i++) { double height = geom->axis[SCALE_ORDINATE].scale * bc->cats[i]->count; + if (bc->percent) + height *= 100.0 / bc->total_count ; if (prev && !value_equal (prev, &bc->cats[i]->values[0], bc->widths[0])) {