Curve
From JSXGraph Wiki
There are various possibilities to display curves and plots. JSXGraph supports the following curve types which can be set by changing the property "curveType". In many cases JSXGraph can guess the curveType from the input parameters, but sometimes the curveType has to be set explicitly.
- 'plot': function plotter
- 'parameter': parameter curves.
- 'polar': polar curves
Function graph
First, we initialize the board and set axes:
var b = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 200, unitX: 20, unitY: 20});
axisx = b.create('axis', [[0,0], [1,0]], {});
axisy = b.create('axis', [[0,0], [0,1]], {});
As input data a curve needs 5 parameters:
- the term for the y-component: it can be a JavaScript function having one input parameter, or an expression in GEONExT syntax.
createElement('functiongraph', [function(x){return Math.sin(x);}, ...
- The last two parameters are optional and can contain constants or functions which determine the interval of the x-component in which the graph is shown.
If these parameters are not given, the graph is plotted from the left border to the right border.
createElement('functiongraph', [function(x){return Math.sin(x);},-Math.PI,4*Math.PI]
Together, the code looks like this:
b.createElement('functiongraph', [function(x){return Math.sin(x);},-Math.PI,2*Math.PI]);