]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Cap bezier handles inside the scale
authorNick Downie <hello@nickdownie.com>
Sun, 17 Aug 2014 21:32:36 +0000 (22:32 +0100)
committerNick Downie <hello@nickdownie.com>
Sun, 17 Aug 2014 21:32:36 +0000 (22:32 +0100)
src/Chart.Line.js

index d5213bfc4702b8f2770f97470abb3cd3a90ff295..0b3079ffe11237700a08b9d8bc232a7abd6dcda2 100644 (file)
                                                        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);
                                }