Even simpler function plotter: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 15: Line 15:
function clearAll(board) {
function clearAll(board) {
     JXG.JSXGraph.freeBoard(board);
     JXG.JSXGraph.freeBoard(board);
     board = JXG.JSXGraph.initBoard('box', {boundingbox:[-5,8,8,-5], unitY: 40});
     board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});
    p = board.create('point', [3,-4], {style:6, name:'p'});
    return board;
}
}
</jsxgraph>
===The underlying JavaScript code===
<source lang="javascript">
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});


</jsxgraph>
function plotter() {
  var t = board.algebra.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});
}
</source>
 
[[Category:Examples]]
[[Category:Calculus]]

Revision as of 16:44, 22 March 2010

The underlying JavaScript code

var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});

function plotter() {
  var t = board.algebra.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});
}