JSXGraph logo
JSXGraph
JSXGraph share

Share

Texts (JSXGraph events)
QR code
<iframe 
    src="https://jsxgraph.uni-bayreuth.de/share/iframe/texts" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Texts (JSXGraph events)" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>


<div id="out"></div>
<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

        var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-1, 10, 7, -1], axis: false, keepaspectratio: false, keepaspectratio: true });
    
        // Vertical line at x=3
        var A = board.create('point', [2, 5], { strokeWidth: 1, dash: 2, name: 'A_1' });
        board.create('text', [3, 8, function() { return 'X(A_1) = ' + A.X().toFixed(2); }]);
    
        board.on('update', function() {
            document.getElementById('out').innerHTML = 'X(A<sub>1</sub>) = ' + A.X().toFixed(2);
        });
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

    var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-1, 10, 7, -1], axis: false, keepaspectratio: false, keepaspectratio: true });

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

    board.on('update', function() {
        document.getElementById('out').innerHTML = 'X(A<sub>1</sub>) = ' + A.X().toFixed(2);
    });

Texts (JSXGraph events)

This code sets up a JSXGraph board with a movable point `A_1`. A text label on the board dynamically shows its x-coordinate, and the same value is continuously updated in the HTML element with id `out` whenever the point is moved.
// Define the id of your board in BOARDID

    var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-1, 10, 7, -1], axis: false, keepaspectratio: false, keepaspectratio: true });

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

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

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.