Alex,
thanks for investigating this. the problem was that in the code for
handline the case where min==max was written with positive (or 0)
as values form min and max ... the fix is attached ...
cheers
tobi
Today Alex van den Bogaerdt wrote:
> On Mon, Nov 19, 2007 at 11:44:04PM +0100, Tobias Oetiker wrote:
> > Hi Alex,
> >
> > what is the 'bug' at least for me this script runs fine with
> > rrdtool 1.2.23 ...
>
> The graph command does not finish, see also the discussion on
> the rrd-users list started by Hans-Joachim Ehlers, subject
> rrdtool graph ( v1.2.24 ) hangs on AIX 5.3
>
> I notice I omitted "--start 1195426800 --end start+1h" from the
> script I copied in my previous post. Sorry. The line should read:
>
> $rrd graph --start 1195426800 --end start+1h $v.png DEF:x=test.rrd:x:AVERAGE
> LINE1:x#FF0000:x
>
> Exact times aren't important, the key factor is that all known rates are
> below zero.
>
> cheers,
> Alex
>
> _______________________________________________
> rrd-developers mailing list
> [email protected]
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
>
>
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten
http://it.oetiker.ch [EMAIL PROTECTED] ++41 62 213 9902
Index: rrd_graph.c
===================================================================
--- rrd_graph.c (revision 1222)
+++ rrd_graph.c (working copy)
@@ -423,7 +423,7 @@
im->minval = sensiblevalues[i]*(im->magfact);
if (-sensiblevalues[i-1]<=scaled_min &&
- -sensiblevalues[i]>=scaled_min)
+ -sensiblevalues[i]>=scaled_min)
im->minval = -sensiblevalues[i-1]*(im->magfact);
if (sensiblevalues[i-1] >= scaled_max &&
@@ -497,11 +497,14 @@
double new_range = factor * (im->maxval - im->minval);
double gridstep = im->ygrid_scale.gridstep;
double minor_y, minor_y_px, minor_y_px_frac;
+
+
if (im->maxval > 0.0)
im->maxval = im->minval + new_range;
else
im->minval = im->maxval - new_range;
ytr(im,DNAN); /* reset precalc */
+
/* make sure first minor gridline is on integer pixel y coord */
minor_y = gridstep * floor(im->minval / gridstep);
while (minor_y < im->minval)
@@ -1007,6 +1010,35 @@
return 0;
}
+static int AlmostEqual2sComplement (float A, float B, int maxUlps)
+{
+
+ int aInt = *(int*)&A;
+ int bInt = *(int*)&B;
+ int intDiff;
+ /* Make sure maxUlps is non-negative and small enough that the
+ default NAN won't compare as equal to anything. */
+
+ /* assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); */
+
+ /* Make aInt lexicographically ordered as a twos-complement int */
+
+ if (aInt < 0)
+ aInt = 0x80000000l - aInt;
+
+ /* Make bInt lexicographically ordered as a twos-complement int */
+
+ if (bInt < 0)
+ bInt = 0x80000000l - bInt;
+
+ intDiff = abs(aInt - bInt);
+
+ if (intDiff <= maxUlps)
+ return 1;
+
+ return 0;
+}
+
/* massage data so, that we get one value for each x coordinate in the graph */
int
data_proc( image_desc_t *im ){
@@ -1126,18 +1158,28 @@
im->maxval = maxval;
}
/* make sure min is smaller than max */
- if (im->minval > im->maxval) {
+ if (im->minval > im->maxval ) {
+ if (im->maxval > 0)
im->minval = 0.99 * im->maxval;
+ else
+ im->minval = 1.01 * im->maxval;
}
/* make sure min and max are not equal */
- if (im->minval == im->maxval) {
- im->maxval *= 1.01;
+ if ( AlmostEqual2sComplement(im->minval,im->maxval,4)) {
+ if (im->maxval > 0)
+ im->maxval *= 1.01;
+ else
+ im->maxval *= 0.99;
+
if (! im->logarithmic) {
- im->minval *= 0.99;
+ if (im->minval > 0)
+ im->minval *= 0.99;
+ else
+ im->minval *= 1.01;
}
/* make sure min and max are not both zero */
- if (im->maxval == 0.0) {
+ if (AlmostEqual2sComplement(im->maxval,0,4)) {
im->maxval = 1.0;
}
}
@@ -1745,35 +1787,7 @@
return mnt;
}
-static int AlmostEqual2sComplement (float A, float B, int maxUlps)
-{
- int aInt = *(int*)&A;
- int bInt = *(int*)&B;
- int intDiff;
- /* Make sure maxUlps is non-negative and small enough that the
- default NAN won't compare as equal to anything. */
-
- /* assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); */
-
- /* Make aInt lexicographically ordered as a twos-complement int */
-
- if (aInt < 0)
- aInt = 0x80000000l - aInt;
-
- /* Make bInt lexicographically ordered as a twos-complement int */
-
- if (bInt < 0)
- bInt = 0x80000000l - bInt;
-
- intDiff = abs(aInt - bInt);
-
- if (intDiff <= maxUlps)
- return 1;
-
- return 0;
-}
-
/* logaritmic horizontal grid */
int
horizontal_log_grid(image_desc_t *im)
_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers