File: input.html

package info (click to toggle)
jsxgraph 1.10.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,804 kB
  • sloc: javascript: 82,299; xml: 5,869; java: 1,072; php: 281; makefile: 184; python: 174; cpp: 76; sh: 12
file content (42 lines) | stat: -rw-r--r-- 1,639 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<head>
   <title>JSXGraph example</title>
   <link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
   <script type="text/javascript" src="/javascript/prototype/prototype.js"></script>
   <script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
</head>
<body>
  <h2>Input example</h2>
  <div id="jxgbox" class="jxgbox" style="width:700px; height:500px;"></div>
  <div id="debug" style="display:none;"></div>
   <script type="text/javascript">
    /* <![CDATA[ */

        board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,8,8,-5], axis:true});
        b1axisx = board.create('axis', [[0,0], [1,0]], {});
        b1axisy = board.create('axis', [[0,0], [0,1]], {});

        var input = board.create('input', [-4, 7, 'sin(x)*x', 'f(x)='], {});
        var f = board.jc.snippet(input.Value(), true, 'x', false);
        var graph = board.create('functiongraph',[f,
                function() {
                  var c = new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],board);
                  return c.usrCoords[1];
                },
                function() {
                  var c = new JXG.Coords(JXG.COORDS_BY_SCREEN,[board.canvasWidth,0],board);
                  return c.usrCoords[1];
                }
              ]);

        board.create('text', [1, 6.7, '<button onclick="updateGraph()">Update graph</button>']);

        var updateGraph = function() {
            graph.Y = board.jc.snippet(input.Value(), true, 'x', false);
            graph.updateCurve();
            board.update();
        }
  /* ]]> */
  </script>
</body>
</html>