summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 918ac20)
raw | patch | inline | side by side (parent: 918ac20)
author | alex <alex@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 17 Mar 2002 22:40:18 +0000 (22:40 +0000) | ||
committer | alex <alex@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 17 Mar 2002 22:40:18 +0000 (22:40 +0000) |
program/src/rrd_gfx.c | patch | blob | history | |
program/src/rrd_gfx.h | patch | blob | history | |
program/src/rrd_graph.c | patch | blob | history |
diff --git a/program/src/rrd_gfx.c b/program/src/rrd_gfx.c
index 1a45439da3d0eb542967f9499cccee785962fb0b..405291b345f3303a7c91790885c4ea07b81f6179 100644 (file)
--- a/program/src/rrd_gfx.c
+++ b/program/src/rrd_gfx.c
return node;
}
-/* create an arc section (2*M_PI is full circle) */
-gfx_node_t *gfx_arc_sect (gfx_canvas_t *canvas,
- double centerx, double centery,
- double radiusx, double radiusy,
- double start, double end,
- gfx_color_t color) {
-
- gfx_node_t *node;
- ArtVpath *vec;
- int counter;
- double position;
-
-/* 20 is too low, 100 is overkill */
-#define AMOUNT_OF_VECTORS 50
-
- node = gfx_new_node(canvas,GFX_AREA);
- if (node == NULL) return NULL;
- vec = art_new(ArtVpath, AMOUNT_OF_VECTORS+4);
- if (vec == NULL) return NULL;
-
- vec[0].code = ART_MOVETO;
- vec[0].x = centerx;
- vec[0].y = centery;
-
- for (counter=0;counter<=AMOUNT_OF_VECTORS;) {
- position=start + counter*(end-start)/AMOUNT_OF_VECTORS;
-
- counter++;
- vec[counter].code = ART_LINETO;
- vec[counter].x = centerx + sin(position)*radiusx;
- vec[counter].y = centery - cos(position)*radiusy;
- }
-
- vec[AMOUNT_OF_VECTORS+2].code = ART_LINETO;
- vec[AMOUNT_OF_VECTORS+2].x = centerx;
- vec[AMOUNT_OF_VECTORS+2].y = centery;
-
- vec[AMOUNT_OF_VECTORS+3].code = ART_END;
-
- node->points = AMOUNT_OF_VECTORS+4;
- node->points_max = AMOUNT_OF_VECTORS+4;
- node->color = color;
- node->path = vec;
-
- return node;
-}
/* add a point to a line or to an area */
int gfx_add_point (gfx_node_t *node,
diff --git a/program/src/rrd_gfx.h b/program/src/rrd_gfx.h
index 8362ff16b564ce0b91f751c0d0c4a9ce017dbce3..808b7c40a84a9545c44558d1ebd5077ad2e9f085 100644 (file)
--- a/program/src/rrd_gfx.h
+++ b/program/src/rrd_gfx.h
double x2, double y2,
gfx_color_t color);
-/* create an arc section (2*M_PI is full circle) */
-gfx_node_t *gfx_arc_sect (gfx_canvas_t *canvas,
- double centerx, double centery,
- double radiusx, double radiusy,
- double start, double end,
- gfx_color_t color);
-
/* add a point to a line or to an area */
int gfx_add_point (gfx_node_t *node, double x, double y);
index c7ba63e62d9493c214a2a06fdb93216ad8a50127..ea7ed0d2f6474a5ed389da6b6e4059efef951c3a 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
{
int i,ii;
int lazy = lazy_check(im);
- int piechart = 0, PieSize, PieCenterX, PieCenterY;
- double PieStart=0.0;
+ int piechart = 0;
+ double PieStart=0.0, PieSize, PieCenterX, PieCenterY;
FILE *fo;
gfx_canvas_t *canvas;
gfx_node_t *node;
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 (piechart) {
-#if 1
- node=gfx_arc_sect (canvas,
- PieCenterX,PieCenterY,
- PieSize*0.6, PieSize*0.6, /* 20% more as background */
- 0,M_PI*2,
- im->graph_col[GRC_CANVAS]);
-#else
- node=gfx_new_area ( canvas,
- PieCenterX-0.6*PieSize, PieCenterY-0.6*PieSize,
- PieCenterX+0.6*PieSize, PieCenterY-0.6*PieSize,
- PieCenterX+0.6*PieSize, PieCenterY+0.6*PieSize,
- im->graph_col[GRC_CANVAS]);
- gfx_add_point(node,
- PieCenterX-0.6*PieSize, PieCenterY+0.6*PieSize);
+#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)
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 */
- node=gfx_arc_sect(canvas,
- PieCenterX, PieCenterY,
- PieSize/2,PieSize/2,
- M_PI*2.0*PieStart/100.0,
- M_PI*2.0*(PieStart+im->gdes[i].yrule)/100.0,
+ 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;