Search code examples
jsxgraph

Dependency Between Objects on Different Boards


I am hoping to use 2 different boards and make elements of one dependent on elements on the other board. Is this possible?


Solution

  • Yes, boards can be connected by board1.addChild(board2). Then, every update of board1 triggers an update of board2. Here is a simple example (see it live at https://jsfiddle.net/vcL7aepo/6/):

    var board1 = JXG.JSXGraph.initBoard('box1', {
                    boundingbox: [-5, 5, 5, -5],
                    axis: false,
                    showNavigation: false
              });
    var board2 = JXG.JSXGraph.initBoard('box2', {
                    boundingbox: [-5, 5, 5, -5],
                    axis: true,
                    showNavigation: false
              });
    
    board1.addChild(board2);
    var a = board1.create('slider', [[-3,1], [3,1], [-10,1,10]]);
    var f = board2.create('functiongraph', [
            function(x) { return a.Value()*x*x;} 
        ]);