From: Jens Axboe Date: Thu, 15 Mar 2012 09:52:38 +0000 (+0100) Subject: graph: fix bar graph min/max displays X-Git-Tag: gfio-0.1~132 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=bb39379fa3eb5e5c42c68e2e146561c49e3309f2 graph: fix bar graph min/max displays Signed-off-by: Jens Axboe --- diff --git a/graph.c b/graph.c index a0f1b056..3f2ee6af 100644 --- a/graph.c +++ b/graph.c @@ -442,7 +442,14 @@ void bar_graph_draw(struct graph *bg, cairo_t *cr) nlabels = count_labels(bg->labels); space_per_label = (x2 - x1) / (double) nlabels; + /* + * Start bars at 0 unless we have negative values, otherwise we + * present a skewed picture comparing label X and X+1. + */ mindata = find_min_data(bg->labels); + if (mindata > 0) + mindata = 0; + maxdata = find_max_data(bg->labels); if (fabs(maxdata - mindata) < 1e-20) { @@ -452,8 +459,7 @@ void bar_graph_draw(struct graph *bg, cairo_t *cr) return; } - graph_draw_y_ticks(bg, cr, x1, y1, x2, y2, mindata, maxdata, 10, 1); - + maxdata = graph_draw_y_ticks(bg, cr, x1, y1, x2, y2, mindata, maxdata, 10, 1); i = 0; for (lb = bg->labels; lb; lb = lb->next) { int nvalues;