iowatcher: Fix the line graphs for values near the edges of the graph
authorChris Mason <chris.mason@fusionio.com>
Mon, 27 Aug 2012 16:53:51 +0000 (12:53 -0400)
committerChris Mason <chris.mason@oracle.com>
Mon, 27 Aug 2012 16:53:51 +0000 (12:53 -0400)
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
iowatcher/plot.c

index fac59bd02ec0d3eb8f0f4fd92ce55d81817929a2..536c638d94c3ca6f950ebe0a59f1766cc6239c35 100644 (file)
@@ -694,7 +694,7 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
        int printed_header = 0;
        int printed_lines = 0;
 
-       if (0 && thresh1 && thresh2)
+       if (thresh1 && thresh2)
                rolling = 0;
        else if (rolling_avg_secs)
                rolling = rolling_avg_secs;
@@ -703,7 +703,16 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
 
        for (i = 0; i < gld->stop_seconds; i++) {
                avg = rolling_avg(gld->data, i, rolling);
-               val = avg / yscale;
+               if (yscale == 0)
+                       val = 0;
+               else
+                       val = avg / yscale;
+
+               if (val > graph_height)
+                       val = graph_height;
+               if (val < 0)
+                       val = 0;
+
                x = (double)i / xscale;
                if (!thresh1 && !thresh2) {