From: Stephen M. Cameron Date: Wed, 7 Mar 2012 13:47:38 +0000 (+0100) Subject: gfio: make empty graph show grid lines, not "No good data" X-Git-Tag: gfio-0.1~233 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=cae0872709f690086f896f7327e136c7db7ba567 gfio: make empty graph show grid lines, not "No good data" This is done by adding a bit of "invisible data" to the graph at the beginning. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- diff --git a/gfio.c b/gfio.c index e190d89a..b1caa678 100644 --- a/gfio.c +++ b/gfio.c @@ -121,6 +121,18 @@ struct gfio_client { GtkWidget *disk_util_frame; }; +static void add_invisible_data(struct graph *g) +{ + /* + * This puts some invisible data into a graph so that it will + * initially have some grid lines instead of "No good data" + */ + graph_add_label(g, "invisible"); + graph_set_color(g, "invisible", INVISIBLE_COLOR, 0.0, 0.7); + graph_add_xy_data(g, "invisible", 0.0, 0.0); + graph_add_xy_data(g, "invisible", 1.0, 100.0); +} + static void setup_iops_graph(struct gui *ui) { if (ui->iops_graph) @@ -134,6 +146,7 @@ static void setup_iops_graph(struct gui *ui) graph_add_label(ui->iops_graph, "Write IOPS"); graph_set_color(ui->iops_graph, "Read IOPS", 0.7, 0.0, 0.0); graph_set_color(ui->iops_graph, "Write IOPS", 0.0, 0.0, 0.7); + add_invisible_data(ui->iops_graph); } static void setup_bandwidth_graph(struct gui *ui) @@ -149,6 +162,7 @@ static void setup_bandwidth_graph(struct gui *ui) graph_add_label(ui->bandwidth_graph, "Write Bandwidth"); graph_set_color(ui->bandwidth_graph, "Read Bandwidth", 0.7, 0.0, 0.0); graph_set_color(ui->bandwidth_graph, "Write Bandwidth", 0.0, 0.0, 0.7); + add_invisible_data(ui->bandwidth_graph); } static void clear_ui_info(struct gui *ui) diff --git a/graph.c b/graph.c index 1cd2caab..d97da595 100644 --- a/graph.c +++ b/graph.c @@ -431,6 +431,8 @@ void line_graph_draw(struct graph *g, cairo_t *cr) cairo_set_line_width(cr, 1.5); for (i = g->labels; i; i = i->next) { first = 1; + if (i->r < 0) /* invisible data */ + continue; cairo_set_source_rgb(cr, i->r, i->g, i->b); for (j = i->values; j; j = j->next) { tx = ((getx(j) - minx) / (maxx - minx)) * (x2 - x1) + x1; @@ -588,16 +590,22 @@ void graph_set_color(struct graph *gr, const char *label, struct graph_label *i; double r, g, b; - r = fabs(red); - g = fabs(green); - b = fabs(blue); - - if (r > 1.0) - r = 1.0; - if (g > 1.0) - g = 1.0; - if (b > 1.0) - b =1.0; + if (red < 0.0) { /* invisible color */ + r = -1.0; + g = -1.0; + b = -1.0; + } else { + r = fabs(red); + g = fabs(green); + b = fabs(blue); + + if (r > 1.0) + r = 1.0; + if (g > 1.0) + g = 1.0; + if (b > 1.0) + b =1.0; + } for (i = gr->labels; i; i = i->next) if (strcmp(i->label, label) == 0) { diff --git a/graph.h b/graph.h index 8202fe63..872e60ea 100644 --- a/graph.h +++ b/graph.h @@ -3,6 +3,8 @@ struct graph; +#define INVISIBLE_COLOR (-1.0) + struct graph *graph_new(unsigned int xdim, unsigned int ydim, const char *font); void bar_graph_draw(struct graph *g, cairo_t *cr); void line_graph_draw(struct graph *g, cairo_t *cr);