From: Nick Downie Date: Sun, 17 Aug 2014 21:32:36 +0000 (+0100) Subject: Cap bezier handles inside the scale X-Git-Tag: v1.0.1-beta.4~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=179d80a93b64cf107ee219886c43eb6e212594f5;p=thirdparty%2FChart.js.git Cap bezier handles inside the scale --- diff --git a/src/Chart.Line.js b/src/Chart.Line.js index d5213bfc4..0b3079ffe 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -291,6 +291,24 @@ nextPoint(point, pointsWithValues, index), tension ); + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (point.controlPoints.outer.y > this.scale.endPoint){ + point.controlPoints.outer.y = this.scale.endPoint; + } + else if (point.controlPoints.outer.y < this.scale.startPoint){ + point.controlPoints.outer.y = this.scale.startPoint; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (point.controlPoints.inner.y > this.scale.endPoint){ + point.controlPoints.inner.y = this.scale.endPoint; + } + else if (point.controlPoints.inner.y < this.scale.startPoint){ + point.controlPoints.inner.y = this.scale.startPoint; + } },this); }