From ee654538c16b841f0be305e7cc2f0952e433c5b8 Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 4 Aug 2005 04:58:11 +0000 Subject: [PATCH] avoid drawing lines where two points are in the same spot. this mai be confusing libart git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@667 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_graph.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index bb31289e..2a13cb54 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -2472,31 +2472,35 @@ graph_paint(image_desc_t *im, char ***calcpr) if (im->gdes[i].col != 0x0){ /* GF_LINE and friend */ if(stack_gf == GF_LINE ){ + double last_y=0; node = NULL; - for(ii=1;iixsize;ii++){ + for(ii=1;iixsize;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,ytr(im,im->gdes[i].p_data[ii]), - ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]), + 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,ytr(im,im->gdes[i].p_data[ii]), + ii+im->xorigin,last_y, im->gdes[i].linewidth, im->gdes[i].col); } } else { - if ( im->slopemode==0 ){ - gfx_add_point(node,ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii])); + double new_y = ytr(im,im->gdes[i].p_data[ii]); + if ( im->slopemode==0 && new_y != last_y){ + gfx_add_point(node,ii-1+im->xorigin,new_y); + last_y = new_y; }; - gfx_add_point(node,ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii])); + gfx_add_point(node,ii+im->xorigin,new_y); }; } -- 2.30.2