From: Evert Timberg Date: Sun, 17 May 2015 17:29:17 +0000 (-0400) Subject: Ensure that you always have at least 2 ticks on the linear axis X-Git-Tag: v2.0-alpha~8^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56d53e3ad482f50df130aa4979d438d5af347e28;p=thirdparty%2FChart.js.git Ensure that you always have at least 2 ticks on the linear axis --- diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index dcaaefe2c..1353c9a7f 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -337,6 +337,9 @@ 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.