gfio: get rid of invisible data
authorStephen M. Cameron <stephenmcameron@gmail.com>
Wed, 7 Mar 2012 18:37:25 +0000 (19:37 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Mar 2012 18:37:25 +0000 (19:37 +0100)
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 <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
gfio.c
graph.c

diff --git a/gfio.c b/gfio.c
index 4707034998b7bc5058bd62d9ae2495589f11c049..787c40f5ed2654c557439e53ef2e155766760e4b 100644 (file)
--- 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 663fe38035b033b74e4455e118af159e4f6c5f15..d3fcb8dbbcdd02d11373508878e3eaf341c98500 100644 (file)
--- 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)