Skip to content

Commit

Permalink
Cap bezier handles inside the scale
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnick committed Aug 17, 2014
1 parent 48f1019 commit 179d80a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Chart.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 179d80a

Please sign in to comment.