FAQ - Frequently asked questions: Difference between revisions

From JSXGraph Wiki
m (typo)
No edit summary
Line 3: Line 3:
The choice completely depends on you. JSXGraph works with both packages equally good.  If you want to use JavaScript features like AJAX
The choice completely depends on you. JSXGraph works with both packages equally good.  If you want to use JavaScript features like AJAX
choose the package you're most familiar with.
choose the package you're most familiar with.
* ''What is the event model of JSXGraph?''
The event model of JSXGraph is the following:
- An onmousemove event in the HTML element containing the JSXGraph construction  and
- an onmousup event of the whole HTML document
trigger the method JXG.Board.update() .
JXG.Board.update() calls the update() method of each element (points, lines, texts, ...) of the board.
Thus, by dragging a point, onmousemove of the HTML element containing
the construction is triggered. This triggers the call of JXG.Board.update(),
which calls all update() methods of each element.
The update() method of each element computes the new position of the element
and its layout (strokeColor, strokeWidth).  This update() method can use
the position of other elements, see the Lissajous example.
The Hilbert example is somewhat more complicated:
It overwrites the (previously empty) method updateDataArray() of a curve of curevType "plot".
In that method the new data points are computed depending on one slider.
Then, with
            this.dataX = ...;
            this.dataY = ...;
they are handed to the curve tight before they are plotted.
Other special cases:
- In order to speed up things the update() of (all) elements can be
prevented by calling
board.suspendUpdate();
until the call of
board.unsuspendUpdate();
- JSXGraph updates ALL JXG.Boards in an HTML document. So
elements of one board can depend from elements in another board.
See http://jsxgraph.uni-bayreuth.de/wiki/index.php/Sine_and_cosine

Revision as of 12:46, 2 June 2009

  • The documentation suggests using either JQuery.js or prototype.js, but the AJAX example appears to require prototype.js. By, what reasons would one choose JQuery over prototype, or vice versa.

The choice completely depends on you. JSXGraph works with both packages equally good. If you want to use JavaScript features like AJAX choose the package you're most familiar with.

  • What is the event model of JSXGraph?


The event model of JSXGraph is the following: - An onmousemove event in the HTML element containing the JSXGraph construction and - an onmousup event of the whole HTML document trigger the method JXG.Board.update() .

JXG.Board.update() calls the update() method of each element (points, lines, texts, ...) of the board.

Thus, by dragging a point, onmousemove of the HTML element containing the construction is triggered. This triggers the call of JXG.Board.update(), which calls all update() methods of each element.

The update() method of each element computes the new position of the element and its layout (strokeColor, strokeWidth). This update() method can use the position of other elements, see the Lissajous example. The Hilbert example is somewhat more complicated: It overwrites the (previously empty) method updateDataArray() of a curve of curevType "plot". In that method the new data points are computed depending on one slider. Then, with

           this.dataX = ...;
           this.dataY = ...;

they are handed to the curve tight before they are plotted.


Other special cases: - In order to speed up things the update() of (all) elements can be prevented by calling board.suspendUpdate(); until the call of board.unsuspendUpdate();

- JSXGraph updates ALL JXG.Boards in an HTML document. So elements of one board can depend from elements in another board. See http://jsxgraph.uni-bayreuth.de/wiki/index.php/Sine_and_cosine