]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Ensure that you always have at least 2 ticks on the linear axis
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 17 May 2015 17:29:17 +0000 (13:29 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sun, 17 May 2015 17:29:17 +0000 (13:29 -0400)
src/Chart.Scale.js

index dcaaefe2ca46f4894c76e6356c1852fa3093a80f..1353c9a7f636d2a957a8c2b81ed25fc04922d0dc 100644 (file)
                                        maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize)));
                                }
                                
+                               // Make sure we always have at least 2 ticks 
+                               maxTicks = Math.max(2, maxTicks);
+                               
                                // To get a "nice" value for the tick spacing, we will use the appropriately named 
                                // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
                                // for details.