aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2012-08-27 12:53:51 -0400
committerChris Mason <chris.mason@oracle.com>2012-08-27 12:53:51 -0400
commit49d17e16fc977e01baf018f7c4af20e6b594fbba (patch)
treebe2e0962d6f6663fea226bd729d37a29d2de758c
parenteef996bc011bf6e57b8954a27f6b5dd3abaaf405 (diff)
downloadblktrace-49d17e16fc977e01baf018f7c4af20e6b594fbba.tar.gz
iowatcher: Fix the line graphs for values near the edges of the graph
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--iowatcher/plot.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/iowatcher/plot.c b/iowatcher/plot.c
index fac59bd..536c638 100644
--- a/iowatcher/plot.c
+++ b/iowatcher/plot.c
@@ -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) {