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
commite539bf58f0e097b38dad2f648c535397ebc237ae (patch)
tree3c5596e29c2ed8cf302ff8266ae6ca7ad1d803ec
parent914d96e0265c44a9b80dfdfef9cd094072336278 (diff)
downloadiowatcher-e539bf58f0e097b38dad2f648c535397ebc237ae.tar.gz
Fix the line graphs for values near the edges of the graph
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--plot.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/plot.c b/plot.c
index fac59bd..536c638 100644
--- a/plot.c
+++ b/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) {