summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-03-21 13:36:46 +0100
committerJens Axboe <axboe@kernel.dk>2012-03-21 13:36:46 +0100
commit0deba507cd01601fcce4fb861b9aa6d4971dfd1a (patch)
treec0d9246c7f5eb996e5c31dd370ef8355945f7388 /graph.c
parent832fde7966f885a0c975a243596bc5b38a23c38e (diff)
downloadfio-0deba507cd01601fcce4fb861b9aa6d4971dfd1a.tar.gz
fio-0deba507cd01601fcce4fb861b9aa6d4971dfd1a.tar.bz2
graph: stop matching tooltips if X diff is too large
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/graph.c b/graph.c
index 837211da..d8f1ba45 100644
--- a/graph.c
+++ b/graph.c
@@ -846,12 +846,18 @@ int graph_contains_xy(struct graph *g, int x, int y)
return (x >= first_x && x <= last_x) && (y >= first_y && y <= last_y);
}
+/*
+ * Allowable difference to show tooltip
+ */
+#define TOOLTIP_XDIFF 10
+#define TOOLTIP_YDIFF 10
+
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 <= 10 && ydiff <= 10;
+ return xdiff <= TOOLTIP_XDIFF && ydiff <= TOOLTIP_YDIFF;
}
const char *graph_find_tooltip(struct graph *g, int x, int y)
@@ -862,9 +868,17 @@ const char *graph_find_tooltip(struct graph *g, int x, int y)
for (i = g->labels; i; i = i->next) {
for (j = i->values; j; j = j->next) {
struct xyvalue *xy = j->value;
-
- if (xy_match(xy, x - g->xoffset, y))
+ int graphx = x - g->xoffset;
+
+ /*
+ * Return match if close enough. Take advantage
+ * of the X axis being monotonically increasing,
+ * so we can break out if we exceed it.
+ */
+ if (xy_match(xy, graphx, y))
return j->tooltip;
+ else if (xy->gx - graphx > TOOLTIP_XDIFF)
+ break;
}
}