MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to use for showing charts on your website.

More »

 

Download
Get the latest version of RGraph (version 6.19, 28th September 2024) from the download page. You can read the changelog here. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

Download »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£129) commercial license available.

More »

An interactive example of the bezierCurveTo function

Written by Richard Heyes, RGraph author, on 16th January 2013

[No canvas support]

This is a demonstration of how to use the bezierCurveTo function in the canvas api. It should help you to understand them because the two control points (the coordinates that you give to the bezierCurveTo function) are illustrated and you can drag them around with your mouse - showing the effect on the curve. The resulting code is shown below.

The output

This is the code that can be used to achieve the curve (the points are color coded to match the output above):



        

The arguments to the function

The bezierCurveTo function takes six arguments - ie three sets of XY coordinate pairs. The curve is actually made up of four points - but the first point is the current point in your path. If you're starting a new path with the bezierCurveTo function then you need to use the moveTo function to move to the start point.

  • Start point
    This is the moveTo call in the example above. The bezier curve starts from this point.

  • Control point 1
    This is the first set of coordinates that you give to the bezierCurveTo function. This point dictates the shape of the curve.

  • Control point 2
    This is the second set of coordinates that you give to the bezierCurveTo function. This point dictates the shape of the curve.

  • End point
    This is the third set of coordinates given to the bezierCurveTo function. This is where the curve ends.