X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=graph.c;h=837211dacebdb4f47defcc6e5b02ce9149c0b25c;hp=a0f1b056d696c6f979c9154c77e521812ea4c34a;hb=5aec66804d2a6d60aee8d973680c69b13c1d34a3;hpb=9ede9c9c00f5457564677833cc44d436b7c936c4 diff --git a/graph.c b/graph.c index a0f1b056..837211da 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; @@ -519,6 +525,15 @@ void line_graph_draw(struct graph *g, cairo_t *cr) minx = find_xy_value(g, getx, mindouble); maxx = find_xy_value(g, getx, maxdouble); miny = find_xy_value(g, gety, mindouble); + + /* + * Start graphs at zero, unless we have a value below. Otherwise + * it's hard to visually compare the read and write graph, since + * the lowest valued one will be the floor of the graph view. + */ + if (miny > 0) + miny = 0; + maxy = find_xy_value(g, gety, maxdouble); if (fabs(maxx - minx) < 1e-20 || fabs(maxy - miny) < 1e-20) { @@ -836,7 +851,7 @@ static int xy_match(struct xyvalue *xy, int x, int y) int xdiff = abs(xy->gx - x); int ydiff = abs(xy->gy - y); - return xdiff <= 20 && ydiff <= 10; + return xdiff <= 10 && ydiff <= 10; } const char *graph_find_tooltip(struct graph *g, int x, int y)