genius r733 - in trunk: . src



Author: jirka
Date: Mon Feb 23 17:01:22 2009
New Revision: 733
URL: http://svn.gnome.org/viewvc/genius?rev=733&view=rev

Log:

Mon Feb 23 11:01:10 2009  Jiri (George) Lebl <jirka 5z com>

	* src/graphing.c: fix the extra precision calculations to work 
	  for increments of 2.5.  Also try a tiny bit harder to get more
	  than 3 ticks



Modified:
   trunk/ChangeLog
   trunk/src/graphing.c

Modified: trunk/src/graphing.c
==============================================================================
--- trunk/src/graphing.c	(original)
+++ trunk/src/graphing.c	Mon Feb 23 17:01:22 2009
@@ -1873,39 +1873,43 @@
 	double len = end-start;
 	int tries = 0;
 	int tickprec;
+	int extra_prec;
 
 	tickprec = -floor (log10(len));
 	*tick = pow (10, -tickprec);
 	incs = floor (len / *tick);
 
-	if (incs < 3) {
-		while (incs < 3) {
-			*tick /= 2.0;
-
-			tickprec ++;
-
-			incs = floor (len / *tick);
-			/* sanity */
-			if (tries ++ > 100) {
-				break;
-			}
+	extra_prec = 0;
+
+	while (incs < 4) {
+		*tick /= 2.0;
+
+		extra_prec ++;
 
+		incs = floor (len / *tick);
+		/* sanity */
+		if (tries ++ > 100) {
+			break;
 		}
-	} else {
-		while (incs > 6) {
-			*tick *= 2.0;
-			incs = floor (len / *tick);
-			/* sanity */
-			if (tries ++ > 100) {
-				break;
-			}
+	}
+
+	while (incs > 6) {
+		*tick *= 2.0;
+		incs = floor (len / *tick);
+
+		if (extra_prec > 0)
+			extra_prec --;
+
+		/* sanity */
+		if (tries ++ > 100) {
+			break;
 		}
 	}
 
-	if (*tick >= 0.99) {
+	if (tickprec + extra_prec <= 0) {
 		*prec = 0;
 	} else {
-		*prec = tickprec;
+		*prec = tickprec + extra_prec;
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]