--- rrdtool-1.2.27.orig/src/rrd_graph.c Mon Mar 10 15:14:29 2008 +++ rrdtool-1.2.27/src/rrd_graph.c Tue Mar 11 11:55:22 2008 @@ -2154,6 +2154,8 @@ int res=0; double X0,Y0; /* points for filled graph and more*/ gfx_node_t *node; + imgtitle_t myimgtitle_t; + int j = 0; /* draw 3d border */ node = gfx_new_area (im->canvas, 0,im->yimg, @@ -2207,13 +2209,18 @@ im->ylegend); /* graph title */ - gfx_new_text( im->canvas, - 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, - GFX_H_CENTER, GFX_V_CENTER, - im->title); + myimgtitle_t = split_graphtitle(im->title); + while(myimgtitle_t.pieces[j] != NULL) { + gfx_new_text( im->canvas, + // im->ximg/2, im->text_prop[TEXT_PROP_TITLE].size*1.3+4, + im->ximg/2, (im->text_prop[TEXT_PROP_TITLE].size*1.3)+(im->text_prop[TEXT_PROP_TITLE].size * 1.6 * j), + im->graph_col[GRC_FONT], + im->text_prop[TEXT_PROP_TITLE].font, + im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, 0.0, + GFX_H_CENTER, GFX_V_CENTER, + myimgtitle_t.pieces[j]); + j++; + } /* rrdtool 'logo' */ gfx_new_text( im->canvas, im->ximg-7, 7, @@ -2414,6 +2421,8 @@ Ywatermark =4; + imgtitle_t myimgtitle_t; + if (im->extra_flags & ONLY_GRAPH) { im->xorigin =0; im->ximg = im->xsize; @@ -2439,7 +2448,9 @@ im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, im->title, 0) + 2*Xspacing; */ - Ytitle = im->text_prop[TEXT_PROP_TITLE].size*2.6+10; + myimgtitle_t = split_graphtitle(im->title); + // Ytitle = im->text_prop[TEXT_PROP_TITLE].size*2.6+10; + Ytitle = im->text_prop[TEXT_PROP_TITLE].size * (myimgtitle_t.count + 1) * 1.6; } if (elements) { @@ -3990,4 +4001,26 @@ /* If we reach this, both values must be finite */ if ( *(double *)a < *(double *)b ) return -1; else return 1; +} + +imgtitle_t split_graphtitle(char *input) +{ + imgtitle_t retval; + char *str; + int count = 0; + char delim = '?'; + + str = strdup(input); + + retval.pieces = malloc((MAX_IMGTITLE_NEWLINES + 1 ) * sizeof(char *)); + + retval.pieces[count] = strtok (str, &delim); + while ( retval.pieces[count] != NULL && count++ < MAX_IMGTITLE_NEWLINES) + { + retval.pieces[count] = strtok( NULL, &delim); + } + retval.pieces[count] = NULL; + retval.count = count; + + return retval; } --- rrdtool-1.2.27.orig/src/rrd_graph.h Mon Mar 10 15:14:29 2008 +++ rrdtool-1.2.27/src/rrd_graph.h Tue Mar 11 11:03:29 2008 @@ -208,6 +208,14 @@ gfx_canvas_t *canvas; /* graphics library */ } image_desc_t; +#define MAX_IMGTITLE_NEWLINES 5 + +typedef struct imgtitle_t +{ + char **pieces; + int count; +} imgtitle_t; + /* Prototypes */ int xtr(image_desc_t *,time_t); double ytr(image_desc_t *, double); @@ -259,5 +267,6 @@ ,int #endif ); +imgtitle_t split_graphtitle(char *); #endif