3

Recently I am working on plotting the algorithm gameOfLife.

I find that JSXGraph is very handy and useful. I just need to include the libraries and add several lines to plot, as shown in a minimal example below.

<!DOCTYPE html>
<html>
<head>
    <title>Ultimate Slot Machine</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
    <script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>

</head>
<body>
    <div id="box" class="jxgbox" style="width:800px; height:800px; margin: 0 auto;"></div>
    <script type="text/javascript">
     var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-10, 10, 10, -10], axis:false, grid:true});

     var p = board.create('point',[-3,1]);

     var q = board.create('point',[-3,1], {face:'x', size:16});
    </script>

</body>
</html>

The question is that I don't know how to delete the created point, and I can not find any reference in the official documentation.

https://jsxgraph.org/docs/symbols/Point.html

https://jsxgraph.org/wiki/index.php/Point

Please help.

Leslie Wong
  • 109
  • 1
  • 6

1 Answers1

8

JSXGraph elements are removed by calling board.removeObject(object); or board.removeObject([array of objects]);. Your example would look like:

 var p = board.create('point',[-3,1]);
 var q = board.create('point',[-3,1], {face:'x', size:16});
 board.removeObject(p);
 board.removeObject(q);
 // or
 board.removeObject([p, q]);
Alfred Wassermann
  • 2,248
  • 1
  • 11
  • 10