diff options
Diffstat (limited to 'src/graph.c')
-rw-r--r-- | src/graph.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/graph.c b/src/graph.c index 1197a7d..02e0586 100644 --- a/src/graph.c +++ b/src/graph.c @@ -70,13 +70,13 @@ draw_vtext (gdImagePtr graph, int color, const char *text) (unsigned char *) text, color); } int draw_graph (FILE *fp, struct monitor *mon, - queue_t *dataq, const struct avg_acc *avg, time_t now, + queue_t *dataq, const struct avg_acc *avg, time_t start, int xstep, unsigned long xmax, int growright, struct grid_class *xgrid, struct grid_class *ygrid) { int x, y; int i, n; @@ -87,13 +87,12 @@ draw_graph (FILE *fp, double xscale, yscale; int dotted_style[3]; int full_xsize = graph_xsize + graph_h_margin[0] + graph_h_margin[1]; int full_ysize = graph_ysize + graph_v_margin[0] + graph_v_margin[1]; grid_t grid; unsigned long ymax = mon->max_rate; - time_t start; yscale = (double) graph_ysize / ymax; xscale = (double) graph_xsize / xmax; #define ytr(y) \ (unsigned long) ((ymax >= (y) ? (ymax - (y)) : ymax) * \ @@ -140,19 +139,19 @@ draw_graph (FILE *fp, gdImageLine (graph, 1, full_ysize - 2, full_xsize - 2, full_ysize - 2, i_dark); n = queue_count (dataq); /* Incoming traffic */ - for (i = n - 1, start = 0; i > 0; i--) + for (i = n - 1; i > 0; i--) { struct traffic_history th, tnext; scale_sample (mon, queue_get_ptr (dataq, i), &th); - if (start == 0) - start = th.time; + if (th.time > start) + continue; scale_sample (mon, queue_get_ptr (dataq, i - 1), &tnext); if (start - tnext.time > xmax) break; if (zero_unknown_option && th.time - tnext.time > xstep * cut_out_fraction) { @@ -169,19 +168,19 @@ draw_graph (FILE *fp, gdImageLine (graph, xtr (start - th.time), ytr (th.inrate), xtr (start - tnext.time), ytr (tnext.inrate), i_in); } /* Outgoing traffic */ gdImageSetBrush (graph, brush_out); - for (i = n - 1, start = 0; i > 0; i--) + for (i = n - 1; i > 0; i--) { struct traffic_history th, tnext; scale_sample (mon, queue_get_ptr (dataq, i), &th); - if (start == 0) - start = th.time; + if (th.time > start) + continue; scale_sample (mon, queue_get_ptr (dataq, i - 1), &tnext); if (start - tnext.time > xmax) break; if (zero_unknown_option && th.time - tnext.time > xstep * cut_out_fraction) @@ -242,13 +241,13 @@ draw_graph (FILE *fp, 23, y - gdFontSmall->h / 2, (unsigned char *) str, i_grid); } grid_destroy (grid); } - grid = grid_create (xgrid, dataq, 0, xmax, &now); + grid = grid_create (xgrid, dataq, 0, xmax, &start); if (grid) { unsigned long i; char *str = NULL; int mark; |