From 49d17e16fc977e01baf018f7c4af20e6b594fbba Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Mon, 27 Aug 2012 12:53:51 -0400 Subject: [PATCH] iowatcher: Fix the line graphs for values near the edges of the graph Signed-off-by: Chris Mason --- iowatcher/plot.c | 13 +++++++++++-- 1 file 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) { -- 2.25.1