Difference between revisions of "Texts"

From JSXGraph Wiki
Jump to: navigation, search
Line 5: Line 5:
 
     var A = brd.create('point', [2, 5], {strokeWidth:1, dash:2});   
 
     var A = brd.create('point', [2, 5], {strokeWidth:1, dash:2});   
 
     brd.create('text', [3, 8, function () { return 'X(A) = ' + A.X(); }]);
 
     brd.create('text', [3, 8, function () { return 'X(A) = ' + A.X(); }]);
 +
 +
    brd.on('update', function () {
 +
        document.getElementById('out').innerHTML = 'X(A) = ' + A.X();
 +
    });
 
</jsxgraph>
 
</jsxgraph>
 +
<html>
 +
<div id="out"></div>
 +
</html>
  
 
===The underlying JavaScript code===
 
===The underlying JavaScript code===
Line 14: Line 21:
 
     var A = brd.create('point', [2, 5], {strokeWidth:1, dash:2});   
 
     var A = brd.create('point', [2, 5], {strokeWidth:1, dash:2});   
 
     brd.create('text', [3, 8, function () { return 'X(A) = ' + A.X(); }]);
 
     brd.create('text', [3, 8, function () { return 'X(A) = ' + A.X(); }]);
 +
 +
    brd.on('update', function () {
 +
        document.getElementById('out').innerHTML = 'X(A) = ' + A.X();
 +
    });
 +
</source>
 +
 +
<source lang="xml">
 +
    <div id="out"></div>
 
</source>
 
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Revision as of 14:53, 14 December 2012

The underlying JavaScript code

    var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox: [-1,10,7,-1], axis:false, keepaspectratio:false});

    // Vertical line at x=3
    var A = brd.create('point', [2, 5], {strokeWidth:1, dash:2});  
    brd.create('text', [3, 8, function () { return 'X(A) = ' + A.X(); }]);

    brd.on('update', function () {
        document.getElementById('out').innerHTML = 'X(A) = ' + A.X();
    });
    <div id="out"></div>