projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* fix transparency rendering by rewinding the paths propperly
[rrdtool.git]
/
src
/
rrd_graph.c
diff --git
a/src/rrd_graph.c
b/src/rrd_graph.c
index
37e1961
..
0279d49
100644
(file)
--- a/
src/rrd_graph.c
+++ b/
src/rrd_graph.c
@@
-1,5
+1,5
@@
/****************************************************************************
/****************************************************************************
- * RRDtool 1.2
.x Copyright Tobias Oetiker, 1997 -
2005
+ * RRDtool 1.2
rc2 Copyright by Tobi Oetiker, 1997-
2005
****************************************************************************
* rrd__graph.c produce graphs from data in rrdfiles
****************************************************************************/
****************************************************************************
* rrd__graph.c produce graphs from data in rrdfiles
****************************************************************************/
@@
-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)
conv_if(DEF,GF_DEF)
conv_if(CDEF,GF_CDEF)
conv_if(VDEF,GF_VDEF)
+#ifdef WITH_PIECHART
conv_if(PART,GF_PART)
conv_if(PART,GF_PART)
+#endif
conv_if(XPORT,GF_XPORT)
conv_if(SHIFT,GF_SHIFT)
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:
case GF_DEF:
case GF_CDEF:
case GF_VDEF:
+#ifdef WITH_PIECHART
case GF_PART:
case GF_PART:
+#endif
case GF_SHIFT:
case GF_XPORT:
break;
case GF_SHIFT:
case GF_XPORT:
break;
@@
-1801,15
+1805,15
@@
vertical_grid(
}
/* paint the labels below the graph */
}
/* paint the labels below the graph */
- for(ti = find_first_time(im->start,
+ for(ti = find_first_time(im->start
- im->xlab_user.precis/2
,
im->xlab_user.labtm,
im->xlab_user.labst);
im->xlab_user.labtm,
im->xlab_user.labst);
- ti <= im->end;
+ ti <= im->end
- im->xlab_user.precis/2
;
ti = find_next_time(ti,im->xlab_user.labtm,im->xlab_user.labst)
){
tilab= ti + im->xlab_user.precis/2; /* correct time for the label */
/* are we inside the graph ? */
ti = find_next_time(ti,im->xlab_user.labtm,im->xlab_user.labst)
){
tilab= ti + im->xlab_user.precis/2; /* correct time for the label */
/* are we inside the graph ? */
- if (ti
< im->start || ti
> im->end) continue;
+ if (ti
lab < im->start || tilab
> im->end) continue;
#if HAVE_STRFTIME
localtime_r(&tilab, &tm);
#if HAVE_STRFTIME
localtime_r(&tilab, &tm);
@@
-1958,6
+1962,14
@@
grid_paint(image_desc_t *im)
im->tabwidth,"M", 0)*1.2;
boxV = boxH;
im->tabwidth,"M", 0)*1.2;
boxV = boxH;
+ /* make sure transparent colors show up all the same */
+ node = gfx_new_area(im->canvas,
+ X0,Y0-boxV,
+ X0,Y0,
+ X0+boxH,Y0,
+ im->graph_col[GRC_CANVAS]);
+ gfx_add_point ( node, X0+boxH, Y0-boxV );
+
node = gfx_new_area(im->canvas,
X0,Y0-boxV,
X0,Y0,
node = gfx_new_area(im->canvas,
X0,Y0-boxV,
X0,Y0,
@@
-1966,7
+1978,7
@@
grid_paint(image_desc_t *im)
gfx_add_point ( node, X0+boxH, Y0-boxV );
node = gfx_new_line(im->canvas,
X0,Y0-boxV, X0,Y0,
gfx_add_point ( node, X0+boxH, Y0-boxV );
node = gfx_new_line(im->canvas,
X0,Y0-boxV, X0,Y0,
- 1,
0x000000FF
);
+ 1,
im->graph_col[GRC_FONT]
);
gfx_add_point(node,X0+boxH,Y0);
gfx_add_point(node,X0+boxH,Y0-boxV);
gfx_close_path(node);
gfx_add_point(node,X0+boxH,Y0);
gfx_add_point(node,X0+boxH,Y0-boxV);
gfx_close_path(node);
@@
-2006,6
+2018,7
@@
int lazy_check(image_desc_t *im){
return size;
}
return size;
}
+#ifdef WITH_PIECHART
void
pie_part(image_desc_t *im, gfx_color_t color,
double PieCenterX, double PieCenterY, double Radius,
void
pie_part(image_desc_t *im, gfx_color_t color,
double PieCenterX, double PieCenterY, double Radius,
@@
-2052,8
+2065,16
@@
pie_part(image_desc_t *im, gfx_color_t color,
}
}
}
}
+#endif
+
int
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
{
/* The actual size of the image to draw is determined from
** several sources. The size given on the command line is
@@
-2125,11
+2146,13
@@
graph_size_location(image_desc_t *im, int elements, int piechart )
}
}
}
}
+#ifdef WITH_PIECHART
if (piechart) {
im->piesize=im->xsize<im->ysize?im->xsize:im->ysize;
Xpie=im->piesize;
Ypie=im->piesize;
}
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
/* Now calculate the total size. Insert some spacing where
desired. im->xorigin and im->yorigin need to correspond
@@
-2217,6
+2240,7
@@
graph_size_location(image_desc_t *im, int elements, int piechart )
}
#endif
}
#endif
+#ifdef WITH_PIECHART
/* The pie is placed in the upper right hand corner,
** just below the title (if any) and with sufficient
** padding.
/* The pie is placed in the upper right hand corner,
** just below the title (if any) and with sufficient
** padding.
@@
-2228,6
+2252,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;
}
im->pie_x = im->ximg/2;
im->pie_y = im->yorigin-Ypie/2;
}
+#endif
return 0;
}
return 0;
}
@@
-2238,8
+2263,10
@@
graph_paint(image_desc_t *im, char ***calcpr)
{
int i,ii;
int lazy = lazy_check(im);
{
int i,ii;
int lazy = lazy_check(im);
+#ifdef WITH_PIECHART
int piechart = 0;
double PieStart=0.0;
int piechart = 0;
double PieStart=0.0;
+#endif
FILE *fo;
gfx_node_t *node;
FILE *fo;
gfx_node_t *node;
@@
-2258,7
+2285,8
@@
graph_paint(image_desc_t *im, char ***calcpr)
/* evaluate VDEF and CDEF operations ... */
if(data_calc(im)==-1)
return -1;
/* 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) {
/* check if we need to draw a piechart */
for(i=0;i<im->gdes_c;i++){
if (im->gdes[i].gf == GF_PART) {
@@
-2266,6
+2294,7
@@
graph_paint(image_desc_t *im, char ***calcpr)
break;
}
}
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
/* 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
+2303,16
@@
graph_paint(image_desc_t *im, char ***calcpr)
*/
i=print_calc(im,calcpr);
if(i<0) return -1;
*/
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;
/* 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)
/* get actual drawing data and find min and max values*/
if(data_proc(im)==-1)
@@
-2300,7
+2335,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. ***
**************************************************************/
*** 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
return -1;
/* the actual graph is created by going through the individual
@@
-2314,7
+2353,9
@@
graph_paint(image_desc_t *im, char ***calcpr)
gfx_add_point(node,0, im->yimg);
gfx_add_point(node,0, im->yimg);
+#ifdef WITH_PIECHART
if (piechart != 2) {
if (piechart != 2) {
+#endif
node=gfx_new_area ( im->canvas,
im->xorigin, im->yorigin,
im->xorigin + im->xsize, im->yorigin,
node=gfx_new_area ( im->canvas,
im->xorigin, im->yorigin,
im->xorigin + im->xsize, im->yorigin,
@@
-2327,11
+2368,15
@@
graph_paint(image_desc_t *im, char ***calcpr)
areazero = im->minval;
if (im->maxval < 0.0)
areazero = im->maxval;
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);
}
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){
for(i=0;i<im->gdes_c;i++){
switch(im->gdes[i].gf){
@@
-2460,6
+2505,7
@@
graph_paint(image_desc_t *im, char ***calcpr)
}
lastgdes = &(im->gdes[i]);
break;
}
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;
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
+2518,16
@@
graph_paint(image_desc_t *im, char ***calcpr)
PieStart += im->gdes[i].yrule;
}
break;
PieStart += im->gdes[i].yrule;
}
break;
+#endif
+
} /* switch */
}
} /* switch */
}
+#ifdef WITH_PIECHART
if (piechart==2) {
im->draw_x_grid=0;
im->draw_y_grid=0;
}
if (piechart==2) {
im->draw_x_grid=0;
im->draw_y_grid=0;
}
+#endif
if( !(im->extra_flags & ONLY_GRAPH) )
axis_paint(im);
if( !(im->extra_flags & ONLY_GRAPH) )
axis_paint(im);
@@
-2978,7
+3028,7
@@
rrd_graph_options(int argc, char *argv[],image_desc_t *im)
char font[1024];
if(sscanf(optarg,
char font[1024];
if(sscanf(optarg,
- "%10[A-Z]:%lf:%s",
+ "%10[A-Z]:%lf:%
1000
s",
prop,&size,font) == 3){
int sindex;
if((sindex=text_prop_conv(prop)) != -1){
prop,&size,font) == 3){
int sindex;
if((sindex=text_prop_conv(prop)) != -1){