cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width (cr, 0.8);
- *x1 = 0.15 * g->xdim;
+ *x1 = 0.10 * g->xdim;
*x2 = 0.95 * g->xdim;
*y1 = 0.10 * g->ydim;
*y2 = 0.90 * g->ydim;
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) {
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;
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) {
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 <= 20 && ydiff <= 10;
+ return xdiff <= TOOLTIP_XDIFF && ydiff <= TOOLTIP_YDIFF;
}
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;
}
}