From JSXGraph Wiki
Revision as of 15:45, 25 January 2009 by A WASSERMANN (talk | contribs)
Jump to navigationJump to search

Sliders enable a convenient way to experiment with mathematical constructions. In the example below there is a slider s which takes values between 1 and 5. The value of the slider can be accessed via s.Value(). The x-coordinate and the y-coordinate of the point A depend on this value s.Value():

The slider needs the following input parameters:

  • [[x1,y1],[x2,y2],[min,start,max]]
  • [x1,y1]: first point of the ruler
  • [x2,y2]: last point of the ruler
  • min: minimum value of the slider
  • start: initial value of the slider
  • max: maximum value of the slider

JavaScript code:

<link rel="stylesheet" type="text/css" href="" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<div id="jxgbox" class="jxgbox" style="width:600px; height:400px;"></div>
var b = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 200, unitX: 60, unitY: 40});        
ax = b.createElement('axis', [[0,0], [1,0]], {});
ay = b.createElement('axis', [[0,0], [0,1]], {});
var s = b.createElement('slider',[[0,-3],[4,-3],[1,1,5]]);
var a = b.createElement('point',[
                       function(){return s.Value();},
                       function(){return 3/s.Value();}