Even simpler function plotter

From JSXGraph Wiki
Revision as of 07:59, 2 July 2010 by A WASSERMANN (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The underlying JavaScript code

<input type="text" id="input" value="sin(x)*x">
<input type="button" value="plot" onClick="plotter()">
<input type="button" value="clear all" onClick="clearAll()">
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});

function plotter() {
  var t = JXG.GeonextParser.geonext2JS(document.getElementById('input').value);
  var f = new Function('x','var y = '+t+'; return y;');
  board.create('functiongraph',[f]);
}
function clearAll(board) {
    JXG.JSXGraph.freeBoard(board);
    board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});
}