Skip to content

How does Chart.js creates BezierCurves with Tension? #10321

Answered by LeeLenaleee
Udemology asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at the code it seems the bezier curved get drawn here:

export function _bezierCurveTo(ctx, previous, target, flip) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
ctx.bezierCurveTo(
flip ? previous.cp1x : previous.cp2x,
flip ? previous.cp1y : previous.cp2y,
flip ? target.cp2x : target.cp1x,
flip ? target.cp2y : target.cp1y,
target.x,
target.y);
}

The points for the curve get updated here:

export function _updateBezierControlPoints(points, options, area, loop

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Udemology
Comment options

Answer selected by Udemology
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants