summaryrefslogtreecommitdiffabout
path: root/src/graph.c
Side-by-side diff
Diffstat (limited to 'src/graph.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/graph.c17
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
@@ -73,7 +73,7 @@ draw_vtext (gdImagePtr graph, int color, const char *text)
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)
@@ -90,7 +90,6 @@ draw_graph (FILE *fp,
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;
@@ -143,13 +142,13 @@ draw_graph (FILE *fp,
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;
@@ -172,13 +171,13 @@ draw_graph (FILE *fp,
/* 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;
@@ -245,7 +244,7 @@ draw_graph (FILE *fp,
grid_destroy (grid);
}
- grid = grid_create (xgrid, dataq, 0, xmax, &now);
+ grid = grid_create (xgrid, dataq, 0, xmax, &start);
if (grid)
{
unsigned long i;

Return to:

Send suggestions and report system problems to the System administrator.