X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=706bd49505e68b341c17fd2551e4d1c0f10f4d40;hp=898b6ff9c8e7dce2eecb3a2359e4615ba135d7b2;hb=d4be3fb9f21f84e086282c1a679ccfdebfccda91;hpb=1f472620354603bd3bf2fdee30e2dd70dea7a4f1 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 898b6ff..706bd49 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1470,6 +1470,13 @@ time_t find_next_time( localtime_r(¤t, &tm); + int limit = 2; + switch (baseint) { + case TMT_SECOND: limit = 7200; break; + case TMT_MINUTE: limit = 120; break; + case TMT_HOUR: limit = 2; break; + default: limit = 2; break; + } do { switch (baseint) { case TMT_SECOND: @@ -1500,7 +1507,7 @@ time_t find_next_time( tm. tm_year += basestep; } madetime = mktime(&tm); - } while (madetime == -1); /* this is necessary to skip impssible times + } while (madetime == -1 && limit-- >= 0); /* this is necessary to skip impossible times like the daylight saving time skips */ return madetime; @@ -1582,7 +1589,7 @@ int print_calc( } } /* prepare printval */ - if ((percent_s = strstr(im->gdes[i].format, "%S")) != NULL) { + if (!im->gdes[i].strftm && (percent_s = strstr(im->gdes[i].format, "%S")) != NULL) { /* Magfact is set to -1 upon entry to print_calc. If it * is still less than 0, then we need to run auto_scale. * Otherwise, put the value into the correct units. If @@ -1596,7 +1603,7 @@ int print_calc( printval /= magfact; } *(++percent_s) = 's'; - } else if (strstr(im->gdes[i].format, "%s") != NULL) { + } else if (!im->gdes[i].strftm && strstr(im->gdes[i].format, "%s") != NULL) { auto_scale(im, &printval, &si_symb, &magfact); } @@ -1859,7 +1866,7 @@ int leg_place( glue = 0; } if (prt_fctn == 'c') - leg_x = (double)(legendwidth - fill) / 2.0; + leg_x = border + (double)(legendwidth - fill) / 2.0; if (prt_fctn == 'r') leg_x = legendwidth - fill + border; for (ii = mark; ii <= i; ii++) { @@ -2506,19 +2513,20 @@ void vertical_grid( mgridtm, im->xlab_user. mgridst); - ti < im->end; + ti < im->end && ti != -1; ti = find_next_time(ti, im->xlab_user.gridtm, im->xlab_user.gridst) ) { /* are we inside the graph ? */ if (ti < im->start || ti > im->end) continue; - while (timajor < ti) { + while (timajor < ti && timajor != -1) { timajor = find_next_time(timajor, im-> xlab_user. mgridtm, im->xlab_user.mgridst); } + if (timajor == -1) break; /* fail in case of problems with time increments */ if (ti == timajor) continue; /* skip as falls on major grid line */ X0 = xtr(im, ti); @@ -2542,7 +2550,7 @@ void vertical_grid( im-> xlab_user. mgridst); - ti < im->end; + ti < im->end && ti != -1; ti = find_next_time(ti, im->xlab_user.mgridtm, im->xlab_user.mgridst) ) { /* are we inside the graph ? */ @@ -2568,9 +2576,9 @@ void vertical_grid( labtm, im->xlab_user. labst); - ti <= + (ti <= im->end - - im->xlab_user.precis / 2; + im->xlab_user.precis / 2) && ti != -1; ti = find_next_time(ti, im->xlab_user.labtm, im->xlab_user.labst) ) { tilab = ti + im->xlab_user.precis / 2; /* correct time for the label */ @@ -2960,7 +2968,7 @@ int graph_size_location( } else{ // we have no title; get a little clearing from the top - Ytitle = 1.5 * Yspacing; + Ytitle = Yspacing; } if (elements) { @@ -3054,7 +3062,7 @@ int graph_size_location( /* reserve space for padding below the graph */ if (im->extra_flags & NOLEGEND) { - Ymain -= Yspacing; + Ymain -= 0.5*Yspacing; } if (im->watermark[0] != '\0') { @@ -3114,7 +3122,7 @@ int graph_size_location( } /* reserve space for padding below the graph */ if (im->extra_flags & NOLEGEND) { - im->yimg += Yspacing; + im->yimg += 0.5*Yspacing; } if (im->watermark[0] != '\0') { @@ -3143,7 +3151,7 @@ int graph_size_location( */ switch(im->legendposition){ case NORTH: - im->xOriginTitle = Xvertical + Xylabel + (im->xsize / 2); + im->xOriginTitle = (im->ximg / 2); im->yOriginTitle = 0; im->xOriginLegend = 0; @@ -3164,7 +3172,7 @@ int graph_size_location( break; case WEST: - im->xOriginTitle = im->legendwidth + Xvertical + Xylabel + im->xsize / 2; + im->xOriginTitle = im->legendwidth + im->xsize / 2; im->yOriginTitle = 0; im->xOriginLegend = 0; @@ -3185,7 +3193,7 @@ int graph_size_location( break; case SOUTH: - im->xOriginTitle = Xvertical + Xylabel + im->xsize / 2; + im->xOriginTitle = im->ximg / 2; im->yOriginTitle = 0; im->xOriginLegend = 0; @@ -3206,7 +3214,7 @@ int graph_size_location( break; case EAST: - im->xOriginTitle = Xvertical + Xylabel + im->xsize / 2; + im->xOriginTitle = im->xsize / 2; im->yOriginTitle = 0; im->xOriginLegend = Xvertical + Xylabel + Xmain + Xvertical2; @@ -3448,17 +3456,27 @@ int graph_paint( break; case GF_LINE: case GF_AREA: - case GF_GRAD: - /* fix data points at oo and -oo */ + case GF_GRAD: { + rrd_value_t diffval = im->maxval - im->minval; + rrd_value_t maxlimit = im->maxval + 9 * diffval; + rrd_value_t minlimit = im->minval - 9 * diffval; for (ii = 0; ii < im->xsize; ii++) { + /* fix data points at oo and -oo */ if (isinf(im->gdes[i].p_data[ii])) { if (im->gdes[i].p_data[ii] > 0) { im->gdes[i].p_data[ii] = im->maxval; } else { im->gdes[i].p_data[ii] = im->minval; } - } + /* some versions of cairo go unstable when trying + to draw way out of the canvas ... lets not even try */ + if (im->gdes[i].p_data[ii] > maxlimit) { + im->gdes[i].p_data[ii] = maxlimit; + } + if (im->gdes[i].p_data[ii] < minlimit) { + im->gdes[i].p_data[ii] = minlimit; + } } /* for */ /* ******************************************************* @@ -3726,6 +3744,7 @@ int graph_paint( } lastgdes = &(im->gdes[i]); break; + } /* GF_AREA, GF_LINE, GF_GRAD */ case GF_STACK: rrd_set_error ("STACK should already be turned into LINE or AREA here");