/****************************************************************************
- * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000
+ * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002
****************************************************************************
* rrd__graph.c make creates ne rrds
****************************************************************************/
conv_if(DEF,GF_DEF)
conv_if(CDEF,GF_CDEF)
conv_if(VDEF,GF_VDEF)
+ conv_if(PART,GF_PART)
return (-1);
}
* further save step size and data source
* count of this rra
*/
- im->gdes[gdi].rpnp[rpi].data = im->gdes[ptr].data;
+ im->gdes[gdi].rpnp[rpi].data = im->gdes[ptr].data + im->gdes[ptr].ds;
im->gdes[gdi].rpnp[rpi].step = im->gdes[ptr].step;
im->gdes[gdi].rpnp[rpi].ds_cnt = im->gdes[ptr].ds_cnt;
case GF_DEF:
case GF_CDEF:
case GF_VDEF:
+ case GF_PART:
break;
}
}
case GF_LINE:
case GF_AREA:
case GF_TICK:
+ case GF_PART:
case GF_STACK:
case GF_HRULE:
case GF_VRULE:
{
int i,ii;
int lazy = lazy_check(im);
+ int piechart = 0;
+ double PieStart=0.0, PieSize, PieCenterX, PieCenterY;
FILE *fo;
gfx_canvas_t *canvas;
gfx_node_t *node;
if(im->title[0] != '\0')
im->yorigin += im->text_prop[TEXT_PROP_TITLE].size*3+4;
- im->xgif=20+im->xsize + im->xorigin;
+ im->xgif= 20 +im->xsize + im->xorigin;
im->ygif= im->yorigin+2* im->text_prop[TEXT_PROP_LEGEND].size;
-
+
+ /* check if we need to draw a piechart */
+ for(i=0;i<im->gdes_c;i++){
+ if (im->gdes[i].gf == GF_PART) {
+ piechart=1;
+ break;
+ }
+ }
+
+ if (piechart) {
+ /* allocate enough space for the piechart itself (PieSize), 20%
+ ** more for the background and an additional 50 pixels spacing.
+ */
+ if (im->xsize < im->ysize)
+ PieSize = im->xsize;
+ else
+ PieSize = im->ysize;
+ im->xgif += PieSize*1.2 + 50;
+
+ PieCenterX = im->xorigin + im->xsize + 50 + PieSize*0.6;
+ PieCenterY = im->yorigin - PieSize*0.5;
+ }
+
/* determine where to place the legends onto the graphics.
and set im->ygif to match space requirements for text */
if(leg_place(im)==-1)
canvas=gfx_new_canvas();
+
/* the actual graph is created by going through the individual
graph elements and then drawing them */
gfx_add_point(node,im->xorigin, im->yorigin - im->ysize);
-
+#if 0
+/******************************************************************
+ ** Just to play around. If you see this, I forgot to remove it **
+ ******************************************************************/
+ im->ygif+=100;
+ node=gfx_new_area(canvas,
+ 0, im->ygif-100,
+ im->xgif, im->ygif-100,
+ im->xgif, im->ygif,
+ im->graph_col[GRC_CANVAS]);
+ gfx_add_point(node,0,im->ygif);
+
+ node=gfx_new_line (canvas,
+ 0, im->ygif-100,
+ im->xgif-3, im->ygif-100,
+ 1.0,
+ 0xFF0000FF);
+ gfx_add_point(node,im->xgif-3,im->ygif-3);
+ gfx_add_point(node,2,im->ygif-3);
+ gfx_add_point(node,2,im->ygif-100);
+
+
+#if 0
+ node=gfx_new_area ( canvas,
+ 1, im->ygif-99,
+ im->xgif-1, im->ygif-99,
+ im->xgif-1, im->ygif-1,
+ im->graph_col[GRC_CANVAS]);
+ gfx_add_point(node,1,im->ygif-1);
+#endif
+
+#endif
+
+ if (piechart) {
+ int n;
+
+ node=gfx_new_area(canvas,
+ PieCenterX,PieCenterY-PieSize*0.6,
+ PieCenterX,PieCenterY,
+ PieCenterX,PieCenterY-PieSize*0.6,
+ im->graph_col[GRC_CANVAS]);
+ for (n=1;n<500;n++) {
+ double angle;
+ angle=M_PI*2.0*n/500.0;
+ gfx_add_point(node,
+ PieCenterX+sin(angle)*PieSize*0.6,
+ PieCenterY-cos(angle)*PieSize*0.6 );
+ }
+ }
+
if (im->minval > 0.0)
areazero = im->minval;
if (im->maxval < 0.0)
axis_paint(im,canvas);
- for(i=0;i<im->gdes_c;i++){
+ for(i=0;i<im->gdes_c;i++){
switch(im->gdes[i].gf){
case GF_CDEF:
case GF_VDEF:
}
lastgdes = &(im->gdes[i]);
break;
+ case GF_PART:
+ if(isnan(im->gdes[i].yrule)) /* fetch variable */
+ im->gdes[i].yrule = im->gdes[im->gdes[i].vidx].vf.val;
+
+ if (finite(im->gdes[i].yrule)) { /* even the fetched var can be NaN */
+ double angle,endangle;
+ int n;
+
+ angle=M_PI*2.0*PieStart/100.0;
+ endangle=M_PI*2.0*(PieStart+im->gdes[i].yrule)/100.0;
+ node=gfx_new_area(canvas,
+ PieCenterX+sin(endangle)*PieSize/2,
+ PieCenterY-cos(endangle)*PieSize/2,
+ PieCenterX,
+ PieCenterY,
+ PieCenterX+sin(angle)*PieSize/2,
+ PieCenterY-cos(angle)*PieSize/2,
+ im->gdes[i].col);
+ for (n=1;n<100;n++) {
+ angle=M_PI*2.0*(PieStart+n/100.0*im->gdes[i].yrule)/100.0;
+ gfx_add_point(node,
+ PieCenterX+sin(angle)*PieSize/2,
+ PieCenterY-cos(angle)*PieSize/2 );
+ }
+ PieStart += im->gdes[i].yrule;
+ }
+ break;
} /* switch */
}
grid_paint(im,canvas);
switch(im->gdes[i].gf){
case GF_HRULE:
- printf("DEBUG: HRULE at %f\n",im->gdes[i].yrule);
if(isnan(im->gdes[i].yrule)) { /* fetch variable */
im->gdes[i].yrule = im->gdes[im->gdes[i].vidx].vf.val;
};
}
break;
case 'n':{
- char *prop = "";
- double size = 1;
- char *font = "dummy";
-
- if(sscanf(optarg,
- "%10[A-Z]:%lf:%s",
- prop,&size,font) == 3){
- int sindex;
- if((sindex=text_prop_conv(prop)) != -1){
- im->text_prop[sindex].size=size;
- im->text_prop[sindex].font=font;
-
- } else {
- rrd_set_error("invalid color name '%s'",col_nam);
- }
- } else {
- rrd_set_error("invalid text property format");
- return;
- }
- break;
- }
+ /* originally this used char *prop = "" and
+ ** char *font = "dummy" however this results
+ ** in a SEG fault, at least on RH7.1
+ **
+ ** The current implementation isn't proper
+ ** either, font is never freed and prop uses
+ ** a fixed width string
+ */
+ char prop[100];
+ double size = 1;
+ char *font;
+
+ font=malloc(255);
+ if(sscanf(optarg,
+ "%10[A-Z]:%lf:%s",
+ prop,&size,font) == 3){
+ int sindex;
+ if((sindex=text_prop_conv(prop)) != -1){
+ im->text_prop[sindex].size=size;
+ im->text_prop[sindex].font=font;
+ if (sindex==0) { /* the default */
+ im->text_prop[TEXT_PROP_TITLE].size=size;
+ im->text_prop[TEXT_PROP_TITLE].font=font;
+ im->text_prop[TEXT_PROP_AXIS].size=size;
+ im->text_prop[TEXT_PROP_AXIS].font=font;
+ im->text_prop[TEXT_PROP_UNIT].size=size;
+ im->text_prop[TEXT_PROP_UNIT].font=font;
+ im->text_prop[TEXT_PROP_LEGEND].size=size;
+ im->text_prop[TEXT_PROP_LEGEND].font=font;
+ }
+ } else {
+ rrd_set_error("invalid fonttag '%s'",prop);
+ return;
+ }
+ } else {
+ rrd_set_error("invalid text property format");
+ return;
+ }
+ break;
+ }
case 'm':
im->zoom= atof(optarg);
if (im->zoom <= 0.0) {
/* function:newvname=string[:ds-name:CF] for xDEF
** function:vname[#color[:string]] for LINEx,AREA,STACK
** function:vname#color[:num[:string]] for TICK
- ** function:vname-or-num#color[:string] for xRULE
+ ** function:vname-or-num#color[:string] for xRULE,PART
** function:vname:CF:string for xPRINT
** function:string for COMMENT
*/
if (rrd_graph_legend(gdp,&line[argstart])==0)
rrd_set_error("Cannot parse comment in line: %s",line);
break;
+ case GF_PART:
case GF_VRULE:
case GF_HRULE:
j=k=l=m=0;