[rrd-users] Re: Newline in graphtitle

Patrick Kuijvenhoven pkuijven at office.kabelfoon.nl
Mon Mar 10 16:38:23 MET 2003


Hi,

I did a very very ugly hack on rrd_graph.c (i am not very fam. with C). Here it is:

diff -uNrw rrdtool-1.0.41-orig/src/rrd_graph.c rrdtool-1.0.41-hack/src/rrd_graph.c
--- rrdtool-1.0.41-orig/src/rrd_graph.c Wed Feb 19 21:44:19 2003
+++ rrdtool-1.0.41-hack/src/rrd_graph.c Mon Mar 10 16:34:57 2003
@@ -2218,6 +2218,10 @@
     int boxH=8, boxV=8;
     int res=0;
     gdPoint polyPoints[4];      /* points for filled graph and more*/
+    char* nlp;                  /* ugly newline hack */
+    char* nlbuffer;
+    char* nldelim = { "?" };
+    int count=0;

     /* draw 3d border */
     gdImageLine(gif,0,0,im->xgif-1,0,graph_col[GRC_SHADEA].i);
@@ -2264,11 +2268,15 @@


     /* graph title */
-    gdImageString(gif, LargeFont,
-                   im->xgif/2
-                   - (strlen(im->title)*LargeFont->w)/2,
-                 8,
-                   (unsigned char *)im->title, graph_col[GRC_FONT].i);
+
+    nlbuffer = strdup(im->title);
+    nlp = strtok( nlbuffer, nldelim );
+
+    while( nlp != NULL ) {
+      gdImageString(gif, LargeFont, im->xgif/2 - (strlen(nlp)*LargeFont->w)/2, count*LargeFont->h+5, (unsigned char *)nlp, graph_col[GRC_FONT].i);
+      nlp = strtok( NULL, nldelim );
+      count++;
+    }

     /* graph labels */
     if( !(im->extra_flags & NOLEGEND) ) {
@@ -2489,6 +2497,7 @@
      return -1;

     gif=gdImageCreate(im->xgif,im->ygif);
+    im->yorigin += LargeFont->h; /* ugly hack */ 

     gdImageInterlace(gif, im->interlaced);


Thanks for all the reactions.

Cheers,

Patrick

-----Oorspronkelijk bericht-----
Van: Alex van den Bogaerdt [mailto:alex at ergens.op.het.net]
Verzonden: maandag 10 maart 2003 11:14
Aan: rrd-users at list.ee.ethz.ch
Onderwerp: [rrd-users] Re: Newline in graphtitle


On Mon, Mar 10, 2003 at 11:08:09AM +0100, Patrick Kuijvenhoven wrote:

> this might be a very simple question, but I just can't get this done.

Indeed.

> 
> I would like to add a newline to my graph-title

> I checked out the documentation and googled around. But nothing is mentioned about this.

Indeed.

I'm not going to say here that *everything* is documented however
usually something that is implemented, is documented.  The other
way around: Something that isn't documented probably isn't implemented.

You could try to implement it yourself.  Make sure to add code to calculate
the offset of the actual canvas from the top of the graph when you do.

HTH
Alex

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list