Share JSXGraph: example "Function plot animation"

JSXGraph
Share JSXGraph: example "Function plot animation"
This website is a beta version. The official release will be in **2023**.

Function plot animation

For animated plotting of simple function graphs, the turtle object is useful.
// Define the id of your board in BOARDID

// User supplied function to be plotted
var f = (x) => Math.sin(x);

const board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-5, 2, 5, -2],
    axis: true,
    keepaspectratio: false
});

var start = -4,
    end = 4,
    x = start,
    step = 0.2,
    turtle = board.create('turtle', [x, f(x)]);

var moveForward = function() {
    x += step;
    if (x > end) {
        return;
    }
    turtle.moveTo([x, f(x)]);
    setTimeout(moveForward, 200); // delay by 200 ms
};

turtle.hideTurtle(); // Hide the turtle arrow
moveForward(); // Start the drawing