From 9ce9cfbd6ab2a821aa31cedf64ec3e8c0729a4fc Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Wed, 7 Mar 2012 19:37:25 +0100 Subject: [PATCH] gfio: get rid of invisible data At first the invisible data seemed like an elegant way to get reasonable graph ticks when no data was really present, but it proved to be an ugly hack that caused other problems later,e.g. when you want to cap other data so the xy graph scrolls, the invisible data kept it from scrolling, etc. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- gfio.c | 14 -------------- graph.c | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/gfio.c b/gfio.c index 47070349..787c40f5 100644 --- a/gfio.c +++ b/gfio.c @@ -121,18 +121,6 @@ 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) @@ -145,7 +133,6 @@ 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.13, 0.54, 0.13); graph_set_color(ui->iops_graph, "Write IOPS", 1.0, 0.0, 0.0); - add_invisible_data(ui->iops_graph); line_graph_set_data_count_limit(ui->iops_graph, 100); } @@ -161,7 +148,6 @@ 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.13, 0.54, 0.13); graph_set_color(ui->bandwidth_graph, "Write Bandwidth", 1.0, 0.0, 0.0); - add_invisible_data(ui->bandwidth_graph); line_graph_set_data_count_limit(ui->bandwidth_graph, 100); } diff --git a/graph.c b/graph.c index 663fe380..d3fcb8db 100644 --- a/graph.c +++ b/graph.c @@ -402,7 +402,7 @@ void line_graph_draw(struct graph *g, cairo_t *cr) double tx, ty; struct graph_label *i; struct graph_value *j; - int first = 1; + int good_data = 1, first = 1; cairo_save(cr); graph_draw_common(g, cr, &x1, &y1, &x2, &y2); @@ -413,15 +413,19 @@ void line_graph_draw(struct graph *g, cairo_t *cr) maxy = find_xy_value(g, gety, maxdouble); if (fabs(maxx - minx) < 1e-20 || fabs(maxy - miny) < 1e-20) { - draw_centered_text(g, cr, - x1 + (x2 - x1) / 2.0, - y1 + (y2 - y1) / 2.0, 20.0, "No good Data"); - return; + good_data = 0; + minx = 0.0; + miny = 0.0; + maxx = 10.0; + maxy = 100.0; } graph_draw_x_ticks(g, cr, x1, y1, x2, y2, minx, maxx, 10); graph_draw_y_ticks(g, cr, x1, y1, x2, y2, miny, maxy, 10); + if (!good_data) + goto skip_data; + cairo_set_line_width(cr, 1.5); for (i = g->labels; i; i = i->next) { first = 1; @@ -440,7 +444,10 @@ void line_graph_draw(struct graph *g, cairo_t *cr) } cairo_stroke(cr); } + +skip_data: cairo_restore(cr); + } static void gfree(void *f) -- 2.25.1