X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph.c;h=33f0e516bf35279972358e5bed0fa76bba800111;hb=361a0fd38d7adf95847508f54c0bde9b3f98662e;hp=8162bbfc79f74bf5866f385a17a262004be0273c;hpb=37329a5f991870e8f47c8a52f6dd594fef813de6;p=rrdtool.git diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 8162bbf..33f0e51 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2.6 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.8 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd__graph.c produce graphs from data in rrdfiles ****************************************************************************/ @@ -9,7 +9,7 @@ #include "rrd_tool.h" -#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) #include #include #endif @@ -100,8 +100,9 @@ gfx_color_t graph_col[] = /* default colors */ 0xE0505080, /* major grid */ 0x000000FF, /* font */ 0x802020FF, /* arrow */ - 0x202020FF /* axis */ -}; + 0x202020FF, /* axis */ + 0x000000FF /* frame */ +}; /* #define DEBUG */ @@ -151,9 +152,9 @@ ytr(image_desc_t *im, double value){ if (! im->rigid) { /* keep yval as-is */ } else if (yval > im->yorigin) { - yval = im->yorigin; + yval = im->yorigin +0.00001; } else if (yval < im->yorigin - im->ysize){ - yval = im->yorigin - im->ysize; + yval = im->yorigin - im->ysize - 0.00001; } return yval; } @@ -222,6 +223,7 @@ enum grc_en grc_conv(char *string){ conv_if(FONT,GRC_FONT) conv_if(ARROW,GRC_ARROW) conv_if(AXIS,GRC_AXIS) + conv_if(FRAME,GRC_FRAME) return -1; } @@ -1989,39 +1991,32 @@ grid_paint(image_desc_t *im) if ( im->gdes[i].gf != GF_PRINT && im->gdes[i].gf != GF_GPRINT && im->gdes[i].gf != GF_COMMENT) { - int boxL, boxH, boxV; + int boxH, boxV; - boxL = gfx_get_text_width(im->canvas, 0, + boxH = gfx_get_text_width(im->canvas, 0, im->text_prop[TEXT_PROP_LEGEND].font, im->text_prop[TEXT_PROP_LEGEND].size, - im->tabwidth,"oo", 0); - boxH = boxL / 1.9; - boxV = boxH+1; + im->tabwidth,"o", 0) * 1.2; + boxV = boxH*1.1; - /* make sure transparent colors show up all the same */ + /* make sure transparent colors show up the same way as in the graph */ node = gfx_new_area(im->canvas, - X0-1,Y0-boxV, - X0-1,Y0+1, - X0+boxL+0.5,Y0+1, - im->graph_col[GRC_BACK]); - gfx_add_point ( node, X0+boxL+0.5, Y0-boxV ); - node = gfx_new_area(im->canvas, - X0-1,Y0-boxV, - X0-1,Y0, + X0,Y0-boxV, + X0,Y0, X0+boxH,Y0, - im->graph_col[GRC_CANVAS]); + im->graph_col[GRC_BACK]); gfx_add_point ( node, X0+boxH, Y0-boxV ); node = gfx_new_area(im->canvas, - X0-1,Y0-boxV, - X0-1,Y0, + X0,Y0-boxV, + X0,Y0, X0+boxH,Y0, im->gdes[i].col); gfx_add_point ( node, X0+boxH, Y0-boxV ); node = gfx_new_line(im->canvas, - X0-1,Y0-boxV, - X0-1,Y0, - 1,im->graph_col[GRC_FONT]); + X0,Y0-boxV, + X0,Y0, + 1.0,im->graph_col[GRC_FRAME]); gfx_add_point(node,X0+boxH,Y0); gfx_add_point(node,X0+boxH,Y0-boxV); gfx_close_path(node); @@ -2387,11 +2382,11 @@ graph_paint(image_desc_t *im, char ***calcpr) node=gfx_new_area ( im->canvas, 0, 0, - im->ximg, 0, - im->ximg, im->yimg, + 0, im->yimg, + im->ximg, im->yimg, im->graph_col[GRC_BACK]); - gfx_add_point(node,0, im->yimg); + gfx_add_point(node,im->ximg, 0); #ifdef WITH_PIECHART if (piechart != 2) { @@ -2506,11 +2501,11 @@ graph_paint(image_desc_t *im, char ***calcpr) } } else { - float ybase0 = DNAN,ytop0=DNAN; + double ybase0 = DNAN,ytop0=DNAN; for(ii=0;iixsize;ii++){ /* keep things simple for now, just draw these bars do not try to build a big and complex area */ - float ybase,ytop; + double ybase,ytop; if ( im->slopemode == 0 && ii==0){ continue; } @@ -2531,7 +2526,7 @@ graph_paint(image_desc_t *im, char ***calcpr) /* every area has to be wound clock-wise, so we have to make sur base remains base */ if (ybase > ytop){ - float extra = ytop; + double extra = ytop; ytop = ybase; ybase = extra; } @@ -2541,13 +2536,13 @@ graph_paint(image_desc_t *im, char ***calcpr) } if ( !isnan(ybase0) ){ node = gfx_new_area(im->canvas, - ii-1+im->xorigin,ybase0, - ii-1+im->xorigin,ytop0, - ii+im->xorigin,ytop, + (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, - ii+im->xorigin,ybase + (double)ii+0.02+im->xorigin,ybase-0.2 ); } ybase0=ybase; @@ -2634,7 +2629,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if (strcmp(im->graphfile,"-")==0) { fo = im->graphhandle ? im->graphhandle : stdout; -#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) /* Change translation mode for stdout to BINARY */ _setmode( _fileno( fo ), O_BINARY ); #endif @@ -2645,7 +2640,7 @@ graph_paint(image_desc_t *im, char ***calcpr) return (-1); } } - gfx_render (im->canvas,im->ximg,im->yimg,0x0,fo); + gfx_render (im->canvas,im->ximg,im->yimg,0x00000000,fo); if (strcmp(im->graphfile,"-") != 0) fclose(fo); return 0; @@ -2839,7 +2834,7 @@ rrd_graph_init(image_desc_t *im) for(i=0;igraph_col[i]=graph_col[i]; -#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) { char *windir; char rrd_win_default_font[1000]; @@ -2926,6 +2921,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) {"tabwidth", required_argument, 0, 'T'}, {"font-render-mode", required_argument, 0, 'R'}, {"font-smoothing-threshold", required_argument, 0, 'B'}, + {"alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */ {0,0,0,0}}; int option_index = 0; int opt; @@ -3112,6 +3108,22 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) int ci; int col_len = col_end - col_start; switch (col_len){ + case 3: + color = ( + ((color & 0xF00) * 0x110000) | + ((color & 0x0F0) * 0x011000) | + ((color & 0x00F) * 0x001100) | + 0x000000FF + ); + break; + case 4: + color = ( + ((color & 0xF000) * 0x11000) | + ((color & 0x0F00) * 0x01100) | + ((color & 0x00F0) * 0x00110) | + ((color & 0x000F) * 0x00011) + ); + break; case 6: color = (color << 8) + 0xff /* shift left by 8 */; break;