From: Evert Timberg Date: Sat, 9 Jul 2016 21:24:41 +0000 (-0400) Subject: Bring back capping of bezier curve points and have an option to disable it (#2948) X-Git-Tag: v2.2.0-rc.1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49c4169010048d1fb4add298ec1f680b6dd6d30a;p=thirdparty%2FChart.js.git Bring back capping of bezier curve points and have an option to disable it (#2948) --- diff --git a/docs/01-Chart-Configuration.md b/docs/01-Chart-Configuration.md index 57c06284d..5a8627456 100644 --- a/docs/01-Chart-Configuration.md +++ b/docs/01-Chart-Configuration.md @@ -369,6 +369,7 @@ borderCapStyle | String | 'butt' | Default line cap style. See [MDN](https://dev borderDash | Array | `[]` | Default line dash. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) borderDashOffset | Number | 0.0 | Default line dash offset. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) borderJoinStyle | String | 'miter' | Default line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin) +capBezierPoints | Boolean | true | If true, bezier control points are kept inside the chart. If false, no restriction is enforced. fill | Boolean | true | If true, the line is filled. stepped | Boolean | false | If true, the line is shown as a steeped line and 'tension' will be ignored diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index caee9c683..b184aff03 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -244,10 +244,17 @@ module.exports = function(Chart) { }, updateBezierControlPoints: function() { - var meta = this.getMeta(); + var me = this; + var meta = me.getMeta(); + var area = me.chart.chartArea; var points = meta.data || []; var i, ilen, point, model, controlPoints; + var needToCap = me.chart.options.elements.line.capBezierPoints; + function capIfNecessary(pt, min, max) { + return needToCap ? Math.max(Math.min(pt, max), min) : pt; + } + for (i=0, ilen=points.length; i