]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Time scale support 1474/head
authorTanner Linsley <tannerlinsley@gmail.com>
Mon, 21 Sep 2015 19:04:41 +0000 (13:04 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Mon, 21 Sep 2015 19:04:41 +0000 (13:04 -0600)
src/scales/scale.time.js

index 140ff72299e8b046bf5407974ba486d6bee09c81..87909d0cf23609b0fc5df668e3006629cbcd4955 100644 (file)
 
                // Functions needed for bar charts
                calculateBaseWidth: function() {
-                       return (this.getPixelForValue(null, this.smallestLabelSeparation / this.tickRange, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing);
+
+                       var base = this.getPixelForValue(null, this.smallestLabelSeparation / this.tickRange, 0, true) - this.getPixelForValue(null, 0, 0, true);
+                       var spacing = 2 * this.options.categorySpacing;
+                       if (base < spacing * 2) {
+                               var mod = Math.min((spacing * 2) / base, 1.5);
+                               base = (base / 2) * mod;
+                               return base;
+                       }
+                       return base - spacing;
                },
                calculateBarWidth: function(barDatasetCount) {
                        //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset