summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f4d3469)
raw | patch | inline | side by side (parent: f4d3469)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 3 Apr 2005 11:36:58 +0000 (11:36 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 3 Apr 2005 11:36:58 +0000 (11:36 +0000) |
index 907ff18833f337083b3c133f06a83b7b877d2478..9dcaf98f30082300340384cbd176ce507002b605 100644 (file)
=item B<AREA> C<:> I<vname> C<#> I<color> [ C<:> I<legend> ] [ C<:> C<STACK> ]
-=item B<PART> : I<vname> B<#> I<rrggbbaa> [ B<:> I<legend> ]
+=cut
+
+# =item B<PART> : I<vname> B<#> I<rrggbbaa> [ B<:> I<legend> ]
+
+=pod
=item B<TICK> : I<vname> B<#> I<rrggbbaa> [ : I<fraction> [ : I<legend> ] ]
B<LINEx> or B<AREA> it gets stacked on is not unknown. Use a CDEF
instruction with B<IF> and B<UN> to do so.
-=item B<PART> : I<vname> B<#> I<rrggbbaa> [ B<:> I<legend> ]
+=cut
-B<RRDtool> has now support for B<pie charts>. If you include the
-B<PART> command, the canvas is extended to make room for a chart
-The size of the canvas is determined by the lesser of
-L<width and height|rrdgraph/item_Size>.
+#=item B<PART> : I<vname> B<#> I<rrggbbaa> [ B<:> I<legend> ]
+#
+#B<RRDtool> has now support for B<pie charts>. If you include the
+#B<PART> command, the canvas is extended to make room for a chart
+#The size of the canvas is determined by the lesser of
+#L<width and height|rrdgraph/item_Size>.
+#
+#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<VDEF|rrdgraph_data/VDEF>
+#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<VDEF|rrdgraph_data/VDEF>
-function. It should return a number between 0 and 100, being a
-percentage. Providing wrong input will produce undefined results.
+=pod
=item B<TICK> : I<vname> B<#> I<rrggbbaa> [ : I<fraction> [ : I<legend> ] ]
is 0.1 (10% of the axis). Note that the color specification is not
optional.
-=back
-
-B<THE NEXT COMMAND IS NOT YET IMPLEMENTED>
-
-=over 4
-
=item B<SHIFT> : I<vname> , I<offset>
Using this command B<RRDtool> will graph the following elements
index 3be36d066da81bdc388f551812314579860ba45e..dacaa6f5a7e7db946931357c97ab5634f47a9da0 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
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)
case GF_DEF:
case GF_CDEF:
case GF_VDEF:
+#ifdef WITH_PIECHART
case GF_PART:
+#endif
case GF_SHIFT:
case GF_XPORT:
break;
return size;
}
+#ifdef WITH_PIECHART
void
pie_part(image_desc_t *im, gfx_color_t color,
double PieCenterX, double PieCenterY, double Radius,
}
}
+#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
}
}
+#ifdef WITH_PIECHART
if (piechart) {
im->piesize=im->xsize<im->ysize?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
}
#endif
+#ifdef WITH_PIECHART
/* The pie is placed in the upper right hand corner,
** just below the title (if any) and with sufficient
** padding.
im->pie_x = im->ximg/2;
im->pie_y = im->yorigin-Ypie/2;
}
+#endif
return 0;
}
{
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;
/* 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;i<im->gdes_c;i++){
if (im->gdes[i].gf == GF_PART) {
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
*/
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)
*** 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
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,
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;i<im->gdes_c;i++){
switch(im->gdes[i].gf){
}
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;
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);
index 0355a8c40c9f7ef61d423354458898fa5c16482b..10f583a7cc3fd717ad7d8b40a1466456202dcf54 100644 (file)
--- a/program/src/rrd_graph.h
+++ b/program/src/rrd_graph.h
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 */
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 */
/* 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 */
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 *);
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
index 44b115905749e3eefdb974b968034a06f910a3dc..e7712216e5d15c78f30e7a81fc06a5f373413339 100644 (file)
@@ -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;
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] */