Step function: Difference between revisions

From JSXGraph Wiki
(New page: <jsxgraph width="600" height="400"> var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true}); var f = function(x) { if(x<0) return -1; if(x>=0 && x <2) ...)
 
No edit summary
Line 13: Line 13:
</jsxgraph>
</jsxgraph>
===The underlying JavaScript code===
===The underlying JavaScript code===
<source lang="html4strict">
<input type="text" id="input" value="sin(x)*x">
<input type="button" value="plot" onClick="plotter()">
<input type="button" value="clear all" onClick="clearAll()">
</source>
<source lang="javascript">
<source lang="javascript">
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});

Revision as of 14:01, 8 June 2011

The underlying JavaScript code

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

var f = function(x) {
  if(x<0)
    return -1;
  if(x>=0 && x <2)
    return 1;
  if(x>=2)
    return 2;
}
board.create('functiongraph',[f]);