- for(i=0;i<im->gdes_c;i++){
- switch(im->gdes[i].gf){
- case GF_CDEF:
- case GF_VDEF:
- case GF_DEF:
- case GF_PRINT:
- case GF_GPRINT:
- case GF_COMMENT:
- case GF_HRULE:
- case GF_VRULE:
- case GF_XPORT:
- case GF_SHIFT:
- break;
- case GF_TICK:
- for (ii = 0; ii < im->xsize; ii++)
- {
- if (!isnan(im->gdes[i].p_data[ii]) &&
- im->gdes[i].p_data[ii] != 0.0)
- {
- if (im -> gdes[i].yrule > 0 ) {
- gfx_new_line(im->canvas,
- im -> xorigin + ii, im->yorigin,
- im -> xorigin + ii, im->yorigin - im -> gdes[i].yrule * im -> ysize,
- 1.0,
- im -> gdes[i].col );
- } else if ( im -> gdes[i].yrule < 0 ) {
- gfx_new_line(im->canvas,
- im -> xorigin + ii, im->yorigin - im -> ysize,
- im -> xorigin + ii, im->yorigin - ( 1 - im -> gdes[i].yrule ) * im -> ysize,
- 1.0,
- im -> gdes[i].col );
-
- }
- }
- }
- break;
- case GF_LINE:
- case GF_AREA:
- /* fix data points at oo and -oo */
- for(ii=0;ii<im->xsize;ii++){
- if (isinf(im->gdes[i].p_data[ii])){
- if (im->gdes[i].p_data[ii] > 0) {
- im->gdes[i].p_data[ii] = im->maxval ;
- } else {
- im->gdes[i].p_data[ii] = im->minval ;
- }
-
- }
- } /* for */
-
- /* *******************************************************
- a ___. (a,t)
- | | ___
- ____| | | |
- | |___|
- -------|--t-1--t--------------------------------
-
- if we know the value at time t was a then
- we draw a square from t-1 to t with the value a.
-
- ********************************************************* */
- if (im->gdes[i].col != 0x0){
- /* GF_LINE and friend */
- if(im->gdes[i].gf == GF_LINE ){
- double last_y=0.0;
- node = NULL;
- for(ii=1;ii<im->xsize;ii++){
- if (isnan(im->gdes[i].p_data[ii]) || (im->slopemode==1 && isnan(im->gdes[i].p_data[ii-1]))){
- node = NULL;
- continue;
- }
- if ( node == NULL ) {
- last_y = ytr(im,im->gdes[i].p_data[ii]);
- if ( im->slopemode == 0 ){
- node = gfx_new_line(im->canvas,
- ii-1+im->xorigin,last_y,
- ii+im->xorigin,last_y,
- im->gdes[i].linewidth,
- im->gdes[i].col);
- } else {
- node = gfx_new_line(im->canvas,
- ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii-1]),
- ii+im->xorigin,last_y,
- im->gdes[i].linewidth,
- im->gdes[i].col);
- }
- } else {
- double new_y = ytr(im,im->gdes[i].p_data[ii]);
- if ( im->slopemode==0 && ! AlmostEqual2sComplement(new_y,last_y,4)){
- gfx_add_point(node,ii-1+im->xorigin,new_y);
- };
- last_y = new_y;
- gfx_add_point(node,ii+im->xorigin,new_y);
- };
-
- }
- } else {
- int idxI=-1;
- double *foreY=malloc(sizeof(double)*im->xsize*2);
- double *foreX=malloc(sizeof(double)*im->xsize*2);
- double *backY=malloc(sizeof(double)*im->xsize*2);
- double *backX=malloc(sizeof(double)*im->xsize*2);
- int drawem = 0;
- for(ii=0;ii<=im->xsize;ii++){
- double ybase,ytop;
- if ( idxI > 0 && ( drawem != 0 || ii==im->xsize)){
- int cntI=1;
- int lastI=0;
- while (cntI < idxI && AlmostEqual2sComplement(foreY[lastI],foreY[cntI],4) && AlmostEqual2sComplement(foreY[lastI],foreY[cntI+1],4)){cntI++;}
- node = gfx_new_area(im->canvas,
- backX[0],backY[0],
- foreX[0],foreY[0],
- foreX[cntI],foreY[cntI], im->gdes[i].col);
- while (cntI < idxI) {
- lastI = cntI;
- cntI++;
- while ( cntI < idxI && AlmostEqual2sComplement(foreY[lastI],foreY[cntI],4) && AlmostEqual2sComplement(foreY[lastI],foreY[cntI+1],4)){cntI++;}
- gfx_add_point(node,foreX[cntI],foreY[cntI]);
- }
- gfx_add_point(node,backX[idxI],backY[idxI]);
- while (idxI > 1){
- lastI = idxI;
- idxI--;
- while ( idxI > 1 && AlmostEqual2sComplement(backY[lastI], backY[idxI],4) && AlmostEqual2sComplement(backY[lastI],backY[idxI-1],4)){idxI--;}
- gfx_add_point(node,backX[idxI],backY[idxI]);
- }
- idxI=-1;
- drawem = 0;
- }
- if (drawem != 0){
- drawem = 0;
- idxI=-1;
- }
- if (ii == im->xsize) break;
-
- /* keep things simple for now, just draw these bars
- do not try to build a big and complex area */
-
-
- if ( im->slopemode == 0 && ii==0){
- continue;
- }
- if ( isnan(im->gdes[i].p_data[ii]) ) {
- drawem = 1;
- continue;
- }
- ytop = ytr(im,im->gdes[i].p_data[ii]);
- if ( lastgdes && im->gdes[i].stack ) {
- ybase = ytr(im,lastgdes->p_data[ii]);
- } else {
- ybase = ytr(im,areazero);
- }
- if ( ybase == ytop ){
- drawem = 1;
- continue;
- }
- /* every area has to be wound clock-wise,
- so we have to make sur base remains base */
- if (ybase > ytop){
- double extra = ytop;
- ytop = ybase;
- ybase = extra;
- }
- if ( im->slopemode == 0 ){
- backY[++idxI] = ybase-0.2;
- backX[idxI] = ii+im->xorigin-1;
- foreY[idxI] = ytop+0.2;
- foreX[idxI] = ii+im->xorigin-1;
- }
- backY[++idxI] = ybase-0.2;
- backX[idxI] = ii+im->xorigin;
- foreY[idxI] = ytop+0.2;
- foreX[idxI] = ii+im->xorigin;
- }
- /* close up any remaining area */
- free(foreY);
- free(foreX);
- free(backY);
- free(backX);
- } /* else GF_LINE */
- } /* if color != 0x0 */
- /* make sure we do not run into trouble when stacking on NaN */
- for(ii=0;ii<im->xsize;ii++){
- if (isnan(im->gdes[i].p_data[ii])) {
- if (lastgdes && (im->gdes[i].stack)) {
- im->gdes[i].p_data[ii] = lastgdes->p_data[ii];
- } else {
- im->gdes[i].p_data[ii] = areazero;
- }
- }
- }
- 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;
-
- if (finite(im->gdes[i].yrule)) { /* even the fetched var can be NaN */
- pie_part(im,im->gdes[i].col,
- im->pie_x,im->pie_y,im->piesize*0.4,
- M_PI*2.0*PieStart/100.0,
- M_PI*2.0*(PieStart+im->gdes[i].yrule)/100.0);
- PieStart += im->gdes[i].yrule;
- }
- break;
-#endif
- case GF_STACK:
- rrd_set_error("STACK should already be turned into LINE or AREA here");
- return -1;
- break;
-
- } /* switch */
- }
-#ifdef WITH_PIECHART
- if (piechart==2) {
- im->draw_x_grid=0;
- im->draw_y_grid=0;
- }
-#endif