r22793 - gnucash/trunk/src/report/jqplot/plugins - Improve jqplot's barchart renderer's barWidth and barPadding calculation

Geert Janssens gjanssens at code.gnucash.org
Wed Feb 20 13:51:42 EST 2013


Author: gjanssens
Date: 2013-02-20 13:51:41 -0500 (Wed, 20 Feb 2013)
New Revision: 22793
Trac: http://svn.gnucash.org/trac/changeset/22793

Modified:
   gnucash/trunk/src/report/jqplot/plugins/jqplot.barRenderer.js
Log:
Improve jqplot's barchart renderer's barWidth and barPadding calculation

The improved formula scales more gracefully from extremely small to
extremely large.

Note: this modifies jqplot itself. We may need to either
- attempt to get this in the upstream code
- see if we can get a similar result by improving our own code

Modified: gnucash/trunk/src/report/jqplot/plugins/jqplot.barRenderer.js
===================================================================
--- gnucash/trunk/src/report/jqplot/plugins/jqplot.barRenderer.js	2013-02-20 18:51:26 UTC (rev 22792)
+++ gnucash/trunk/src/report/jqplot/plugins/jqplot.barRenderer.js	2013-02-20 18:51:41 UTC (rev 22793)
@@ -273,6 +273,19 @@
                 // this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding - this.barMargin/nseries;
             }
         }
+        // When things are getting tight, prefer a larger barWidth over a larger barPadding
+        if (this.barWidth < this.barPadding) {
+            var switcher;
+            switcher = this.barPadding;
+            this.barPadding = this.barWidth;
+	    this.barWidth = switcher;
+        }
+        // Make sure we keep a sensible minimum for barWidth when it's 0 or very small
+        this.barWidth = Math.max(3,this.barWidth);
+        // Restrict possible negative padding for better display in extremely tight conditions
+        if (this.barPadding <= -this.barWidth) {
+          this.barPadding = -(this.barWidth -1);
+        }
         return [nvals, nseries];
     };
 



More information about the gnucash-changes mailing list