X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=01e174ce7cb0ed5fcdf38ed5ede01350a72cd951;hp=95ba70df452e835e28122abf946e4c2e1ca281b6;hb=db40632e1c55e32f618d14f75a8698d87cc6b974;hpb=7572d57fd117fd3077be29ea7bd9b5c075fc0b0b diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 95ba70d..01e174c 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2rc8 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.1 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd__graph.c produce graphs from data in rrdfiles ****************************************************************************/ @@ -30,15 +30,15 @@ #ifndef RRD_DEFAULT_FONT /* there is special code later to pick Cour.ttf when running on windows */ -#define RRD_DEFAULT_FONT "VeraMono.ttf" +#define RRD_DEFAULT_FONT "DejaVuSansMono-Roman.ttf" #endif text_prop_t text_prop[] = { - { 9.0, RRD_DEFAULT_FONT }, /* default */ - { 11.0, RRD_DEFAULT_FONT }, /* title */ - { 8.0, RRD_DEFAULT_FONT }, /* axis */ - { 9.0, RRD_DEFAULT_FONT }, /* unit */ - { 9.0, RRD_DEFAULT_FONT } /* legend */ + { 8.0, RRD_DEFAULT_FONT }, /* default */ + { 9.0, RRD_DEFAULT_FONT }, /* title */ + { 7.0, RRD_DEFAULT_FONT }, /* axis */ + { 8.0, RRD_DEFAULT_FONT }, /* unit */ + { 8.0, RRD_DEFAULT_FONT } /* legend */ }; xlab_t xlab[] = { @@ -1497,7 +1497,7 @@ leg_place(image_desc_t *im) + legspace[ii] + glue; } - leg_y += im->text_prop[TEXT_PROP_LEGEND].size*1.7; + leg_y += im->text_prop[TEXT_PROP_LEGEND].size*1.8; if (prt_fctn == 's') leg_y -= im->text_prop[TEXT_PROP_LEGEND].size; fill = 0; leg_c = 0; @@ -1938,7 +1938,7 @@ grid_paint(image_desc_t *im) /* yaxis unit description */ gfx_new_text( im->canvas, - 7, (im->yorigin - im->ysize/2), + 12, (im->yorigin - im->ysize/2), im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_UNIT].font, im->text_prop[TEXT_PROP_UNIT].size, im->tabwidth, @@ -1948,7 +1948,7 @@ grid_paint(image_desc_t *im) /* graph title */ gfx_new_text( im->canvas, - im->ximg/2, im->text_prop[TEXT_PROP_TITLE].size*1.2, + im->ximg/2, im->text_prop[TEXT_PROP_TITLE].size*1.3+4, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_TITLE].font, im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, 0.0, @@ -2117,8 +2117,8 @@ graph_size_location(image_desc_t *im, int elements ** | |..............legends......................| ** +-+-------------------------------------------+ */ - int Xvertical=0, Yvertical=0, - Xtitle =0, Ytitle =0, + int Xvertical=0, + Ytitle =0, Xylabel =0, Xmain =0, Ymain =0, #ifdef WITH_PIECHART @@ -2140,10 +2140,6 @@ graph_size_location(image_desc_t *im, int elements if (im->ylegend[0] != '\0' ) { Xvertical = im->text_prop[TEXT_PROP_UNIT].size *2; - Yvertical = gfx_get_text_width(im->canvas, 0, - im->text_prop[TEXT_PROP_UNIT].font, - im->text_prop[TEXT_PROP_UNIT].size, - im->tabwidth,im->ylegend, 0); } @@ -2152,12 +2148,13 @@ graph_size_location(image_desc_t *im, int elements ** automatically has some vertical spacing. The horizontal ** spacing is added here, on each side. */ - Xtitle = gfx_get_text_width(im->canvas, 0, + /* don't care for the with of the title + Xtitle = gfx_get_text_width(im->canvas, 0, im->text_prop[TEXT_PROP_TITLE].font, im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, - im->title, 0) + 2*Xspacing; - Ytitle = im->text_prop[TEXT_PROP_TITLE].size*2.5; + im->title, 0) + 2*Xspacing; */ + Ytitle = im->text_prop[TEXT_PROP_TITLE].size*2.6+10; } if (elements) { @@ -2171,7 +2168,7 @@ graph_size_location(image_desc_t *im, int elements im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, - "0", 0) * im->unitslength + im->text_prop[TEXT_PROP_AXIS].size * 2; + "0", 0) * im->unitslength + Xspacing; } } @@ -2207,7 +2204,8 @@ graph_size_location(image_desc_t *im, int elements im->xorigin = Xspacing + Xylabel; - if (Xtitle > im->ximg) im->ximg = Xtitle; + /* the length of the title should not influence with width of the graph + if (Xtitle > im->ximg) im->ximg = Xtitle; */ if (Xvertical) { /* unit description */ im->ximg += Xvertical; @@ -2239,8 +2237,8 @@ graph_size_location(image_desc_t *im, int elements im->yimg += Ytitle; im->yorigin += Ytitle; } else { - im->yimg += Yspacing; - im->yorigin += Yspacing; + im->yimg += 1.5*Yspacing; + im->yorigin += 1.5*Yspacing; } /* reserve space for padding below the graph */ im->yimg += Yspacing; @@ -2252,8 +2250,6 @@ graph_size_location(image_desc_t *im, int elements if(leg_place(im)==-1) return -1; - /* last of three steps: check total height of image */ - if (im->yimg < Yvertical) im->yimg = Yvertical; #if 0 if (Xlegend > im->ximg) { @@ -2486,7 +2482,7 @@ graph_paint(image_desc_t *im, char ***calcpr) continue; } ytop = ytr(im,im->gdes[i].p_data[ii]); - if ( im->gdes[i].stack ) { + if ( lastgdes && im->gdes[i].stack ) { ybase = ytr(im,lastgdes->p_data[ii]); } else { ybase = ytr(im,areazero); @@ -2540,12 +2536,14 @@ graph_paint(image_desc_t *im, char ***calcpr) } #endif - if( !(im->extra_flags & ONLY_GRAPH) ) - axis_paint(im); /* grid_paint also does the text */ if( !(im->extra_flags & ONLY_GRAPH) ) grid_paint(im); + + + if( !(im->extra_flags & ONLY_GRAPH) ) + axis_paint(im); /* the RULES are the last thing to paint ... */ for(i=0;igdes_c;i++){ @@ -2671,7 +2669,6 @@ int rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *stream, double *ymin, double *ymax) { image_desc_t im; - rrd_graph_init(&im); im.graphhandle = stream; @@ -2762,7 +2759,7 @@ rrd_graph_init(image_desc_t *im) im->minval = DNAN; im->maxval = DNAN; im->unitsexponent= 9999; - im->unitslength= 5; + im->unitslength= 6; im->symbol = ' '; im->viewfactor = 1.0; im->extra_flags= 0; @@ -2795,7 +2792,8 @@ rrd_graph_init(image_desc_t *im) if (windir != NULL) { strncpy(rrd_win_default_font,windir,999); rrd_win_default_font[999] = '\0'; - strcat(rrd_win_default_font,"\\fonts\\cour.ttf"); + strcat(rrd_win_default_font,"\\fonts\\"); + strcat(rrd_win_default_font,RRD_DEFAULT_FONT); for(i=0;ititle[150]='\0'; break; + case 'R': + if ( strcmp( optarg, "normal" ) == 0 ) + im->canvas->aa_type = AA_NORMAL; + else if ( strcmp( optarg, "light" ) == 0 ) + im->canvas->aa_type = AA_LIGHT; + else if ( strcmp( optarg, "mono" ) == 0 ) + im->canvas->aa_type = AA_NONE; + else + { + rrd_set_error("unknown font-render-mode '%s'", optarg ); + return; + } + break; + + case 'B': + im->canvas->font_aa_threshold = atof(optarg); + break; + case '?': if (optopt != 0) rrd_set_error("unknown option '%c'", optopt);