[rrd-developers] Re: proposed TICK bug fix for negative values

Tobias Oetiker oetiker at ee.ethz.ch
Wed Feb 1 22:05:04 MET 2006


Or even better:

Index: rrd_graph.c
===================================================================
--- rrd_graph.c (revision 746)
+++ rrd_graph.c (working copy)
@@ -2468,13 +2468,32 @@
           if (!isnan(im->gdes[i].p_data[ii]) &&
               im->gdes[i].p_data[ii] > 0.0)
             {
+             double ya = ytr(im,0);
+             double yb = ytr(im,0) - (im -> gdes[i].yrule * im -> ysize);
+
+             if (ya > im->yorigin) {
+                 ya = im->yorigin;
+                 yb = ya - (im -> gdes[i].yrule * im -> ysize);
+             }
+             if (ya < im->yorigin - im->ysize) {
+                 ya = im->yorigin - im->ysize;
+                 yb = ya + (im -> gdes[i].yrule * im -> ysize);
+             }
+
+             if (yb > im->yorigin)
+                 yb = im->yorigin;
+             if (yb < im->yorigin - im->ysize)
+                 yb = im->yorigin - im->ysize;
+
               /* generate a tick */
-              gfx_new_line(im->canvas, im -> xorigin + ii,
-                           im -> yorigin - (im -> gdes[i].yrule * im -> ysize),
-                           im -> xorigin + ii,
-                           im -> yorigin,
-                           1.0,
-                           im -> gdes[i].col );
+             if (ya != yb)
+                     gfx_new_line(im->canvas, im -> xorigin + ii,
+                                  ya,
+                                  im -> xorigin + ii,
+                                  yb,
+                                  1.0,
+                                  im -> gdes[i].col );
+
             }
         }
       break;


cheers
tobi

-- 
 ______    __   _
/_  __/_  / /  (_) Oetiker @ ISG.EE, ETL F24.2, ETH, CH-8092 Zurich
 / // _ \/ _ \/ /  System Manager, Time Lord, Coder, Designer, Coach
/_/ \.__/_.__/_/   http://people.ee.ethz.ch/oetiker +41(0)44-632-5286

--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-developers
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-developers mailing list