From: oetiker Date: Sun, 3 Apr 2005 11:36:58 +0000 (+0000) Subject: the piechart code does not produce release ready results ... hide it behind WITH_PIEC... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5b2064dee177834d41e3b7051faa7dc6cee85853;p=rrdtool.git the piechart code does not produce release ready results ... hide it behind WITH_PIECHART define git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@334 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/doc/rrdgraph_graph.src b/doc/rrdgraph_graph.src index 907ff18..9dcaf98 100644 --- a/doc/rrdgraph_graph.src +++ b/doc/rrdgraph_graph.src @@ -34,7 +34,11 @@ =item B C<:> I C<#> I [ C<:> I ] [ C<:> C ] -=item B : I B<#> I [ B<:> I ] +=cut + +# =item B : I B<#> I [ B<:> I ] + +=pod =item B : I B<#> I [ : I [ : I ] ] @@ -222,18 +226,22 @@ graph this stacked variable anyway you need to make sure that the B or B it gets stacked on is not unknown. Use a CDEF instruction with B and B to do so. -=item B : I B<#> I [ B<:> I ] +=cut -B has now support for B. If you include the -B command, the canvas is extended to make room for a chart -The size of the canvas is determined by the lesser of -L. +#=item B : I B<#> I [ B<:> I ] +# +#B has now support for B. If you include the +#B command, the canvas is extended to make room for a chart +#The size of the canvas is determined by the lesser of +#L. +# +#Pie parts will be concatenated, the first one will start at the +#top and parts will be created clockwise. The size of the part +#is defined by the value part of the L +#function. It should return a number between 0 and 100, being a +#percentage. Providing wrong input will produce undefined results. -Pie parts will be concatenated, the first one will start at the -top and parts will be created clockwise. The size of the part -is defined by the value part of the L -function. It should return a number between 0 and 100, being a -percentage. Providing wrong input will produce undefined results. +=pod =item B : I B<#> I [ : I [ : I ] ] @@ -243,12 +251,6 @@ length of the tick mark as a fraction of the y-axis; the default value is 0.1 (10% of the axis). Note that the color specification is not optional. -=back - -B - -=over 4 - =item B : I , I Using this command B will graph the following elements diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 3be36d0..dacaa6f 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -183,7 +183,9 @@ enum gf_en gf_conv(char *string){ conv_if(DEF,GF_DEF) conv_if(CDEF,GF_CDEF) conv_if(VDEF,GF_VDEF) +#ifdef WITH_PIECHART conv_if(PART,GF_PART) +#endif conv_if(XPORT,GF_XPORT) conv_if(SHIFT,GF_SHIFT) @@ -1355,7 +1357,9 @@ print_calc(image_desc_t *im, char ***prdata) case GF_DEF: case GF_CDEF: case GF_VDEF: +#ifdef WITH_PIECHART case GF_PART: +#endif case GF_SHIFT: case GF_XPORT: break; @@ -2006,6 +2010,7 @@ int lazy_check(image_desc_t *im){ return size; } +#ifdef WITH_PIECHART void pie_part(image_desc_t *im, gfx_color_t color, double PieCenterX, double PieCenterY, double Radius, @@ -2052,8 +2057,16 @@ pie_part(image_desc_t *im, gfx_color_t color, } } +#endif + int -graph_size_location(image_desc_t *im, int elements, int piechart ) +graph_size_location(image_desc_t *im, int elements + +#ifdef WITH_PIECHART +, int piechart +#endif + + ) { /* The actual size of the image to draw is determined from ** several sources. The size given on the command line is @@ -2125,11 +2138,13 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) } } +#ifdef WITH_PIECHART if (piechart) { im->piesize=im->xsizeysize?im->xsize:im->ysize; Xpie=im->piesize; Ypie=im->piesize; } +#endif /* Now calculate the total size. Insert some spacing where desired. im->xorigin and im->yorigin need to correspond @@ -2217,6 +2232,7 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) } #endif +#ifdef WITH_PIECHART /* The pie is placed in the upper right hand corner, ** just below the title (if any) and with sufficient ** padding. @@ -2228,6 +2244,7 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) im->pie_x = im->ximg/2; im->pie_y = im->yorigin-Ypie/2; } +#endif return 0; } @@ -2238,8 +2255,10 @@ graph_paint(image_desc_t *im, char ***calcpr) { int i,ii; int lazy = lazy_check(im); +#ifdef WITH_PIECHART int piechart = 0; double PieStart=0.0; +#endif FILE *fo; gfx_node_t *node; @@ -2258,7 +2277,8 @@ graph_paint(image_desc_t *im, char ***calcpr) /* evaluate VDEF and CDEF operations ... */ if(data_calc(im)==-1) return -1; - + +#ifdef WITH_PIECHART /* check if we need to draw a piechart */ for(i=0;igdes_c;i++){ if (im->gdes[i].gf == GF_PART) { @@ -2266,6 +2286,7 @@ graph_paint(image_desc_t *im, char ***calcpr) break; } } +#endif /* calculate and PRINT and GPRINT definitions. We have to do it at * this point because it will affect the length of the legends @@ -2274,10 +2295,16 @@ graph_paint(image_desc_t *im, char ***calcpr) */ i=print_calc(im,calcpr); if(i<0) return -1; - if(((i==0)&&(piechart==0)) || lazy) return 0; + if(((i==0) +#ifdef WITH_PIECHART +&&(piechart==0) +#endif +) || lazy) return 0; +#ifdef WITH_PIECHART /* If there's only the pie chart to draw, signal this */ if (i==0) piechart=2; +#endif /* get actual drawing data and find min and max values*/ if(data_proc(im)==-1) @@ -2300,7 +2327,11 @@ graph_paint(image_desc_t *im, char ***calcpr) *** Calculating sizes and locations became a bit confusing *** *** so I moved this into a separate function. *** **************************************************************/ - if(graph_size_location(im,i,piechart)==-1) + if(graph_size_location(im,i +#ifdef WITH_PIECHART +,piechart +#endif +)==-1) return -1; /* the actual graph is created by going through the individual @@ -2314,7 +2345,9 @@ graph_paint(image_desc_t *im, char ***calcpr) gfx_add_point(node,0, im->yimg); +#ifdef WITH_PIECHART if (piechart != 2) { +#endif node=gfx_new_area ( im->canvas, im->xorigin, im->yorigin, im->xorigin + im->xsize, im->yorigin, @@ -2327,11 +2360,15 @@ graph_paint(image_desc_t *im, char ***calcpr) areazero = im->minval; if (im->maxval < 0.0) areazero = im->maxval; - } +#ifdef WITH_PIECHART + } +#endif +#ifdef WITH_PIECHART if (piechart) { pie_part(im,im->graph_col[GRC_CANVAS],im->pie_x,im->pie_y,im->piesize*0.5,0,2*M_PI); } +#endif for(i=0;igdes_c;i++){ switch(im->gdes[i].gf){ @@ -2460,6 +2497,7 @@ graph_paint(image_desc_t *im, char ***calcpr) } lastgdes = &(im->gdes[i]); break; +#ifdef WITH_PIECHART case GF_PART: if(isnan(im->gdes[i].yrule)) /* fetch variable */ im->gdes[i].yrule = im->gdes[im->gdes[i].vidx].vf.val; @@ -2472,12 +2510,16 @@ graph_paint(image_desc_t *im, char ***calcpr) PieStart += im->gdes[i].yrule; } break; +#endif + } /* switch */ } +#ifdef WITH_PIECHART if (piechart==2) { im->draw_x_grid=0; im->draw_y_grid=0; } +#endif if( !(im->extra_flags & ONLY_GRAPH) ) axis_paint(im); diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 0355a8c..10f583a 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -29,7 +29,10 @@ enum grc_en {GRC_CANVAS=0,GRC_BACK,GRC_SHADEA,GRC_SHADEB, enum gf_en {GF_PRINT=0,GF_GPRINT,GF_COMMENT,GF_HRULE,GF_VRULE,GF_LINE, GF_AREA,GF_STACK,GF_TICK, GF_DEF, GF_CDEF, GF_VDEF, GF_SHIFT, - GF_PART, GF_XPORT}; +#ifdef WITH_PIECHART + GF_PART, +#endif + GF_XPORT}; enum vdef_op_en { VDEF_MAXIMUM /* like the MAX in (G)PRINT */ @@ -137,7 +140,10 @@ typedef struct image_desc_t { char graphfile[MAXPATH]; /* filename for graphic */ FILE *graphhandle; /* FILE to use if filename is "-" */ - long xsize,ysize,piesize; /* graph area size in pixels */ + long xsize,ysize; /* graph area size in pixels */ +#ifdef WITH_PIECHART + long piesize; /* size of the piechart */ +#endif gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */ text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */ char ylegend[200]; /* legend along the yaxis */ @@ -169,7 +175,9 @@ typedef struct image_desc_t { /* status information */ long xorigin,yorigin;/* where is (0,0) of the graph */ +#ifdef WITH_PIECHART long pie_x,pie_y; /* where is the centerpoint */ +#endif long ximg,yimg; /* total size of the image */ double magfact; /* numerical magnitude*/ long base; /* 1000 or 1024 depending on what we graph */ @@ -216,7 +224,9 @@ void axis_paint(image_desc_t *); void grid_paint(image_desc_t *); int lazy_check(image_desc_t *); int graph_paint(image_desc_t *, char ***); +#ifdef WITH_PIECHART void pie_part(image_desc_t *, gfx_color_t, double, double, double, double, double); +#endif int gdes_alloc(image_desc_t *); int scan_for_col(char *, int, char *); int rrd_graph(int, char **, char ***, int *, int *, FILE *, double *, double *); @@ -229,6 +239,10 @@ int bad_format(char *); int vdef_parse(struct graph_desc_t *,char *); int vdef_calc(image_desc_t *, int); int vdef_percent_compar(const void *,const void *); -int graph_size_location(image_desc_t *, int, int); +int graph_size_location(image_desc_t *, int +#ifdef WITH_PIECHART + ,int +#endif +); #endif diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 44b1159..e771221 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -347,7 +347,9 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc /* PART, HRULE, VRULE and TICK cannot be stacked. We're finished */ if ( (gdp->gf == GF_HRULE) || (gdp->gf == GF_VRULE) +#ifdef WITH_PIECHART || (gdp->gf == GF_PART) +#endif || (gdp->gf == GF_TICK) ) return 0; @@ -587,7 +589,9 @@ rrd_graph_script(int argc, char *argv[], image_desc_t *im, int optno) { case GF_COMMENT: /* text */ if (rrd_parse_legend(argv[i],&eaten,gdp)) return; break; +#ifdef WITH_PIECHART case GF_PART: /* value[#color[:legend]] */ +#endif case GF_VRULE: /* value#color[:legend] */ case GF_HRULE: /* value#color[:legend] */ case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */