X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=program%2Fsrc%2Frrd_graph.c;h=a71a174a5001cc931a0013fed39a93e6d8302bc4;hb=3a856c49a6374cf7a17c3c5be67d1ddd96b3b0f6;hp=ba0460eecad4cc9e73d034b936f693809a6ab854;hpb=ac8d83f8d21e6f8d6c1d892813ecfc59623cdab2;p=rrdtool-all.git diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index ba0460ee..a71a174a 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -179,7 +179,7 @@ enum gf_en gf_conv(char *string){ conv_if(VRULE,GF_VRULE) conv_if(LINE,GF_LINE) conv_if(AREA,GF_AREA) - conv_if(STACK,GF_STACK) + conv_if(STACK,GF_STACK) conv_if(TICK,GF_TICK) conv_if(DEF,GF_DEF) conv_if(CDEF,GF_CDEF) @@ -1020,8 +1020,7 @@ data_proc( image_desc_t *im ){ for(i=0;igdes_c;i++) { if((im->gdes[i].gf==GF_LINE) || (im->gdes[i].gf==GF_AREA) || - (im->gdes[i].gf==GF_TICK) || - (im->gdes[i].gf==GF_STACK)) { + (im->gdes[i].gf==GF_TICK)) { if((im->gdes[i].p_data = malloc((im->xsize +1) * sizeof(rrd_value_t)))==NULL){ rrd_set_error("malloc data_proc"); @@ -1043,7 +1042,6 @@ data_proc( image_desc_t *im ){ case GF_TICK: if (!im->gdes[ii].stack) paintval = 0.0; - case GF_STACK: value = im->gdes[ii].yrule; if (isnan(value) || (im->gdes[ii].gf == GF_TICK)) { /* The time of the data doesn't necessarily match @@ -1082,6 +1080,10 @@ data_proc( image_desc_t *im ){ im->gdes[ii].p_data[i] = DNAN; } break; + case GF_STACK: + rrd_set_error("STACK should already be turned into LINE or AREA here"); + return -1; + break; default: break; } @@ -1361,7 +1363,6 @@ print_calc(image_desc_t *im, char ***prdata) case GF_LINE: case GF_AREA: case GF_TICK: - case GF_STACK: case GF_HRULE: case GF_VRULE: graphelement = 1; @@ -1376,6 +1377,10 @@ print_calc(image_desc_t *im, char ***prdata) case GF_SHIFT: case GF_XPORT: break; + case GF_STACK: + rrd_set_error("STACK should already be turned into LINE or AREA here"); + return -1; + break; } } return graphelement; @@ -1527,7 +1532,7 @@ calc_horizontal_grid(image_desc_t *im) double range; double scaledrange; int pixel,i; - int gridind; + int gridind=0; int decimals, fractionals; im->ygrid_scale.labfact=2; @@ -1972,6 +1977,17 @@ grid_paint(image_desc_t *im) 5.5, im->tabwidth, 270, GFX_H_RIGHT, GFX_V_TOP, "RRDTOOL / TOBI OETIKER"); + + /* graph watermark */ + if(im->watermark[0] != '\0') { + gfx_new_text( im->canvas, + im->ximg/2, im->yimg-6, + ( im->graph_col[GRC_FONT] & 0xffffff00 ) | 0x00000044, + im->text_prop[TEXT_PROP_AXIS].font, + 5.5, im->tabwidth, 0, + GFX_H_CENTER, GFX_V_BOTTOM, + im->watermark); + } /* graph labels */ if( !(im->extra_flags & NOLEGEND) & !(im->extra_flags & ONLY_GRAPH) ) { @@ -2135,6 +2151,8 @@ graph_size_location(image_desc_t *im, int elements ** |v+--+-------------------------------+--------+ ** | |..............legends......................| ** +-+-------------------------------------------+ + ** | watermark | + ** +---------------------------------------------+ */ int Xvertical=0, Ytitle =0, @@ -2147,7 +2165,9 @@ graph_size_location(image_desc_t *im, int elements #if 0 Xlegend =0, Ylegend =0, #endif - Xspacing =15, Yspacing =15; + Xspacing =15, Yspacing =15, + + Ywatermark =4; if (im->extra_flags & ONLY_GRAPH) { im->xorigin =0; @@ -2234,12 +2254,13 @@ graph_size_location(image_desc_t *im, int elements xtr(im,0); /* The vertical size is interesting... we need to compare - ** the sum of {Ytitle, Ymain, Yxlabel, Ylegend} with Yvertical - ** however we need to know {Ytitle+Ymain+Yxlabel} in order to - ** start even thinking about Ylegend. + ** the sum of {Ytitle, Ymain, Yxlabel, Ylegend, Ywatermark} with + ** Yvertical however we need to know {Ytitle+Ymain+Yxlabel} + ** in order to start even thinking about Ylegend or Ywatermark. ** ** Do it in three portions: First calculate the inner part, - ** then do the legend, then adjust the total height of the img. + ** then do the legend, then adjust the total height of the img, + ** adding space for a watermark if one exists; */ /* reserve space for main and/or pie */ @@ -2268,7 +2289,10 @@ graph_size_location(image_desc_t *im, int elements */ if(leg_place(im)==-1) return -1; - + + if (im->watermark[0] != '\0') { + im->yimg += Ywatermark; + } #if 0 if (Xlegend > im->ximg) { @@ -2342,7 +2366,6 @@ graph_paint(image_desc_t *im, char ***calcpr) gfx_node_t *node; double areazero = 0.0; - enum gf_en stack_gf = GF_PRINT; graph_desc_t *lastgdes = NULL; /* if we are lazy and there is nothing to PRINT ... quit now */ @@ -2466,22 +2489,27 @@ graph_paint(image_desc_t *im, char ***calcpr) for (ii = 0; ii < im->xsize; ii++) { if (!isnan(im->gdes[i].p_data[ii]) && - im->gdes[i].p_data[ii] > 0.0) - { - /* generate a tick */ - gfx_new_line(im->canvas, im -> xorigin + ii, - im -> yorigin - (im -> gdes[i].yrule * im -> ysize), - im -> xorigin + ii, - im -> yorigin, - 1.0, - im -> gdes[i].col ); - } + im->gdes[i].p_data[ii] != 0.0) + { + if (im -> gdes[i].yrule > 0 ) { + gfx_new_line(im->canvas, + im -> xorigin + ii, im->yorigin, + im -> xorigin + ii, im->yorigin - im -> gdes[i].yrule * im -> ysize, + 1.0, + im -> gdes[i].col ); + } else if ( im -> gdes[i].yrule < 0 ) { + gfx_new_line(im->canvas, + im -> xorigin + ii, im->yorigin - im -> ysize, + im -> xorigin + ii, im->yorigin - ( 1 - im -> gdes[i].yrule ) * im -> ysize, + 1.0, + im -> gdes[i].col ); + + } + } } break; case GF_LINE: case GF_AREA: - stack_gf = im->gdes[i].gf; - case GF_STACK: /* fix data points at oo and -oo */ for(ii=0;iixsize;ii++){ if (isinf(im->gdes[i].p_data[ii])){ @@ -2507,7 +2535,7 @@ graph_paint(image_desc_t *im, char ***calcpr) ********************************************************* */ if (im->gdes[i].col != 0x0){ /* GF_LINE and friend */ - if(stack_gf == GF_LINE ){ + if(im->gdes[i].gf == GF_LINE ){ double last_y=0.0; node = NULL; for(ii=1;iixsize;ii++){ @@ -2651,6 +2679,10 @@ graph_paint(image_desc_t *im, char ***calcpr) } break; #endif + case GF_STACK: + rrd_set_error("STACK should already be turned into LINE or AREA here"); + return -1; + break; } /* switch */ } @@ -2740,6 +2772,7 @@ gdes_alloc(image_desc_t *im){ im->gdes[im->gdes_c-1].step=im->step; im->gdes[im->gdes_c-1].step_orig=im->step; im->gdes[im->gdes_c-1].stack=0; + im->gdes[im->gdes_c-1].linewidth=0; im->gdes[im->gdes_c-1].debug=0; im->gdes[im->gdes_c-1].start=im->start; im->gdes[im->gdes_c-1].end=im->end; @@ -2870,6 +2903,9 @@ rrd_graph_init(image_desc_t *im) #endif #ifdef HAVE_SETLOCALE setlocale(LC_TIME,""); +#ifdef HAVE_MBSTOWCS + setlocale(LC_CTYPE,""); +#endif #endif im->yorigin=0; im->xorigin=0; @@ -2882,6 +2918,7 @@ rrd_graph_init(image_desc_t *im) im->step = 0; im->ylegend[0] = '\0'; im->title[0] = '\0'; + im->watermark[0] = '\0'; im->minval = DNAN; im->maxval = DNAN; im->unitsexponent= 9999; @@ -2917,8 +2954,8 @@ rrd_graph_init(image_desc_t *im) windir = getenv("windir"); /* %windir% is something like D:\windows or C:\winnt */ if (windir != NULL) { - strncpy(rrd_win_default_font,windir,999); - rrd_win_default_font[999] = '\0'; + strncpy(rrd_win_default_font,windir,500); + rrd_win_default_font[500] = '\0'; strcat(rrd_win_default_font,"\\fonts\\"); strcat(rrd_win_default_font,RRD_DEFAULT_FONT); for(i=0;icanvas->font_aa_threshold = atof(optarg); break; + case 'W': + strncpy(im->watermark,optarg,100); + im->watermark[99]='\0'; + break; + case '?': if (optopt != 0) rrd_set_error("unknown option '%c'", optopt);