X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph.c;h=bfbd4550fda972d36b97505bb8d11691abb906a6;hb=32abc651a73d99b513dcf9dc47ed27a509a999c9;hp=c9411e25f6f3555daaddbea6f19f2bd6230714f9;hpb=aa4d951ab71eb7fe57840c3baaddf36809806aef;p=rrdtool.git diff --git a/src/rrd_graph.c b/src/rrd_graph.c index c9411e2..bfbd455 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1573,7 +1573,7 @@ calc_horizontal_grid(image_desc_t *im) } else { int len = decimals + 1; if (im->unitslength < len+2) im->unitslength = len+2; - sprintf(im->ygrid_scale.labfmt, "%%%d.1f%s", len, ( im->symbol != ' ' ? " %c" : "" )); + sprintf(im->ygrid_scale.labfmt, "%%%d.0f%s", len, ( im->symbol != ' ' ? " %c" : "" )); } } else { @@ -1844,11 +1844,11 @@ vertical_grid( # error "your libc has no strftime I guess we'll abort the exercise here." #endif gfx_new_text ( im->canvas, - xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size, + xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size*1.4+5, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, - im->tabwidth, 0.0, GFX_H_CENTER, GFX_V_TOP, + im->tabwidth, 0.0, GFX_H_CENTER, GFX_V_BOTTOM, graph_label ); } @@ -2500,16 +2500,53 @@ graph_paint(image_desc_t *im, char ***calcpr) } } else { - double ybase0 = DNAN,ytop0=DNAN; - for(ii=0;iixsize;ii++){ + int idxI=-1; + double *foreY=malloc(sizeof(double)*im->xsize*2); + double *foreX=malloc(sizeof(double)*im->xsize*2); + double *backY=malloc(sizeof(double)*im->xsize*2); + double *backX=malloc(sizeof(double)*im->xsize*2); + int drawem = 0; + for(ii=0;ii<=im->xsize;ii++){ + double ybase,ytop; + if ( idxI > 0 && ( drawem != 0 || ii==im->xsize)){ + int cntI=1; + int lastI=0; + while (cntI < idxI && foreY[lastI] == foreY[cntI] && foreY[lastI] == foreY[cntI+1]){cntI++;} + node = gfx_new_area(im->canvas, + backX[0],backY[0], + foreX[0],foreY[0], + foreX[cntI],foreY[cntI], im->gdes[i].col); + while (cntI < idxI) { + lastI = cntI; + cntI++; + while ( cntI < idxI && foreY[lastI] == foreY[cntI] && foreY[lastI] == foreY[cntI+1]){cntI++;} + gfx_add_point(node,foreX[cntI],foreY[cntI]); + } + gfx_add_point(node,backX[idxI],backY[idxI]); + while (idxI > 1){ + lastI = idxI; + idxI--; + while ( idxI > 1 && backY[lastI] == backY[idxI] && backY[lastI] == backY[idxI-1]){idxI--;} + gfx_add_point(node,backX[idxI],backY[idxI]); + } + idxI=-1; + drawem = 0; + } + if (drawem != 0){ + drawem = 0; + idxI=-1; + } + if (ii == im->xsize) break; + /* keep things simple for now, just draw these bars do not try to build a big and complex area */ - double ybase,ytop; + + if ( im->slopemode == 0 && ii==0){ continue; } if ( isnan(im->gdes[i].p_data[ii]) ) { - ybase0 = DNAN; + drawem = 1; continue; } ytop = ytr(im,im->gdes[i].p_data[ii]); @@ -2519,7 +2556,7 @@ graph_paint(image_desc_t *im, char ***calcpr) ybase = ytr(im,areazero); } if ( ybase == ytop ){ - ybase0 = DNAN; + drawem = 1; continue; } /* every area has to be wound clock-wise, @@ -2529,24 +2566,22 @@ graph_paint(image_desc_t *im, char ***calcpr) ytop = ybase; ybase = extra; } - if ( im->slopemode == 0){ - ybase0 = ybase; - ytop0 = ytop; - } - if ( !isnan(ybase0) ){ - node = gfx_new_area(im->canvas, - (double)ii-1.2+(double)im->xorigin,ybase0-0.2, - (double)ii-1.2+(double)im->xorigin,ytop0+0.2, - (double)ii+0.2+(double)im->xorigin,ytop+0.2, - im->gdes[i].col - ); - gfx_add_point(node, - (double)ii+0.02+im->xorigin,ybase-0.2 - ); + if ( im->slopemode == 0 ){ + backY[++idxI] = ybase-0.2; + backX[idxI] = ii+im->xorigin-1; + foreY[idxI] = ytop+0.2; + foreX[idxI] = ii+im->xorigin-1; } - ybase0=ybase; - ytop0=ytop; - } + backY[++idxI] = ybase-0.2; + backX[idxI] = ii+im->xorigin; + foreY[idxI] = ytop+0.2; + foreX[idxI] = ii+im->xorigin; + } + /* close up any remaining area */ + free(foreY); + free(foreX); + free(backY); + free(backX); } /* else GF_LINE */ } /* if color != 0x0 */ /* make sure we do not run into trouble when stacking on NaN */ @@ -2555,7 +2590,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if (lastgdes && (im->gdes[i].stack)) { im->gdes[i].p_data[ii] = lastgdes->p_data[ii]; } else { - im->gdes[i].p_data[ii] = ytr(im,areazero); + im->gdes[i].p_data[ii] = areazero; } } } @@ -3150,7 +3185,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) if(sscanf(optarg, "%10[A-Z]:%lf:%1000s", - prop,&size,font) == 3){ + prop,&size,font) >= 2){ int sindex,propidx; if((sindex=text_prop_conv(prop)) != -1){ for (propidx=sindex;propidx