From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Thu, 14 Dec 2017 15:03:07 +0000 (+0100) Subject: Fix issue #5029 (#5041) X-Git-Tag: v2.7.2~1^2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9beedba40217f07169ce9764f4371d40ee72367;p=thirdparty%2FChart.js.git Fix issue #5029 (#5041) - infinite loop in generating time axis, due to insufficient bounds checking. --- diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 4fe39b810..cfa9f829a 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -240,7 +240,7 @@ function determineStepSize(min, max, unit, capacity) { var i, ilen, factor; if (!steps) { - return Math.ceil(range / ((capacity || 1) * milliseconds)); + return Math.ceil(range / (capacity * milliseconds)); } for (i = 0, ilen = steps.length; i < ilen; ++i) { @@ -748,7 +748,8 @@ module.exports = function(Chart) { var tickLabelWidth = me.getLabelWidth(exampleLabel); var innerWidth = me.isHorizontal() ? me.width : me.height; - return Math.floor(innerWidth / tickLabelWidth); + var capacity = Math.floor(innerWidth / tickLabelWidth); + return capacity > 0 ? capacity : 1; } });