JXG.Board

Class

JXG.Board controls all properties and methods used to manage a geonext board like managing geometric elements, managing mouse and touch events, etc. You probably don't want to use this constructor directly. Please use JXG.JSXGraph.initBoard to initialize a board.

Attributes

Own

animationDelay

Description

Time (in msec) between two animation steps. Used in JXG.CoordsElement#moveAlong, JXG.CoordsElement#moveTo and JXG.CoordsElement#visit.

Type
Number
Default Value
35
See
Source
options.js, line 65

axis

Description

Show default axis. If shown, the horizontal axis can be accessed via JXG.Board.defaultAxes.x, the vertical axis can be accessed via JXG.Board.defaultAxes.y. Both axes have a sub-element "defaultTicks".

Value can be Boolean or an object containing axis attributes.

Type
Boolean
Default Value
false
Source
options.js, line 80

boundingBox

Description

Bounding box of the visible area in user coordinates. It is an array consisting of four values: [x1, y1, x2, y2]

The canvas will be spanned from the upper left corner (x1, y1) to the lower right corner (x2, y2).

Type
Array
Default Value
[-5, 5, 5, -5]
See
Example
var board = JXG.JSXGraph.initBoard('jxgbox', {
        boundingbox: [-5, 5, 5, -5],
        axis: true
    });
Source
options.js, line 95

browserPan

Description

Enable browser scrolling on touch interfaces if the user double taps into an empty region of the board. In turn, browser scrolling is deactivated as soon as a JSXGraph element is dragged.

  • Implemented for pointer touch devices - not with mouse, pen or old iOS touch.
  • It only works if browserPan:true
  • One finger action by the settings "pan.enabled:true" and "pan.needTwoFingers:false" has priority.
Type
Boolean
Default Value
false
See
Example
const board = JXG.JSXGraph.initBoard('jxgbox', {
    boundingbox: [-5, 5, 5, -5], axis: true,
    pan: {
        enabled: true,
        needTwoFingers: true,
    },
    browserPan: true,
    zoom: {
        enabled: false
    }
});

var p1 = board.create('point', [1, -1]);
var p2 = board.create('point', [2.5, -2]);
var li1 = board.create('line', [p1, p2]);

Source
options.js, line 118

clickDelay

Description

Maximum time delay (in msec) between two clicks to be considered as double click. This attribute is used together with JXG.Board#dblClickSuppressClick. The JavaScript standard is that a click event is preceded by two click events, see https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event. In case of JXG.Board#dblClickSuppressClick being true, the JavaScript standard is ignored and this time delay is used to suppress the two click events if they are followed by a double click event.

In case of JXG.Board#dblClickSuppressClick being false, this attribute is used to clear the list of clicked elements after the time specified by this attribute.

Recommendation: if JXG.Board#dblClickSuppressClick is true, use a value of approx. 300, otherwise stay with the default 600.

Type
Number
Default Value
600
See
Source
options.js, line 177

cssStyle

Description

CSS attributes for the JSXGraph div element.

Type
String
Default Value
''
Source
options.js, line 201

dblClickSuppressClick

Description

If false (default), JSXGraph follows the JavaScript standard and fires before a dblclick event two click events.

If true, the click events are suppressed if there is a dblclick event. The consequence is that in this case any click event is fired with a delay specified by JXG.Board#clickDelay.

Type
Boolean
Default Value
false
See
Source
options.js, line 211

defaultAxes

Description

Attributes for the default axes in case of the attribute axis:true in JXG.JSXGraph#initBoard.

Type
Object
Default Value
{x: {name:'x'}, y: {name: 'y'}}
Examples
const board = JXG.JSXGraph.initBoard('id', {
    boundingbox: [-5, 5, 5, -5], axis:true,
    defaultAxes: {
        x: {
          name: 'Distance (mi)',
          withLabel: true,
          label: {
            position: 'rt',
            offset: [-5, 15],
            anchorX: 'right'
          }
        },
        y: {
          withLabel: true,
          name: 'Y',
          label: {
            position: 'rt',
            offset: [-20, -5],
            anchorY: 'top'
          }
        }
    }
});

Display ticks labels as fractions

 var board = JXG.JSXGraph.initBoard('jxgbox', {
     boundingbox: [-1.2, 2.3, 1.2, -2.3],
     axis: true,
     defaultAxes: {
         x: {
             ticks: {
                 label: {
                     useMathJax: true,
                     display: 'html',
                     toFraction: true
                 }
             }
         },
         y: {
             ticks: {
                 label: {
                     useMathJax: true,
                     display: 'html',
                     toFraction: true
                 }
             }
         }
     }
 });

Source
options.js, line 228

document

Description

Supply the document object (DOM object). Defaults to window.document

Type
Object
Default Value
false (meaning window.document)
Source
options.js, line 392

drag

Description

Control the possibilities for dragging objects.

Possible sub-attributes with default values are:

drag: {
  enabled: true   // Allow dragging
}
Type
Object
Default Value
{enabled: true}
Source
options.js, line 402

fullscreen

Description

Attribute(s) to control the fullscreen icon. The attribute "showFullscreen" controls if the icon is shown. The following attribute(s) can be set:

  • symbol (String): Unicode symbol which is shown in the navigation bar. Default: svg code for '\u26f6', other possibilities are the unicode symbols '\u26f6' and '\u25a1'. However, '\u26f6' is not supported by MacOS and iOS.
  • scale (number between 0 and 1): Relative size of the larger side of the JSXGraph board in the fullscreen window. 1.0 gives full width or height. Default value is 0.85.
  • id (String): Id of the HTML element which is brought to full screen or null if the JSXgraph div is taken. It may be an outer div element, e.g. if the old aspect ratio trick is used. Default: null, i.e. use the JSXGraph div.
Type
Object
Default Value
svg code
See
Example
var board = JXG.JSXGraph.initBoard('35bec5a2-fd4d-11e8-ab14-901b0e1b8723',
            {boundingbox: [-8, 8, 8,-8], axis: true,
            showcopyright: false,
            showFullscreen: true,
            fullscreen: {
                 symbol: '\u22c7',
                 scale: 0.95
             }
            });
var pol = board.create('polygon', [[0, 1], [3,4], [1,-4]], {fillColor: 'yellow'});

Source
options.js, line 421

ignoreLabels

Description

If set true and hasPoint() is true for both an element and it's label, the element (and not the label) is taken as drag element.

If set false and hasPoint() is true for both an element and it's label, the label is taken (if it is on a higher layer than the element)

Meanwhile, this feature might be irrelevant.

Type
Booelan
Default Value
true
Source
options.js, line 476

intl

Description

Support for internationalization of number formatting. This affects

  • axis labels
  • infobox
  • texts consisting of numbers only
  • smartlabel elements
  • slider labels
  • tapemeasure elements
  • integral element labels

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat for an overview on the possibilities and the options.

User generated texts consisting of texts AND numbers have to be internationalized by the user, see Text#intl. Language locale and options can be individually controlled for each element by its intl attribute. If no locale is set, the default language of the browser is used.

Type
Object
Default Value
{enabled: false}
See
Examples

Set the board-wide locale and use individual options for a text

const board = JXG.JSXGraph.initBoard(BOARDID, {
    axis: true,
    intl: {
        enabled: true,
        locale: 'de-DE'
    },
    boundingbox:[-0.5, 0.5, 0.5, -0.5]
});

var t = board.create('text', [0.05, 0.2, -Math.PI*100], {
        formatNumber: true,
        digits: 2,
        intl: {
                enabled: true,
                options: {
                    style: 'unit',
                    unit: 'celsius'
                }
            }
    });

Here, locale is disabled in general, but enabled for the horizontal axis and the infobox

const board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-0.5, 0.5, 0.5, -0.5],
    intl: {
        enabled: false,
        locale: 'de-DE'
    },
    keepaspectratio: true,
    axis: true,
    defaultAxes: {
        x: {
            ticks: {
                intl: {
                        enabled: true,
                        options: {
                            style: 'unit',
                            unit: 'kilometer-per-hour',
                            unitDisplay: 'narrow'
                        }
                }
            }
        },
        y: {
            ticks: {
            }
        }
    },
    infobox: {
        fontSize: 12,
        intl: {
            enabled: true,
            options: {
                minimumFractionDigits: 4,
                maximumFractionDigits: 5
            }
        }
    }
});

var p = board.create('point', [0.1, 0.1], {});

Source
options.js, line 492

jxgbox

Description

Attributes for the div containing the JSXGraph board - in case the board has been constructed by JXG.initAppBox

Type
Object
Default Value
{
  id: 'jxgbox',
  outerbox: null,
  cssStyle: 'width: 500px;  aspect-ratio: 1/1; overflow: visible',
  cssClass: 'jxgbox'
}
Source
options.js, line 663

keepAspectRatio

Description

If set to true, the ratio between horizontal and vertical unit sizes stays constant - independent of size changes of the hosting HTML div element.

If the aspect ration of the hosting div changes, JSXGraphs will change the user supplied bounding box accordingly. This is necessary if circles should look like circles and not like ellipses. It is recommended to set keepAspectRatio = true for geometric applets.

For function plotting keepAspectRatio = false might be the better choice.

Type
Boolean
Default Value
false
See
Source
options.js, line 683

keyboard

Description

Control using the keyboard to change the construction.

  • enabled: true / false
  • dx: horizontal shift amount per key press
  • dy: vertical shift amount per key press
  • panShift: zoom if shift key is pressed
  • panCtrl: zoom if ctrl key is pressed
Type
Object
Default Value
{enabled: true, dx: 10, dy:10, panShift: true, panCtrl: false}
See
Example
var board = JXG.JSXGraph.initBoard("jxgbox", {boundingbox: [-5,5,5,-5],
    axis: true,
    showCopyright:true,
    showNavigation:true,
    keyboard: {
        enabled: true,
        dy: 30,
        panShift: true,
        panCtrl: false
    }
});

Source
options.js, line 706

logging

Description

If enabled, user activities are logged in array "board.userLog".

Type
Object
Default Value
{enabled: false}
See
Example
var board = JXG.JSXGraph.initBoard(BOARDID,
         {
             boundingbox: [-8, 8, 8,-8],
             axis: true,
             logging: {enabled: true},
             showcopyright: false,
             shownavigation: false
         });
var A = board.create('point', [-4, 0], { name: 'A' });
var B = board.create('point', [1, 2], { name: 'B' });
var showUserLog = function() {
    var txt = '';

    for (let i = 0; i < board.userLog.length; i++) {
        txt += JSON.stringify(board.userLog[i]) + '\n';
    }
    alert(txt);
};
var but = board.create('button', [4, 4, 'Show user log', showUserLog]);

Source
options.js, line 766

maxBoundingBox

Description

Maximal bounding box of the visible area in user coordinates. It is an array consisting of four values: [x1, y1, x2, y2]

The bounding box of the canvas must be inside of this maximal bounding box.

Type
Array
Default Value
[-Infinity, Infinity, Infinity, -Infinity]
See
Example
var board = JXG.JSXGraph.initBoard('jxgbox', {
        boundingBox: [-5, 5, 5, -5],
        maxBoundingBox: [-8, 8, 8, -8],
        pan: {enabled: true},
        axis: true
    });

Source
options.js, line 848

maxFrameRate

Description

Maximum frame rate of the board, i.e. maximum number of updates per second triggered by move events.

Type
Number
Default Value
40
Source
options.js, line 888

maxNameLength

Description

Maximum number of digits in automatic label generation. For example, if set to 1 automatic point labels end at "Z". If set to 2, point labels end at "ZZ".

Type
Number
Default Value
1
See
Source
options.js, line 899

minimizeReflow

Description

Change redraw strategy in SVG rendering engine.

This optimization seems to be obsolete in newer browsers (from 2021 on, at least) and even slow down the constructions. Therefore, the default is set to 'none' since v1.2.4.

If set to 'svg', before every redrawing of the JSXGraph construction the SVG sub-tree of the DOM tree is taken out of the DOM.

If set to 'all', before every redrawing of the JSXGraph construction the complete DOM tree is taken out of the DOM. If set to 'none' the redrawing is done in-place.

Using 'svg' or 'all' speeds up the update process considerably. The risk is that if there is an exception, only a white div or window is left.

Type
String
Default Value
'none'
Source
options.js, line 824

moveTarget

Description

Element which listens to move events of the pointing device. This allows to drag elements of a JSXGraph construction outside of the board. Especially, on mobile devices this enhances the user experience. However, it is recommended to allow dragging outside of the JSXGraph board only in certain constructions where users may not "loose" points outside of the board. In such a case, points may become unreachable.

A situation where dragging outside of the board is uncritical is for example if only sliders are used to interact with the construction.

Possible values for this attributes are:

  • an element specified by document.getElementById('some id');
  • null: to use the JSXGraph container div element
  • document

Since the introduction of this attribute "moveTarget", the value "document" has become sort of default on touch devices like smartphones. However, it is no longer the case that the document listens to move events, but there is the new feature "setPointerCapture", which is also implicitly enabled on certain devices. In future versions, JSXGraph may adopt this new standard and distinguish only two cases:

  • null: no pointerCapture
  • document: use pointerCapture

This attribute is immutable. It can be changed as follows:

Type
Object
Default Value
null
Examples
board.setAttribute({moveTarget: null});
board.removeEventHandlers();
board.addEventHandlers();
var board = JXG.JSXGraph.initBoard('jxgbox', {
        boundingbox: [-5,5,5,-5],
        axis: true,
        moveTarget: document
    });

Source
options.js, line 912

offsetX

Description

A number that will be added to the absolute position of the board used in mouse coordinate calculations in JXG.Board#getCoordsTopLeftCorner.

Type
Number
Default Value
0
See
Source
options.js, line 974

offsetY

Description

A number that will be added to the absolute position of the board used in mouse coordinate calculations in JXG.Board#getCoordsTopLeftCorner.

Type
Number
Default Value
0
See
Source
options.js, line 986

pan

Description

Control the possibilities for panning interaction (i.e. moving the origin).

Possible sub-attributes with default values are:

pan: {
  enabled: true   // Allow panning
  needTwoFingers: false, // panning is done with two fingers on touch devices
  needShift: true, // mouse panning needs pressing of the shift key
}
Type
Object
See
Source
options.js, line 998

renderer

Description

Default rendering engine. Possible values are 'svg', 'canvas', 'vml', 'no', or 'auto'. If the rendering engine is not available JSXGraph tries to detect a different engine.

In case of 'canvas' it is advisable to call 'board.update()' after all elements have been constructed. This ensures that all elements are drawn with their intended visual appearance.

This attribute is immutable.

Type
String
Default Value
'auto'
Source
options.js, line 1094

resize

Description

Control if JSXGraph reacts to resizing of the JSXGraph container element by the user / browser. The attribute "throttle" determines the minimal time in msec between to resize calls.

Attention: if the JSXGraph container has no CSS property like width or height and max-width or max-height set, but has a property like box-sizing:content-box, then the interplay between CSS and the resize attribute may result in an infinite loop with ever increasing JSXGraph container.

Type
Object
Default Value
{enabled: true, throttle: 10}
See
Example
var board = JXG.JSXGraph.initBoard('jxgbox', {
    boundingbox: [-5,5,5,-5],
    keepAspectRatio: true,
    axis: true,
    resize: {enabled: true, throttle: 200}
});

Source
options.js, line 1112

screenshot

Description

Attributes to control the screenshot function. The following attributes can be set:

  • scale: scaling factor (default=1.0)
  • type: format of the screenshot image. Default: png
  • symbol: Unicode symbol which is shown in the navigation bar. Default: '\u2318'
  • css: CSS rules to format the div element containing the screen shot image
  • cssButton: CSS rules to format the close button of the div element containing the screen shot image

The screenshot will fail if the board contains text elements or foreign objects containing SVG again.

Type
Object
Source
options.js, line 1159

selection

Description

Control the possibilities for a selection rectangle. Starting a selection event triggers the "startselecting" event. When the mouse pointer is released, the "stopselecting" event is fired. The "stopselecting" event is supplied by the user.

So far it works in SVG renderer only.

Possible sub-attributes with default values are:

selection: {
  enabled: false,
  name: 'selectionPolygon',
  needShift: false,  // mouse selection needs pressing of the shift key
  needCtrl: true,    // mouse selection needs pressing of the shift key
  fillColor: '#ffff00'
}

Board events triggered by selection manipulation: 'startselecting', 'stopselecting', 'mousestartselecting', 'mousestopselecting', 'pointerstartselecting', 'pointerstopselecting', 'touchstartselecting', 'touchstopselecting'.

Type
Object
See
Example
board.on('stopselecting', function(){
    var box = board.stopSelectionMode(),
    // bbox has the coordinates of the selectionr rectangle.
    // Attention: box[i].usrCoords have the form [1, x, y], i.e.
    // are homogeneous coordinates.
    bbox = box[0].usrCoords.slice(1).concat(box[1].usrCoords.slice(1));
    // Set a new bounding box
    board.setBoundingBox(bbox, false);
});
Source
options.js, line 1184

showClearTraces

Description

Show a button which allows to clear all traces of a board. This button can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_cleartraces" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_cleartraces".

Type
Boolean
Default Value
false
See
Source
options.js, line 1261

showCopyright

Description

Show copyright string and logo in the top left corner of the board.

Type
Boolean
Default Value
true
See
Source
options.js, line 1276

showFullscreen

Description

Show a button in the navigation bar to start fullscreen mode. This button can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_fullscreen" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_fullscreen".

Type
Boolean
Default Value
false
See
Source
options.js, line 1287

showInfobox

Description

If true, the infobox is shown on mouse/pen over for all points which have set their attribute showInfobox to 'inherit'. If a point has set its attribute showInfobox to false or true, that value will have priority over this value.

Type
Boolean
Default Value
true
See
Source
options.js, line 1304
Description

The JSXGraph logo in the top left corner of the board is shown as soon as JXG.Board#showCopyright is true.

If JXG.Board#showCopyright is false, the logo can be shown anyhow by setting showLogo to true.

Type
Boolean
Default Value
false
See
Source
options.js, line 1318

showNavigation

Description

Display of navigation arrows and zoom buttons in the navigation bar.

The navigation bar has the the ID "{board_id}_navigation" and the CSS class JXG_navigation". The individual buttons can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_{type}" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_{type}", where {type} is one of left, right, or up, down, in, 100, or out, fullscreen, screenshot, cleartraces, reload.

Type
Boolean
Default Value
true
See
Source
options.js, line 1333

showReload

Description

Show a button in the navigation bar to force reload of a construction. Works only with the JessieCode tag. This button can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_reload" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_reload".

Type
Boolean
Default Value
false
See
Source
options.js, line 1355

showScreenshot

Description

Show a button in the navigation bar to enable screenshots. This button can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_screenshot" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_screenshot".

Type
Boolean
Default Value
false
See
Source
options.js, line 1371

showZoom

Description

Display of zoom buttons in the navigation bar. To show zoom buttons, additionally showNavigation has to be set to true.

The individual buttons can be accessed by JavaScript or CSS with the ID "{board_id}_navigation_button_{type}" or by the CSS classes JXG_navigation_button" or JXG_navigation_button_{type}", where {type} is in, 100, or out.

Type
Boolean
Default Value
true
See
Source
options.js, line 1386

sketches

Description

Control the sketchcurves for pointer device or first and second finger.

Type
Object
Default Value
{
  enabled: false,
  0: {visible: true},
  1: {visible: true}
}
See
Source
options.js, line 1242

takeFirst

Description

If true the first element of the set JXG.board.objects having hasPoint==true is taken as drag element.

Type
Boolean
Default Value
false
Source
options.js, line 1404

takeSizeFromFile

Description

If true, when read from a file or string - the size of the div can be changed by the construction text.

Type
Boolean
Default Value
false
Source
options.js, line 1414

theme

Description

Set a visual theme for a board. At the moment this attribute is immutable. Available themes are

  • 'default'
  • 'mono_thin': a black / white theme using thin strokes. Restricted to 2D.
Type
String
Default Value
'default'
Example
const board = JXG.JSXGraph.initBoard('jxgbox', {
     boundingbox: [-5, 5, 5, -5], axis: true,
     theme: 'mono_thin'
 });

 var a = board.create('slider', [[1, 4], [3, 4], [-10, 1, 10]]);
 var p1 = board.create('point', [1, 2]);
 var ci1 = board.create('circle', [p1, 0.7]);
 var cu = board.create('functiongraph', ['x^2']);
 var l1 = board.create('line', [2, 3, -1]);
 var l2 = board.create('line', [-5, -3, -1], { dash: 2 });
 var i1 = board.create('intersection', [l1, l2]);
 var pol = board.create('polygon', [[1, 0], [4, 0], [3.5, 1]]);
 var an = board.create('angle', [pol.vertices[1], pol.vertices[0], pol.vertices[2]]);
 var se = board.create('sector', [pol.vertices[1], pol.vertices[2], pol.vertices[0]]);
 var ci1 = board.create('circle', [[-3, -3], 0.7], { center: { visible: true } });

Source
options.js, line 1424

title

Description

Title string for the board. Primarily used in an invisible text element for assistive technologies. The title is implemented with the attribute 'aria-label' in the JSXGraph container.

Content should be accessible to all users, not just to those with screen readers. Consider instead adding a text element with the title and add the attribute aria:{enable:true,label:"Your Title"}

Type
String
Default Value
''
Source
options.js, line 1479

zoom

Description

Control the possibilities for zoom interaction.

Possible sub-attributes with default values are:

zoom: {
  enabled: true,  // turns off zooming completely, if set to false.
  factorX: 1.25,  // horizontal zoom factor (multiplied to JXG.Board#zoomX)
  factorY: 1.25,  // vertical zoom factor (multiplied to JXG.Board#zoomY)
  wheel: true,    // allow zooming by mouse wheel
  needShift: true,  // mouse wheel zooming needs pressing of the shift key
  min: 0.001,       // minimal values of JXG.Board#zoomX and JXG.Board#zoomY, limits zoomOut
  max: 1000.0,      // maximal values of JXG.Board#zoomX and JXG.Board#zoomY, limits zoomIn
  center: 'auto',   // 'auto': the center of zoom is at the position of the mouse or at the midpoint of two fingers
                    // 'board': the center of zoom is at the board's center
  pinch: true,      // pinch-to-zoom gesture for proportional zoom
  pinchHorizontal: true, // Horizontal pinch-to-zoom zooms horizontal axis. Only available if keepaspectratio:false
  pinchVertical: true,   // Vertical pinch-to-zoom zooms vertical axis only. Only available if keepaspectratio:false
  pinchSensitivity: 7    // Sensitivity (in degrees) for recognizing horizontal or vertical pinch-to-zoom gestures.
}

If the zoom buttons are visible, zooming by clicking the buttons is still possible, regardless of zoom.enabled:true/false. If this should be prevented, set showZoom:false.

Deprecated: zoom.eps which is superseded by zoom.min

Type
Object
Default Value
See above
See
Source
options.js, line 1496

zoomX

Description

Zoom factor in horizontal direction.

Type
Number
Default Value
1.0
See
Source
options.js, line 1555

zoomY

Description

Zoom factor in vertical direction.

Type
Number
Default Value
1.0
See
Source
options.js, line 1566

registerEvents

Description

Allow user interaction by registering pointer events (including mouse and touch events), fullscreen, keyboard, resize, and zoom events. The latter events are essentially mouse wheel events. Decide if JSXGraph listens to these events.

Using a Boolean value turns on all events (or not), supplying an object of the form

 {
    fullscreen: true / false,
    keyboard: true / false,
    pointer: true / false,
    resize: true / false,
    wheel: true / false
 }

activates individual event handlers. If an event is NOT given, it will be activated.

This attribute is immutable. Please use JXG.Board#addEventHandlers() and JXG.Board#removeEventHandlers() directly.

Type
Boolean
Default Value
true
See
Source
options.js, line 1023

Inherited

none

Members

Own

(constant) BOARD_MODE_DRAG : Number

Description

Board is in drag mode, objects aren't highlighted on mouse over and the object referenced in JXG.Board#mouse is updated on mouse movement.

Type
Number
Source
base/board.js, line 98

(constant) BOARD_MODE_MOVE_ORIGIN : Number

Description

In this mode a mouse move changes the origin's screen coordinates.

Type
Number
Source
base/board.js, line 105

(constant) BOARD_MODE_NONE : Number

Description

Board is in no special mode, objects are highlighted on mouse over and objects may be clicked to start drag&drop.

Type
Number
Source
base/board.js, line 90

(constant) BOARD_MODE_ZOOM : Number

Description

This mode is active when the user zooms

Type
Number
Source
base/board.js, line 112

(constant) BOARD_QUALITY_HIGH : Number

Description

Update is made with high quality, e.g. graphs are evaluated at much more points.

Type
Number
See
Source
base/board.js, line 128

(constant) BOARD_QUALITY_LOW : Number

Description

Update is made with low quality, e.g. graphs are evaluated at a lesser amount of points.

Type
Number
See
Source
base/board.js, line 120

(private) _board_touches : Array

Description

Keeps a list of pointer devices which are currently touching the screen.

Type
Array
Source
base/board.js, line 597

(private) _change3DView : Boolean

Description

A flag which tells us if the update is triggered by a change of the 3D view. In that case we only have to update the projection of the 3D elements and can avoid a full board update.

Type
Boolean
Default Value
false
Source
base/board.js, line 640

(private) _drag_offset : Array

Description

Offset for large coords elements like images

Type
Array
Default Value
[0, 0]
Source
base/board.js, line 582

(private) _inputDevice : String

Description

Stores the input device used in the last down or move event.

Type
String
Default Value
'mouse'
Source
base/board.js, line 590

(private) _isResizing : Boolean

Description

A flag which tells us if a resize is in process

Type
Boolean
Default Value
false
See
Source
base/board.js, line 629

(private) _isScrolling : Boolean

Description

A flag which tells us if the user is scrolling the viewport

Type
Boolean
Default Value
false
See
Source
base/board.js, line 620

addEvent

Description

Alias of JXG.Board.on.

Source
base/board.js, line 6124

animationObjects : Object

Description

Stores all the objects that are currently running an animation.

Type
Object
Source
base/board.js, line 340

attr : Object

Description

Board attributes

Type
Object
Source
base/board.js, line 217

cPos : Array

Description

Cached result of getCoordsTopLeftCorner for touch/mouseMove-Events to save some DOM operations.

Type
Array
Source
base/board.js, line 439

(private) canvasHeight : Number

Description

Canvas Height

Type
Number
Source
base/board.js, line 297

(private) canvasWidth : Number

Description

Canvas width.

Type
Number
Source
base/board.js, line 290

container : String

Description

The html-id of the html element containing the board.

Type
String
Source
base/board.js, line 144

containerObj : Object

Description

Pointer to the html element containing the board.

Type
Object
Source
base/board.js, line 156

currentCBDef

Description

The current color blindness deficiency is stored in this property. If color blindness is not emulated at the moment, it's value is 'none'.

Source
base/board.js, line 503

dependentBoards : Array

Description

An array containing all other boards that are updated after this board has been updated.

Type
Array
See
Source
base/board.js, line 309

dimension : Number

Description

Dimension of the board.

Type
Number
Default Value
2
Source
base/board.js, line 228

downObjects : Array

Description

Collects all elements that triggered a mouse down event.

Type
Array
Source
base/board.js, line 465

drag_dx : Number

Description

The distance from the mouse to the dragged object in x direction when the user clicked the mouse button.

Type
Number
See
Source
base/board.js, line 398

drag_dy : Number

Description

The distance from the mouse to the dragged object in y direction when the user clicked the mouse button.

Type
Number
See
Source
base/board.js, line 405

drag_position : Array

Description

The last position where a drag event has been fired.

Type
Array
See
Source
base/board.js, line 412

elementsByName : Object

Description

An associative array / dictionary to store the objects of the board by name. The name of the object is the key and value is a reference to the object.

Type
Object
Source
base/board.js, line 358

focusObjects : Array

Description

Collects all elements that have keyboard focus. Should be either one or no element. Elements are stored with their id.

Type
Array
Source
base/board.js, line 473

geonextCompatibilityMode : Boolean

Description

If GEONExT constructions are displayed, then this property should be set to true. At the moment there should be no difference. But this may change.

Type
Boolean
Default Value
false
Source
base/board.js, line 512

(private) grids : Array

Description

Grids keeps track of all grids attached to this board.

Type
Array
Source
base/board.js, line 205

groups : Object

Description

An associative array containing all groups belonging to the board. Key is the id of the group and value is a reference to the object.

Type
Object
Source
base/board.js, line 334

hasMouseHandlers : Boolean

Description

A flag which tells if the board registers mouse events.

Type
Boolean
Default Value
false
Source
base/board.js, line 525

hasMouseUp : Boolean

Description

A flag which tells if the board the JXG.Board#mouseUpListener is currently registered.

Type
Boolean
Default Value
false
Source
base/board.js, line 553

hasPointerHandlers : Boolean

Description

A flag which stores if the board registered pointer events.

Type
Boolean
Default Value
false
Source
base/board.js, line 539

hasPointerUp : Boolean

Description

A flag which tells us if the board has a pointerUp event registered at the moment.

Type
Boolean
Default Value
false
Source
base/board.js, line 567

hasTouchEnd : Boolean

Description

A flag which tells if the board the JXG.Board#touchEndListener is currently registered.

Type
Boolean
Default Value
false
Source
base/board.js, line 560

hasTouchHandlers : Boolean

Description

A flag which tells if the board registers touch events.

Type
Boolean
Default Value
false
Source
base/board.js, line 532

hasWheelHandlers : Boolean

Description

A flag which stores if the board registered zoom events, i.e. mouse wheel scroll events.

Type
Boolean
Default Value
false
Source
base/board.js, line 546

highlightedObjects : Object

Description

An associative array containing all highlighted elements belonging to the board.

Type
Object
Source
base/board.js, line 346

id : String

Description

ID of the board

Type
String
Source
base/board.js, line 150

inUpdate : Boolean

Description

During the update process this is set to false to prevent an endless loop.

Type
Boolean
Default Value
false
Source
base/board.js, line 316

isSelecting : Boolean

Description

A flag which tells us if the user is selecting

Type
Boolean
Default Value
false
Source
base/board.js, line 611

isSketching : Array

Description

Array of length two of Boolean flags indicating if a pointer device (finger, mouse, pen) is adding points to board.sketches[i] (i=0,1). i=1 is only used for multi-touch with fingers.

User-supplied events might use this flag to test if sketching is active. Usually, this flag is true starting with a down event and ends with the up event.

Type
Array
See
Source
base/board.js, line 737

isSuspendedRedraw : Boolean

Description

If true updates are skipped.

Type
Boolean
Source
base/board.js, line 389

(private) keepaspectratio : Boolean

Description

Keep aspect ratio if bounding box is set and the width/height ratio differs from the width/height ratio of the canvas.

Type
Boolean
Source
base/board.js, line 283

mathLib

Source
base/board.js, line 742

mathLibJXG

Source
base/board.js, line 747

mode : Number

Description

The board mode the board is currently in. Possible values are

  • JXG.Board.BOARD_MODE_NONE
  • JXG.Board.BOARD_MODE_DRAG
  • JXG.Board.BOARD_MODE_MOVE_ORIGIN
Type
Number
Source
base/board.js, line 369

mouse : JXG.GeometryElement

Description

References to the object that is dragged with the mouse on the board.

Type
JXG.GeometryElement
See
Source
base/board.js, line 419

needsFullUpdate : Boolean

Description

Full updates are needed after zoom and axis translates. This saves some time during an update.

Type
Boolean
Default Value
false
Source
base/board.js, line 488

numObjects : Number

Description

Number of objects ever created on this board. This includes every object, even invisible and deleted ones.

Type
Number
Source
base/board.js, line 352

objects : Object

Description

An associative array containing all geometric objects belonging to the board. Key is the id of the object and value is a reference to the object.

Type
Object
Source
base/board.js, line 322

objectsList : Array

Description

An array containing all geometric objects on the board in the order of construction.

Type
Array
Source
base/board.js, line 328

options : JXG.Options

Description

Copy of the default options

Type
JXG.Options
Source
base/board.js, line 211

(private) origin : Object

Description

Coordinates of the boards origin. This a object with the two properties usrCoords and scrCoords. usrCoords always equals [1, 0, 0] and scrCoords stores the boards origin in homogeneous screen coordinates.

Type
Object
Source
base/board.js, line 239

positionAccessLast : Number

Description

Contains the last time (epoch, msec) since the last getCoordsTopLeftCorner call which was not thrown away.

Type
Number
Source
base/board.js, line 459

reducedUpdate : Boolean

Description

If reducedUpdate is set to true then only the dragged element and few (e.g. 2) following elements are updated during mouse move. On mouse up the whole construction is updated. This enables us to be fast even on very slow devices.

Type
Boolean
Default Value
false
Source
base/board.js, line 497

removeEvent

Description

Alias of JXG.Board.off.

Source
base/board.js, line 6145

resizeHandlers : Array

Description

Array containing the events related to resizing that have event listeners.

Type
Array
Default Value
[]
Source
base/board.js, line 574

selectingBox : Array

Description

A bounding box for the selection

Type
Array
Default Value
[ [0,0], [0,0] ]
Source
base/board.js, line 647

selectingMode : Boolean

Description

A flag which tells us if the board is in the selecting mode

Type
Boolean
Default Value
false
Source
base/board.js, line 604

sketch : JXG.Curve

Description

Alias for the first sketchcurve, i.e. for board.sketches[0].

Type
JXG.Curve
See
Source
base/board.js, line 725

sketches : Array

Description

Array of length two containing sketchcurves of the board. In case of mouse or pen only the first entry is used. In case of finger input, sketchcurves for the first and second finger are possible.

Type
Array
See
Example
const board = JXG.JSXGraph.initBoard('jxgbox', {
     boundingbox: [-10, 10, 10, -10],
     axis: true,
     sketches: {
         enabled: true,
         0: {strokeWidth: 2, visible: true, maxLength: 20},
         1: {strokeWidth: 3, visible: true}
     }
 });

 // Use event handler to access the actual curve
 board.on('move', function(evt) {
   console.log('JSXGraph example: move', this.sketches[0].dataX.length);
 });

 // Use event handler to access the actual curve
 board.on('up', function(evt) {
   console.log('JSXGraph example: up', this.sketches[0].dataX.length);
 });

Source
base/board.js, line 718

touchMoveLast : Number

Description

Contains the last time (epoch, msec) since the last touchMove event which was not thrown away or since touchStart because Android's Webkit browser fires too much of them.

Type
Number
Source
base/board.js, line 446

touchMoveLastId : Number

Description

Contains the pointerId of the last touchMove event which was not thrown away or since touchStart because Android's Webkit browser fires too much of them.

Type
Number
Source
base/board.js, line 453

touches : Array

Description

Keeps track on touched elements, like JXG.Board#mouse does for mouse events.

Type
Array
See
Source
base/board.js, line 426

(private) unitX : Number

Description

The number of pixels which represent one unit in user-coordinates in x direction.

Type
Number
Source
base/board.js, line 268

(private) unitY : Number

Description

The number of pixels which represent one unit in user-coordinates in y direction.

Type
Number
Source
base/board.js, line 275

updateQuality : Number

Description

The update quality of the board. In most cases this is set to JXG.Board#BOARD_QUALITY_HIGH. If JXG.Board#mode equals JXG.Board#BOARD_MODE_DRAG this is set to JXG.Board#BOARD_QUALITY_LOW to speed up the update process by e.g. reducing the number of evaluation points when plotting functions. Possible values are

  • BOARD_QUALITY_LOW
  • BOARD_QUALITY_HIGH
Type
Number
See
Source
base/board.js, line 383

userLog : Array

Description

Array to log user activity. Entries are objects of the form '{type, id, start, end}' notifying the start time as well as the last time of a single event of type 'type' on a JSXGraph element of id 'id'. 'start' and 'end' contain the amount of milliseconds elapsed between 1 January 1970 00:00:00 UTC and the time the event happened.

For the time being (i.e. v1.5.0) the only supported type is 'drag'.

Type
Array
Source
base/board.js, line 660

xmlString : String

Description

A string containing the XML text of the construction. Only useful if a construction is read from a GEONExT-, Intergeo-, Geogebra-, or Cinderella-File.

Type
String
Source
base/board.js, line 433

Inherited

none

Methods

Own

_createSelectionPolygon

_getPointerInputDevice

_handleClicks

_handleDblClicks

_isPointerRegistered

_isRequiredKeyPressed

_moveSelecting

_pointerClearTouches

_pointerRemoveTouches

_pointerStorePosition

_removeObj

_set

_setSelectionPolygonFromBox

_startSelecting

_stopSelecting

_testForSelection

addAnimation

addChild

addConditions

addEventHandlers

addFullscreenEventHandlers

addGrid

addHook

addKeyboardEventHandlers

addLogEntry

addMouseEventHandlers

addPointerEventHandlers

addResizeEventHandlers

addToSketchCurve

addTouchEventHandlers

addWheelEventHandlers

animate

applyZoom

calculateSnapSizes

checkFrameRate

clearTraces

clickDownArrow

clickLeftArrow

clickRightArrow

clickUpArrow

create

createElement

createRoulette

dehighlightAll

displayInfobox

emulateColorblindness

finalizeAdding

finalizeSketchCurve

fullUpdate

fullscreenListener

generateId

generateName

gestureChangeListener

gestureStartListener

getAllObjectsUnderMouse

getAllUnderMouse

getBoundingBox

getCoordsTopLeftCorner

getLocationOrigin

getMousePosition

getPointLoc

getScrCoordsOfMouse

getTwoFingerTransform

getUsrCoordsOfMouse

hasPoint

highlightCustomInfobox

highlightInfobox

initGeonextBoard

initInfobox

initMoveObject

initMoveOrigin

initSketchCurve

keyDownListener

keyFocusInListener

keyFocusOutListener

migratePoint

mouseClickListener

mouseDblClickListener

mouseDownListener

mouseMoveListener

mouseUpListener

mouseWheelListener

moveObject

moveOrigin

originMoveEnd

pointerClickListener

pointerDblClickListener

pointerDownListener

pointerLeaveListener

pointerMoveListener

pointerUpListener

prepareUpdate

printListener

printListenerMatch

removeAncestors

removeChild

removeEventHandlers

removeFullscreenEventHandlers

removeGrids

removeHook

removeKeyboardEventHandlers

removeMouseEventHandlers

removeObject

removePointerEventHandlers

removeResizeEventHandlers

removeTouchEventHandlers

resizeContainer

resizeListener

saveStartPos

scrollListener

select

setAttribute

setBoundingBox

setId

setZoom

showDependencies

showXML

startFullscreenResizeObserver

startIntersectionObserver

startResizeObserver

startSelectionMode

stopAllAnimation

stopFullscreenResizeObserver

stopIntersectionObserver

stopResizeObserver

stopSelectionMode

suppressDefault

suspendUpdate

toFullscreen

touchEndListener

touchMoveListener

touchOriginMove

touchStartListener

touchStartMoveOriginOneFinger

twoFingerMove

twoFingerTouchObject

unsuspendUpdate

update

updateCSSTransforms

updateConditions

updateContainerDims

updateCoords

updateElements

updateHooks

updateInfobox

updateRenderer

updateRendererCanvas

zoom100

zoomAllPoints

zoomElements

zoomIn

zoomOut

(private) _createSelectionPolygon(attr) → {Object}

Create the internal selection polygon, which will be available as board.selectionPolygon.

Parameters

Name Type Description
attr Object

board attributes, e.g. the subobject board.attr.

Returns

pointer to the board to enable chaining.

Type
Object

Details

Source
base/board.js, line 7479

(private) _getPointerInputDevice(evt) → {String}

Determine which input device is used for this action. Possible devices are 'touch', 'pen' and 'mouse'. This affects the precision and certain events. In case of no browser, 'mouse' is used.

Parameters

Name Type Description
evt Event

The browsers event object.

Returns

'mouse', 'pen', or 'touch'

Type
String

Details

See
Source
base/board.js, line 2798

(private) _handleClicks(evt, evtArray)

Internal handling of click events for pointers and mouse.

Parameters

Name Type Description
evt Event

The browsers event object.

evtArray Array

list of event names

Details

Source
base/board.js, line 3032

(private) _handleDblClicks(evt, evtArray)

Internal handling of dblclick events for pointers and mouse.

Parameters

Name Type Description
evt Event

The browsers event object.

evtArray Array

list of event names

Details

Source
base/board.js, line 3092

(private) _isPointerRegistered(evt) → {Boolean}

Check if pointer event is already registered in JXG.Board#_board_touches.

Parameters

Name Type Description
evt Object

Event object

Returns

true if down event has already been sent.

Type
Boolean

Details

Source
base/board.js, line 2690

(private) _isRequiredKeyPressed(evt, action) → {Boolean}

Test if the required key combination is pressed for wheel zoom, move origin and selection

Parameters

Name Type Description
evt Object

Mouse or pen event

action String

String containing the action: 'zoom', 'pan', 'selection'. Corresponds to the attribute subobject.

Returns

true or false.

Type
Boolean

Details

Source
base/board.js, line 2662

(private) _moveSelecting(pos)

Update the selection rectangle during a move event.

Parameters

Name Type Description
pos Array

Screen coordiates of the move event

Details

Source
base/board.js, line 7412

(private) _pointerClearTouches() → {JXG.Board}

Remove all registered fingers from JXG.Board#_board_touches. This might be necessary if too many fingers have been registered.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2763

(private) _pointerRemoveTouches(evt) → {JXG.Board}

Deregisters a pointer event in JXG.Board#_board_touches. It happens if a finger has been lifted from the screen.

Parameters

Name Type Description
evt Object

Event object

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2745

(private) _pointerStorePosition(evt) → {JXG.Board}

Store the position of a pointer event. If not yet done, registers a pointer event in JXG.Board#_board_touches. Allows to follow the path of that finger on the screen. Only two simultaneous touches are supported.

Parameters

Name Type Description
evt Object

Event object

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2713

(private) _removeObj(object, saveMethodopt) → {JXG.Board}

Inner, recursive method of removeObject.

Parameters

Name Type Attributes Default Description
object JXG.GeometryElement | Array

The object to remove or array of objects to be removed. The element(s) is/are given by name, id or a reference.

saveMethod Boolean <optional>
false

If saveMethod=true, the algorithm runs through all elements and tests if the element to be deleted is a child element. If this is the case, it will be removed from the list of child elements. If saveMethod=false (default), the element is removed from the lists of child elements of all its ancestors. The latter should be much faster.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5539

(private) _set(key, value)

Sets the value of attribute key to value.

Parameters

Name Type Description
key String

The attribute's name.

value

The new value

Details

Source
base/board.js, line 6524

(private) _setSelectionPolygonFromBox()

Update the Selection rectangle.

Details

Source
base/board.js, line 7437

(private) _startSelecting(pos)

Start the selection of a region.

Parameters

Name Type Description
pos Array

Screen coordiates of the upper left corner of the selection rectangle.

Details

Source
base/board.js, line 7398

(private) _stopSelecting(evt)

Update the selection rectangle during an up event. Stop selection.

Parameters

Name Type Description
evt Object

Event object

Details

Source
base/board.js, line 7425

_testForSelection(evt)

Test if a down event should start a selection. Test if the required keys are pressed. If yes, JXG.Board.startSelectionMode is called.

Parameters

Name Type Description
evt Object

Event object

Details

Source
base/board.js, line 7464

addAnimation(element) → {JXG.Board}

Adds an animation. Animations are controlled by the boards, so the boards need to be aware of the animated elements. This function tells the board about new elements to animate.

Parameters

Name Type Description
element JXG.GeometryElement

The element which is to be animated.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6851

addChild(board) → {JXG.Board}

Adds a dependent board to this board.

Parameters

Name Type Description
board JXG.Board

A reference to board which will be updated after an update of this board occurred.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6168

addConditions(str)

Add conditional updates to the elements.

Parameters

Name Type Description
str String

String containing conditional update in geonext syntax

Details

Source
base/board.js, line 5062

addEventHandlers()

Add all possible event handlers to the board object that move objects, i.e. mouse, pointer and touch events.

Details

Source
base/board.js, line 2032

addFullscreenEventHandlers()

Add fullscreen events which update the CSS transformation matrix to correct the mouse/touch/pointer positions in case of CSS transformations.

Details

Source
base/board.js, line 2274

addGrid() → {JXG.Board}

Adds a grid to the board according to the settings given in board.options.

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 6266

addHook(hook, mopt, contextopt) → {Number}

Please use JXG.Board.on instead.

Parameters

Name Type Attributes Default Description
hook function

A function to be called by the board after an update occurred.

m String <optional>
'update'

When the hook is to be called. Possible values are mouseup, mousedown and update.

context Object <optional>
board

Determines the execution context the hook is called. This parameter is optional, default is the board object the hook is attached to.

Returns

Id of the hook, required to remove the hook from the board.

Type
Number

Details

Deprecated
Yes
Source
base/board.js, line 6109

addKeyboardEventHandlers()

Register keyboard event handlers.

Details

Source
base/board.js, line 2296

addLogEntry(type, obj) → {JXG.Board}

Add user activity to the array 'board.userLog'.

Parameters

Name Type Description
type String

Event type, e.g. 'drag'

obj Object

JSXGraph element object

Returns

Reference to the board

Type
JXG.Board

Details

See
Source
base/board.js, line 8254

addMouseEventHandlers()

Registers mouse move, down and wheel event handlers.

Details

Source
base/board.js, line 2218

addPointerEventHandlers()

Registers pointer event handlers.

Details

Source
base/board.js, line 2186

addResizeEventHandlers()

Add resize related event handlers

Details

Source
base/board.js, line 2084

(private) addToSketchCurve(evt)

Add the position of the event to the sketchcurve i in board.sketches[]. Called at move events. Point is only added if board.isSketching[i] = true.

Parameters

Name Type Description
evt Object

Event object

Details

See
Source
base/board.js, line 7538

addTouchEventHandlers(appleGestures)

Register touch start and move and gesture start and change event handlers.

Parameters

Name Type Description
appleGestures Boolean

If set to false the gesturestart and gesturechange event handlers will not be registered.

Since iOS 13, touch events were abandoned in favour of pointer events

Details

Source
base/board.js, line 2239

addWheelEventHandlers()

Registers pointer event handlers.

Details

Source
base/board.js, line 2262

animate() → {JXG.Board}

General purpose animation function. This currently only supports moving points from one place to another. This is faster than managing the animation per point, especially if there is more than one animated point at the same time.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6893

applyZoom() → {JXG.Board}

Apply update on all objects with the new zoom-factors. Clears all traces.

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 5285

calculateSnapSizes() → {JXG.Board}

Calculates adequate snap sizes.

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 5225

(private) checkFrameRate(evt) → {Boolean}

Returns false if the event has been triggered faster than the maximum frame rate.

Parameters

Name Type Description
evt Event

Event object given by the browser (unused)

Returns

If the event has been triggered faster than the maximum frame rate, false is returned.

Type
Boolean

Details

See
Source
base/board.js, line 996

clearTraces() → {JXG.Board}

Delete the elements drawn as part of a trace of an element.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6370

clickDownArrow() → {JXG.Board}

Handler for click on down arrow in the navigation bar

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2472

clickLeftArrow() → {JXG.Board}

Handler for click on left arrow in the navigation bar

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2436

clickRightArrow() → {JXG.Board}

Handler for click on right arrow in the navigation bar

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2448

clickUpArrow() → {JXG.Board}

Handler for click on up arrow in the navigation bar

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 2460

create(elementType, parents, attributesopt) → {Object}

Creates a new geometric element of type elementType.

Parameters

Name Type Attributes Description
elementType String

Type of the element to be constructed given as a string e.g. 'point' or 'circle'.

parents Array

Array of parent elements needed to construct the element e.g. coordinates for a point or two points to construct a line. This highly depends on the elementType that is constructed. See the corresponding JXG.create* methods for a list of possible parameters.

attributes Object <optional>

An object containing the attributes to be set. This also depends on the elementType. Common attributes are name, visible, strokeColor.

Returns

Reference to the created element. This is usually a GeometryElement, but can be an array containing two or more elements.

Type
Object

Details

Source
base/board.js, line 6301

createElement()

Deprecated name for JXG.Board.create.

Details

Deprecated
Yes
Source
base/board.js, line 6361

createRoulette(c1, c2, start_c1, stepsize, direction, time, pointlist)

Function to animate a curve rolling on another curve.

Example

// Line which will be the floor to roll upon.
var line = board.create('curve', [function (t) { return t;}, function (t){ return 1;}], {strokeWidth:6});
// Center of the rolling circle
var C = board.create('point',[0,2],{name:'C'});
// Starting point of the rolling circle
var P = board.create('point',[0,1],{name:'P', trace:true});
// Circle defined as a curve. The circle 'starts' at P, i.e. circle(0) = P
var circle = board.create('curve',[
          function (t){var d = P.Dist(C),
                          beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P);
                      t += beta;
                      return C.X()+d*Math.cos(t);
          },
          function (t){var d = P.Dist(C),
                          beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P);
                      t += beta;
                      return C.Y()+d*Math.sin(t);
          },
          0,2*Math.PI],
          {strokeWidth:6, strokeColor:'green'});

// Point on circle
var B = board.create('glider',[0,2,circle],{name:'B', color:'blue',trace:false});
var roll = board.createRoulette(line, circle, 0, Math.PI/20, 1, 100, [C,P,B]);
roll.start() // Start the rolling, to be stopped by roll.stop()

Parameters

Name Type Description
c1 Curve

JSXGraph curve building the floor where c2 rolls

c2 Curve

JSXGraph curve which rolls on c1.

start_c1 number

The parameter t such that c1(t) touches c2. This is the start position of the rolling process

stepsize Number

Increase in t in each step for the curve c1

direction Number
time Number

Delay time for setInterval()

pointlist Array

Array of points which are rolled in each step. This list should contain all points which define c2 and gliders on c2.

Details

Source
base/board.js, line 8359

dehighlightAll() → {JXG.Board}

Remove highlighting of all elements.

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 4841

displayInfobox(val) → {JXG.Board}

Set infobox visible / invisible.

It uses its property hiddenByParent to memorize its status. In this way, many DOM access can be avoided.

Parameters

Name Type Description
val Boolean

true for visible, false for invisible

Returns

Reference to the board.

Type
JXG.Board

Details

See
Source
base/board.js, line 4795

emulateColorblindness(deficiency) → {JXG.Board}

Initializes color blindness simulation.

Parameters

Name Type Description
deficiency String

Describes the color blindness deficiency which is simulated. Accepted values are 'protanopia', 'deuteranopia', and 'tritanopia'.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 7072

finalizeAdding(obj)

After construction of the object the visibility is set and the label is constructed if necessary.

Parameters

Name Type Description
obj Object

The object to add.

Details

Source
base/board.js, line 964

(private) finalizeSketchCurve(evt)

Ends adding points to the sketchcurve i in board.sketches[]. Called at up events. Sets board.isSketching[i] = false. Empties the curve if deleteOnUp==true;

Parameters

Name Type Description
evt Object

Event object

Details

See
Source
base/board.js, line 7573

fullUpdate() → {JXG.Board}

Runs through all elements and calls their update() method and update the conditions. This is necessary after zooming and changing the bounding box.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6255

fullscreenListener(evt)

If fullscreen mode is toggled, the possible CSS transformations which are applied to the JSXGraph canvas have to be reread. Otherwise the position of upper left corner is wrongly interpreted.

Parameters

Name Type Description
evt Object

fullscreen event object (unused)

Details

Source
base/board.js, line 8105

generateId() → {String}

Generates unique id for a board. The result is randomly generated and prefixed with 'jxgBoard'.

Returns

Unique id for a board.

Type
String

Details

Source
base/board.js, line 916

generateName(object) → {String}

Generates an unique name for the given object. The result depends on the objects type, if the object is a JXG.Point, capital characters are used, if it is of type JXG.Line only lower case characters are used. If object is of type JXG.Polygon, a bunch of lower case characters prefixed with P_ are used. If object is of type JXG.Circle the name is generated using lower case characters. prefixed with k_ is used. In any other case, lower case chars prefixed with s_ is used.

Parameters

Name Type Description
object Object

Reference of an JXG.GeometryElement that is to be named.

Returns

Unique name for the object.

Type
String

Details

Source
base/board.js, line 836

gestureChangeListener(evt) → {Boolean}

Triggered on iOS/Safari while the user inputs a gesture (e.g. pinch) and is used to zoom into the board. Works on iOS/Safari and Android.

Parameters

Name Type Description
evt Event

Browser event object

Returns

Type
Boolean

Details

Source
base/board.js, line 2486

gestureStartListener(evt) → {Boolean}

Called by iOS/Safari as soon as the user starts a gesture. Works natively on iOS/Safari, on Android we emulate it.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 2626

getAllObjectsUnderMouse(evt) → {Array}

Collects all elements under current mouse position.

Parameters

Name Type Description
evt Event

Event object containing the mouse coordinates.

Returns

Array of elements at the current mouse position.

Type
Array

Details

See
Source
base/board.js, line 4960

getAllUnderMouse(evt) → {Array}

Collects all elements under current mouse position plus current user coordinates of mouse cursor.

Parameters

Name Type Description
evt Event

Event object containing the mouse coordinates.

Returns

Array of elements at the current mouse position plus current user coordinates of mouse.

Type
Array

Details

See
Source
base/board.js, line 4947

getBoundingBox() → {Array}

Get the bounding box of the board.

Returns

bounding box [x1,y1,x2,y2] upper left corner, lower right corner

Type
Array

Details

Source
base/board.js, line 6508

getCoordsTopLeftCorner() → {Array}

Calculates mouse coordinates relative to the boards container.

Returns

Array of coordinates relative the boards container top left corner.

Type
Array

Details

Source
base/board.js, line 1017

getLocationOrigin(marginopt) → {Array}

This function calculates where the origin is located (@link Board#getPointLoc). Optional a margin to the inner of the board is respected.

Parameters

Name Type Attributes Description
margin Array | Number <optional>

Optional margin for the inner of the board: [top, right, bottom, left]. A single number m is interpreted as [m, m, m, m].

Returns

[u,v] which shows where the origin is located (@link Board#getPointLoc).

Type
Array

Details

Source
base/board.js, line 1324

getMousePosition(e, iopt) → {Array}

Get the position of the pointing device in screen coordinates, relative to the upper left corner of the host tag.

Parameters

Name Type Attributes Description
e Event

Event object given by the browser.

i Number <optional>

Only use in case of touch events. This determines which finger to use and should not be set for mouseevents.

Returns

Contains the mouse coordinates in screen coordinates, ready for JXG.Coords

Type
Array

Details

Source
base/board.js, line 1336

getPointLoc(position, marginopt) → {Array}

This function divides the board into 9 sections and returns an array [u,v] which symbolizes the location of position. Optional a margin to the inner of the board is respected.

Example

var point1, point2, point3, point4, margin,
            p1Location, p2Location, p3Location, p4Location,
            helppoint1, helppoint2, helppoint3, helppoint4;

     // margin to make the boundingBox virtually smaller
     margin = [2,2,2,2];

     // Points which are seen on screen
     point1 = board.create('point', [0,0]);
     point2 = board.create('point', [0,7]);
     point3 = board.create('point', [7,7]);
     point4 = board.create('point', [-7,-5]);

     p1Location = board.getPointLoc(point1.coords.usrCoords, margin);
     p2Location = board.getPointLoc(point2.coords.usrCoords, margin);
     p3Location = board.getPointLoc(point3.coords.usrCoords, margin);
     p4Location = board.getPointLoc(point4.coords.usrCoords, margin);

     // Text seen on screen
     board.create('text', [1,-1, "getPointLoc(A): " + "[" + p1Location + "]"])
     board.create('text', [1,-2, "getPointLoc(B): " + "[" + p2Location + "]"])
     board.create('text', [1,-3, "getPointLoc(C): " + "[" + p3Location + "]"])
     board.create('text', [1,-4, "getPointLoc(D): " + "[" + p4Location + "]"])


     // Helping points that are used to create the helping lines
     helppoint1 = board.create('point', [(function (){
         var bbx = board.getBoundingBox();
         return [bbx[2] - 2, bbx[1] -2];
     })], {
         visible: false,
     })

     helppoint2 = board.create('point', [(function (){
         var bbx = board.getBoundingBox();
         return [bbx[0] + 2, bbx[1] -2];
     })], {
         visible: false,
     })

     helppoint3 = board.create('point', [(function (){
         var bbx = board.getBoundingBox();
         return [bbx[0]+ 2, bbx[3] + 2];
     })],{
         visible: false,
     })

     helppoint4 = board.create('point', [(function (){
         var bbx = board.getBoundingBox();
         return [bbx[2] -2, bbx[3] + 2];
     })], {
         visible: false,
     })

     // Helping lines to visualize the 9 sectors and the margin
     board.create('line', [helppoint1, helppoint2]);
     board.create('line', [helppoint2, helppoint3]);
     board.create('line', [helppoint3, helppoint4]);
     board.create('line', [helppoint4, helppoint1]);

Parameters

Name Type Attributes Description
position Array

Array of requested position [x, y] or [w, x, y].

margin Array | Number <optional>

Optional margin for the inner of the board: [top, right, bottom, left]. A single number m is interpreted as [m, m, m, m].

Returns

[u,v] with the following meanings:

    v    u > |   -1    |    0   |    1   |
------------------------------------------
    1        | [-1,1]  |  [0,1] |  [1,1] |
------------------------------------------
    0        | [-1,0]  |  Board |  [1,0] |
------------------------------------------
   -1        | [-1,-1] | [0,-1] | [1,-1] |

Positions inside the board (minus margin) return the value [0,0].

Type
Array

Details

Source
base/board.js, line 1286

(private) getScrCoordsOfMouse(x, y) → {Array}

Returns the input parameters in an array. This method looks pointless and it really is, but it had a purpose once.

Parameters

Name Type Description
x Number

X coordinate in screen coordinates

y Number

Y coordinate in screen coordinates

Returns

Coordinates [x, y] of the mouse in screen coordinates.

Type
Array

Details

See
Source
base/board.js, line 4891

getTwoFingerTransform(finger1, finger1, scalable, rotatable) → {Array}

Compute the transformation matrix to move an element according to the previous and actual positions of finger 1 and finger 2. See also https://math.stackexchange.com/questions/4010538/solve-for-2d-translation-rotation-and-scale-given-two-touch-point-movements

Parameters

Name Type Description
finger1 Object

Actual and previous position of finger 1

finger1 Object

Actual and previous position of finger 1

scalable Boolean

Flag if element may be scaled

rotatable Boolean

Flag if element may be rotated

Returns

Type
Array

Details

Source
base/board.js, line 1646

getUsrCoordsOfMouse(evt) → {Array}

This method calculates the user coords of the current mouse coordinates.

Example

board.on('up', function (evt) {
        var a = board.getUsrCoordsOfMouse(evt),
            x = a[0],
            y = a[1],
            somePoint = board.create('point', [x,y], {name:'SomePoint',size:4});
            // Shorter version:
            //somePoint = board.create('point', a, {name:'SomePoint',size:4});
        });

Parameters

Name Type Description
evt Event

Event object containing the mouse coordinates.

Returns

Coordinates [x, y] of the mouse in user coordinates.

Type
Array

Details

See
Source
base/board.js, line 4930

hasPoint(x, yopt) → {Boolean}

Checks if the given point is inside the boundingbox.

Parameters

Name Type Attributes Description
x Number | JXG.Coords

User coordinate or JXG.Coords object.

y Number <optional>

User coordinate. May be omitted in case x is a JXG.Coords object.

Returns

Type
Boolean

Details

Source
base/board.js, line 7214

highlightCustomInfobox(text, elopt) → {JXG.Board}

Changes the text of the info box to what is provided via text.

Parameters

Name Type Attributes Description
text String
el JXG.GeometryElement <optional>

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 4832

highlightInfobox(x, y, elopt) → {JXG.Board}

Changes the text of the info box to show the given coordinates.

Parameters

Name Type Attributes Description
x Number
y Number
el JXG.GeometryElement <optional>

The element the mouse is pointing at

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 4821

initGeonextBoard() → {JXG.Board}

Initialize some objects which are contained in every GEONExT construction by default, but are not contained in the gxt files.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5703

initInfobox() → {JXG.Board}

Initialize the info box object which is used to display the coordinates of points near the mouse pointer,

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 4649

initMoveObject(x, y, evt, type) → {Array}

Collects all elements below the current mouse pointer and fulfilling the following constraints:

  • isDraggable
  • visible
  • not fixed
  • not frozen

Parameters

Name Type Description
x Number

Current mouse/touch coordinates

y Number

current mouse/touch coordinates

evt Object

An event object

type String

What type of event? 'touch', 'mouse' or 'pen'.

Returns

A list of geometric elements.

Type
Array

Details

Source
base/board.js, line 1398

initMoveOrigin(x, y)

Initiate moving the origin. This is used in mouseDown and touchStart listeners.

Parameters

Name Type Description
x Number

Current mouse/touch coordinates

y Number

Current mouse/touch coordinates

Details

Source
base/board.js, line 1375

(private) initSketchCurve(evt)

Reset the sketchcurves in board.sketches[] to length 0 and add the position of the event as first point of the sketch curve. Called at down events.

Sets board.isSketching[i] = true where i depends on the finger (1st or 2nd).

Parameters

Name Type Description
evt Object

Event object

Details

See
Source
base/board.js, line 7512

keyDownListener(evt)

Allow moving of JSXGraph elements with arrow keys. The selection of the element is done with the tab key. For this, the attribute 'tabindex' of the element has to be set to some number (default=0). tabindex corresponds to the HTML and SVG attribute of the same name.

Panning of the construction is done with arrow keys if the pan key (shift or ctrl - depending on the board attributes) is pressed.

Zooming is triggered with the keys +, o, -, if the pan key (shift or ctrl - depending on the board attributes) is pressed.

Keyboard control (move, pan, and zoom) is disabled if an HTML element of type input or textarea has received focus.

Parameters

Name Type Description
evt Event

The browser's event object

Details

See
Source
base/board.js, line 4173

keyFocusInListener(evt)

Event listener for SVG elements getting focus. This is needed for highlighting when using keyboard control. Only elements having the attribute 'tabindex' can receive focus.

Parameters

Name Type Description
evt Event

The browser's event object

Details

See
Source
base/board.js, line 4359

keyFocusOutListener(evt)

Event listener for SVG elements losing focus. This is needed for dehighlighting when using keyboard control. Only elements having the attribute 'tabindex' can receive focus.

Parameters

Name Type Description
evt Event

The browser's event object

Details

See
Source
base/board.js, line 4392

migratePoint(src, dest, copyName) → {JXG.Board}

Migrate the dependency properties of the point src to the point dest and delete the point src. For example, a circle around the point src receives the new center dest. The old center src will be deleted.

Parameters

Name Type Description
src Point

Original point which will be deleted

dest Point

New point with the dependencies of src.

copyName Boolean

Flag which decides if the name of the src element is copied to the dest element.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6991

mouseClickListener(evt)

This method is called by the browser when the mouse device clicks on the screen.

Parameters

Name Type Description
evt Event

The browsers event object.

Details

Source
base/board.js, line 3136

mouseDblClickListener(evt)

This method is called by the browser when the mouse device double clicks on the screen.

Parameters

Name Type Description
evt Event

The browsers event object.

Details

Source
base/board.js, line 3144

mouseDownListener(evt) → {Boolean}

This method is called by the browser when the mouse button is clicked.

Parameters

Name Type Description
evt Event

The browsers event object.

Returns

True if no element is found under the current mouse pointer, false otherwise.

Type
Boolean

Details

Source
base/board.js, line 3931

mouseMoveListener(evt)

This method is called by the browser when the mouse is moved.

Parameters

Name Type Description
evt Event

The browsers event object.

Details

Source
base/board.js, line 4016

mouseUpListener(evt)

This method is called by the browser when the mouse button is released.

Parameters

Name Type Description
evt Event

Details

Source
base/board.js, line 4066

mouseWheelListener(evt) → {Boolean}

Handler for mouse wheel events. Used to zoom in and out of the board.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 4119

moveObject(x, y, o, evt, type)

Moves an object.

Parameters

Name Type Description
x Number

Coordinate

y Number

Coordinate

o Object

The touch object that is dragged: {JXG.Board#mouse} or {JXG.Board#touches}.

evt Object

The event object.

type String

Mouse or touch event?

Details

Source
base/board.js, line 1526

moveOrigin(x, y, diffopt) → {JXG.Board}

Moves the origin and initializes an update of all elements.

Parameters

Name Type Attributes Default Description
x Number
y Number
diff Boolean <optional>
false

Returns

Reference to this board.

Type
JXG.Board

Details

Source
base/board.js, line 5021

(private) originMoveEnd() → {null}

Stop moving the origin with one finger

Returns

null

Type
null

Details

Source
base/board.js, line 2003

pointerClickListener(evt)

This method is called by the browser when a pointer device clicks on the screen.

Parameters

Name Type Description
evt Event

The browsers event object.

Details

Source
base/board.js, line 3120

pointerDblClickListener(evt)

This method is called by the browser when a pointer device double clicks on the screen.

Parameters

Name Type Description
evt Event

The browsers event object.

Details

Source
base/board.js, line 3128

pointerDownListener(evt, object, allowDefaultEventHandlingopt) → {Boolean}

This method is called by the browser when a pointing device is pressed on the screen.

Parameters

Name Type Attributes Default Description
evt Event

The browsers event object.

object Object

If the object to be dragged is already known, it can be submitted via this parameter

allowDefaultEventHandling Boolean <optional>
false

If true event is not canceled, i.e. prevent call of evt.preventDefault()

Returns

false if the first finger event is sent twice, or not a browser, or in selection mode. Otherwise returns true.

Type
Boolean

Details

Source
base/board.js, line 2824

pointerLeaveListener(evt) → {Boolean}

Triggered by the pointerleave event. This is needed in addition to JXG.Board#pointerUpListener in the situation that a pen is used and after an up event the pen leaves the hover range vertically. Here, it happens that after the pointerup event further pointermove events are fired and elements get highlighted. This highlighting has to be cancelled.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 3391

pointerMoveListener(evt) → {Boolean}

Called periodically by the browser while the user moves a pointing device across the screen.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 3168

pointerUpListener(evt) → {Boolean}

Triggered as soon as the user stops touching the device with at least one finger.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 3285

prepareUpdate(dragopt) → {JXG.Board}

Sets for all objects the needsUpdate flag to 'true'.

In case the parameter drag has elType: view3d_slider, no elements are recomputated, only 3D elements are projected to the new view

Parameters

Name Type Attributes Description
drag JXG.GeometryElement <optional>

Optional element that is dragged.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5858

printListener(evtopt)

Update the container before and after printing.

Parameters

Name Type Attributes Description
evt Event <optional>

Details

Source
base/board.js, line 4624

printListenerMatch(mql)

Wrapper for printListener to be used in mediaQuery matches.

Parameters

Name Type Description
mql MediaQueryList

Details

Source
base/board.js, line 4632

removeAncestors(object) → {JXG.Board}

Removes the ancestors of an object an the object itself from board and renderer.

Parameters

Name Type Description
object JXG.GeometryElement

The object to remove.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5684

removeChild(board) → {JXG.Board}

Deletes a board from the list of dependent boards.

Parameters

Name Type Description
board JXG.Board

Reference to the board which will be removed.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6181

removeEventHandlers()

Remove all event handlers from the board object

Details

Source
base/board.js, line 2054

removeFullscreenEventHandlers()

Remove all registered event handlers regarding fullscreen mode.

Details

Source
base/board.js, line 2320

removeGrids() → {JXG.Board}

Removes all grids assigned to this board. Warning: This method also removes all objects depending on one or more of the grids.

Returns

Reference to the board object.

Type
JXG.Board

Details

Source
base/board.js, line 6277

removeHook(id) → {JXG.Board}

Please use JXG.Board.off instead.

Parameters

Name Type Description
id Number | function

The number you got when you added the hook or a reference to the event handler.

Returns

Reference to the board

Type
JXG.Board

Details

Deprecated
Yes
Source
base/board.js, line 6132

removeKeyboardEventHandlers()

Remove all registered touch event handlers.

Details

Source
base/board.js, line 2308

removeMouseEventHandlers()

De-register mouse event handlers.

Details

Source
base/board.js, line 2383

removeObject(object, saveMethod) → {JXG.Board}

Removes object from board and from the renderer object.

Performance hints: It is recommended to use the JSXGraph object's id. If many elements are removed, it is best to either

  • remove the whole array if the elements are contained in an array instead of looping through the array OR
  • call board.suspendUpdate() before looping through the elements to be removed and call board.unsuspendUpdate() after the loop. Further, it is advisable to loop in reverse order, i.e. remove the object in reverse order of their creation time.

Parameters

Name Type Description
object JXG.GeometryElement | Array

The object to remove or array of objects to be removed. The element(s) is/are given by name, id or a reference.

saveMethod Boolean

If true, the algorithm runs through all elements and tests if the element to be deleted is a child element. If yes, it will be removed from the list of child elements. If false (default), the element is removed from the lists of child elements of all its ancestors. This should be much faster.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5662

removePointerEventHandlers()

Remove MSPointer* Event handlers.

Details

Source
base/board.js, line 2342

removeResizeEventHandlers()

Remove resize related event handlers

Details

Source
base/board.js, line 2146

removeTouchEventHandlers()

Remove all registered touch event handlers.

Details

Source
base/board.js, line 2415

resizeContainer(canvasWidth, canvasHeight, dontsetopt, dontSetBoundingBoxopt) → {JXG.Board}

Change the height and width of the board's container. After doing so, JXG.JSXGraph.setBoundingBox is called using the actual size of the bounding box and the actual value of keepaspectratio. If setBoundingbox() should not be called automatically, call resizeContainer with dontSetBoundingBox == true.

Parameters

Name Type Attributes Default Description
canvasWidth Number

New width of the container.

canvasHeight Number

New height of the container.

dontset Boolean <optional>
false

If true do not set the CSS width and height of the DOM element.

dontSetBoundingBox Boolean <optional>
false

If true do not call setBoundingBox(), but keep view centered around original visible center.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5759

resizeListener()

Fallback solutions if there is no resizeObserver available in the browser. Reacts to resize events of the window (only). Otherwise similar to startResizeObserver(). To handle changes of the visibility of the JSXGraph container element, additionally an intersection observer is used. which watches changes in the visibility of the JSXGraph container element. This is necessary e.g. for register tabs or dia shows.

Details

See
Source
base/board.js, line 4543

(private) saveStartPos(obj, targets)

Helper function which returns a reasonable starting point for the object being dragged. Formerly known as initXYstart().

Parameters

Name Type Description
obj JXG.GeometryElement

The object to be dragged

targets Array

Array of targets. It is changed by this function.

Details

Source
base/board.js, line 1878

scrollListener(evt)

Listener to watch for scroll events. Sets board._isScrolling = true

Parameters

Name Type Description
evt Event

The browser's event object

Details

See
Source
base/board.js, line 4566

select(str, onlyByIdOrName) → {JXG.GeometryElement|JXG.Composition}

Select a single or multiple elements at once.

Example

// select the element with name A
board.select('A');

// select all elements with strokecolor set to 'red' (but not '#ff0000')
board.select({
  strokeColor: 'red'
});

// select all points on or below the x axis and make them black.
board.select({
  elementClass: JXG.OBJECT_CLASS_POINT,
  Y: function (v) {
    return v <= 0;
  }
}).setAttribute({color: 'black'});

// select all elements
board.select(function (el) {
  return true;
});

Parameters

Name Type Description
str String | Object | function

The name, id or a reference to a JSXGraph element on this board. An object will be used as a filter to return multiple elements at once filtered by the properties of the object.

onlyByIdOrName Boolean

If true (default:false) elements are only filtered by their id, name or groupId. The advanced filters consisting of objects or functions are ignored.

Returns

Type
JXG.GeometryElement | JXG.Composition

Details

Source
base/board.js, line 7158

setAttribute(attributes, forceopt) → {JXG.Board}

Sets an arbitrary number of attributes. This method has one or more parameters of the following types:

  • object: {key1:value1,key2:value2,...}
  • string: 'key:value'
  • array: ['key', value]

Some board attributes are immutable, like e.g. the renderer type.

Example

const board = JXG.JSXGraph.initBoard('jxgbox', {
    boundingbox: [-5, 5, 5, -5],
    keepAspectRatio: false,
    axis:true,
    showFullscreen: true,
    showScreenshot: true,
    showCopyright: false
});

board.setAttribute({
    animationDelay: 10,
    boundingbox: [-10, 5, 10, -5],
    defaultAxes: {
        x: { strokeColor: 'blue', ticks: { strokeColor: 'blue'}}
    },
    description: 'test',
    fullscreen: {
        scale: 0.5
    },
    intl: {
        enabled: true,
        locale: 'de-DE'
    }
});

board.setAttribute({
    selection: {
        enabled: true,
        fillColor: 'blue'
    },
    showInfobox: false,
    zoomX: 0.5,
    zoomY: 2,
    fullscreen: { symbol: 'x' },
    screenshot: { symbol: 'y' },
    showCopyright: true,
    showFullscreen: false,
    showScreenshot: false,
    showZoom: false,
    showNavigation: false
});
board.setAttribute('showCopyright:false');

var p = board.create('point', [1, 1], {size: 10,
    label: {
        fontSize: 24,
        highlightStrokeOpacity: 0.1,
        offset: [5, 0]
    }
});


Parameters

Name Type Attributes Default Description
attributes Object

An object with attributes

force Boolean <optional>
false

if true the attributes are set regardless of the previous setting was identical.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6676

setBoundingBox(bbox, keepaspectratioopt, setZoomopt) → {JXG.Board}

Set the bounding box of the board.

Parameters

Name Type Attributes Default Description
bbox Array

New bounding box [x1,y1,x2,y2]

keepaspectratio Boolean <optional>
false

If set to true, the aspect ratio will be 1:1, but the resulting viewport may be larger.

setZoom String <optional>
'reset'

Reset, keep or update the zoom level of the board. 'reset' sets JXG.Board#zoomX and JXG.Board#zoomY to the start values (or 1.0). 'update' adapts these values accoring to the new bounding box and 'keep' does nothing.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6414

setId(obj, type) → {String}

Composes an id for an element. If the ID is empty ('' or null) a new ID is generated, depending on the object type. As a side effect JXG.Board#numObjects is updated.

Parameters

Name Type Description
obj Object

Reference of an geometry object that needs an id.

type Number

Type of the object.

Returns

Unique id for an element.

Type
String

Details

Source
base/board.js, line 935

setZoom(fX, fY) → {JXG.Board}

Sets the zoom level to fX resp fY.

Parameters

Name Type Description
fX Number
fY Number

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 5511

showDependencies() → {JXG.Board}

Lists the dependencies graph in a new HTML-window.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5801

showXML() → {JXG.Board}

Lists the XML code of the construction in a new HTML-window.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5842

(private) startFullscreenResizeObserver(node) → {JXG.Board}

Start resize observer to handle orientation changes in fullscreen mode.

Parameters

Name Type Description
node Object

DOM object which is in fullscreen mode. It is the wrapper element around the JSXGraph div.

Returns

Reference to the board

Type
JXG.Board

Details

See
Source
base/board.js, line 8186

startIntersectionObserver()

Watch for changes of the visibility of the JSXGraph container element.

Details

See
Source
base/board.js, line 4587

startResizeObserver()

Start observer which reacts to size changes of the JSXGraph container div element. Calls updateContainerDims(). If not available, an event listener for the window-resize event is started. On mobile devices also scrolling might trigger resizes. However, resize events triggered by scrolling events should be ignored. Therefore, also a scrollListener is started. Resize can be controlled with the board attribute resize.

Details

See
Source
base/board.js, line 4490

startSelectionMode()

Start selection mode. This function can either be triggered from outside or by a down event together with correct key pressing. The default keys are shift+ctrl. But this can be changed in the options.

Starting from out side can be realized for example with a button like this:

	<button onclick='board.startSelectionMode()'>Start</button>

Example

//
// Set a new bounding box from the selection rectangle
//
var board = JXG.JSXGraph.initBoard('jxgbox', {
        boundingBox:[-3,2,3,-2],
        keepAspectRatio: false,
        axis:true,
        selection: {
            enabled: true,
            needShift: false,
            needCtrl: true,
            withLines: false,
            vertices: {
                visible: false
            },
            fillColor: '#ffff00',
        }
     });

var f = function f(x) { return Math.cos(x); },
    curve = board.create('functiongraph', [f]);

board.on('stopselecting', function(){
    var box = board.stopSelectionMode(),

        // bbox has the coordinates of the selection rectangle.
        // Attention: box[i].usrCoords have the form [1, x, y], i.e.
        // are homogeneous coordinates.
        bbox = box[0].usrCoords.slice(1).concat(box[1].usrCoords.slice(1));

        // Set a new bounding box
        board.setBoundingBox(bbox, false);
 });


Details

Source
base/board.js, line 7365

stopAllAnimation() → {JXG.Board}

Cancels all running animations.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6869

(private) stopFullscreenResizeObserver(node) → {JXG.Board}

Remove resize observer to handle orientation changes in fullscreen mode.

Parameters

Name Type Description
node Object

DOM object which is in fullscreen mode. It is the wrapper element around the JSXGraph div.

Returns

Reference to the board

Type
JXG.Board

Details

See
Source
base/board.js, line 8234

stopIntersectionObserver()

Stop the intersection observer

Details

See
Source
base/board.js, line 4614

stopResizeObserver()

Stops the resize observer.

Details

See
Source
base/board.js, line 4522

stopSelectionMode() → {Array}

Finalize the selection: disable selection mode and return the coordinates of the selection rectangle.

Returns

Coordinates of the selection rectangle. The array contains two JXG.Coords objects. One the upper left corner and the second for the lower right corner.

Type
Array

Details

Source
base/board.js, line 7383

suppressDefault(e) → {Boolean}

Suppresses the default event handling. Used for context menu.

Parameters

Name Type Description
e Event

Returns

false

Type
Boolean

Details

Source
base/board.js, line 2021

suspendUpdate() → {JXG.Board}

Stop updates of the board.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6385

toFullscreen(id) → {JXG.Board}

Expand the JSXGraph construction to fullscreen. In order to preserve the proportions of the JSXGraph element, a wrapper div is created which is set to fullscreen. This function is called when fullscreen mode is triggered and when it is closed.

The wrapping div has the CSS class 'jxgbox_wrap_private' which is defined in the file 'jsxgraph.css'

This feature is not available on iPhones (as of December 2021).

Examples

<div id='jxgbox' class='jxgbox' style='width:500px; height:200px;'></div>
<button onClick='board.toFullscreen()'>Fullscreen</button>

<script language='Javascript' type='text/javascript'>
var board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
var p = board.create('point', [0, 1]);
</script>



    
    

    
<div id='outer' style='max-width: 500px; margin: 0 auto;'>
<div id='jxgbox' class='jxgbox' style='height: 0; padding-bottom: 100%'></div>
</div>
<button onClick='board.toFullscreen('outer')'>Fullscreen</button>

<script language='Javascript' type='text/javascript'>
var board = JXG.JSXGraph.initBoard('jxgbox', {
    axis:true,
    boundingbox:[-5,5,5,-5],
    fullscreen: { id: 'outer' },
    showFullscreen: true
});
var p = board.create('point', [-2, 3], {});
</script>

Parameters

Name Type Description
id String

(Optional) id of the div element which is brought to fullscreen. If not provided, this defaults to the JSXGraph div. However, it may be necessary for the aspect ratio trick which using padding-bottom/top and an out div element. Then, the id of the outer div has to be supplied.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 8030

touchEndListener(evt) → {Boolean}

Triggered as soon as the user stops touching the device with at least one finger.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 3777

touchMoveListener(evt) → {Boolean}

Called periodically by the browser while the user moves his fingers across the device.

Parameters

Name Type Description
evt Event

Returns

Type
Boolean

Details

Source
base/board.js, line 3637

(private) touchOriginMove(evt) → {Boolean}

Move the origin with one finger

Parameters

Name Type Description
evt Object

Event from touchMoveListener

Returns

returns if the origin is moved.

Type
Boolean

Details

Source
base/board.js, line 1986

touchStartListener(evt) → {Boolean}

This method is called by the browser when a finger touches the surface of the touch-device.

Parameters

Name Type Description
evt Event

The browsers event object.

Returns

...

Type
Boolean

Details

Source
base/board.js, line 3407

(private) touchStartMoveOriginOneFinger(evt) → {Boolean}

Start moving the origin with one finger.

Parameters

Name Type Description
evt Object

Event from touchStartListener

Returns

returns if the origin is moved.

Type
Boolean

Details

Source
base/board.js, line 1964

twoFingerMove(p1, p2, o, evt)

Moves elements in multitouch mode.

Parameters

Name Type Description
p1 Array

x,y coordinates of first touch

p2 Array

x,y coordinates of second touch

o Object

The touch object that is dragged: {JXG.Board#touches}.

evt Object

The event object that lead to this movement.

Details

Source
base/board.js, line 1612

twoFingerTouchObject(tar, drag, id)

Moves, rotates and scales a line or polygon with two fingers.

If one vertex of the polygon snaps to the grid or to points or is not draggable, two-finger-movement is cancelled.

Parameters

Name Type Description
tar Array

Array containing touch event objects: {JXG.Board#touches.targets}.

drag object

The object that is dragged:

id Number

pointerId of the event. In case of old touch event this is emulated.

Details

Source
base/board.js, line 1702

unsuspendUpdate() → {JXG.Board}

Enable updates of the board.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6396

update(dragopt) → {JXG.Board}

Runs through most elements and calls their update() method and update the conditions.

Parameters

Name Type Attributes Description
drag JXG.GeometryElement <optional>

Element that caused the update.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6197

updateCSSTransforms()

Update CSS transformations of type scaling. It is used to correct the mouse position in JXG.Board.getMousePosition. The inverse transformation matrix is updated on each mouseDown and touchStart event.

It is up to the user to call this method after an update of the CSS transformation in the DOM.

Details

Source
base/board.js, line 7242

(private) updateConditions()

Computes the commands in the conditions-section of the gxt file. It is evaluated after an update, before the unsuspendRedraw. The function is generated in

Details

See
Source
base/board.js, line 5217

updateContainerDims(widthopt, heightopt) → {JXG.Board}

Update the width and height of the JSXGraph container div element. If width and height are not supplied, read actual values with offsetWidth/Height, and call board.resizeContainer() with this values.

If necessary, also call setBoundingBox().

Parameters

Name Type Attributes Default Description
width Number <optional>
this.containerObj.offsetWidth

Width of the container element

height Number <optional>
this.containerObj.offsetHeight

Height of the container element

Returns

Reference to the board

Type
JXG.Board

Details

See
Source
base/board.js, line 4417

updateCoords() → {JXG.Board}

Update the coords object of all elements which possess this property. This is necessary after changing the viewport.

Returns

Reference to this board.

Type
JXG.Board

Details

Source
base/board.js, line 4985

updateElements(drag) → {JXG.Board}

Runs through all elements and calls their update() method.

Parameters

Name Type Description
drag JXG.GeometryElement

Element that caused the update.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5911

updateHooks() → {JXG.Board}

Runs through all hooked functions and calls them.

Returns

Reference to the board

Type
JXG.Board

Details

Deprecated
Yes
Source
base/board.js, line 6152

updateInfobox(el) → {JXG.Board}

Updates and displays a little info box to show coordinates of current selected points.

Parameters

Name Type Description
el JXG.GeometryElement

A GeometryElement

Returns

Reference to the board

Type
JXG.Board

Details

See
Source
base/board.js, line 4729

updateRenderer() → {JXG.Board}

Runs through all elements and calls their update() method.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5954

updateRendererCanvas() → {JXG.Board}

Runs through all elements and calls their update() method. This is a special version for the CanvasRenderer. Here, we have to do our own layer handling.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 6015

zoom100() → {JXG.Board}

Reset the zoom level to the original zoom level from initBoard(); Additionally, if the board as been initialized with a boundingBox (which is the default), restore the viewport to the original viewport during initialization. Otherwise, (i.e. if the board as been initialized with unitX/Y and originX/Y), just set the zoom level to 100%.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5386

zoomAllPoints() → {JXG.Board}

Zooms the board so every visible point is shown. Keeps aspect ratio.

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5409

zoomElements(elements) → {JXG.Board}

Reset the bounding box and the zoom level to 100% such that a given set of elements is within the board's viewport.

Parameters

Name Type Description
elements Array

A set of elements given by id, reference, or name.

Returns

Reference to the board.

Type
JXG.Board

Details

Source
base/board.js, line 5457

zoomIn(xopt, yopt) → {JXG.Board}

Zooms into the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom. The zoom operation is centered at x, y.

Parameters

Name Type Attributes Description
x Number <optional>
y Number <optional>

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5298

zoomOut(xopt, yopt) → {JXG.Board}

Zooms out of the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom. The zoom operation is centered at x, y.

Parameters

Name Type Attributes Description
x Number <optional>
y Number <optional>

Returns

Reference to the board

Type
JXG.Board

Details

Source
base/board.js, line 5344

Inherited

none

Events

Own

attribute

Whenever JXG.Board#setAttribute is called.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7596

boundingbox

The bounding box of the board has changed.

Details

Source
base/board.js, line 7845

click

Whenever the user clicks on the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

See
Source
base/board.js, line 7678

click

Whenever the user clicks on an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2768

dblclick

Whenever the user double clicks on the board. This event works on desktop browser, but is undefined on mobile browsers.

Parameters

Name Type Description
e Event

The browser's event object.

Details

See
Source
base/board.js, line 7687

dblclick

Whenever the user double clicks on an element. This event works on desktop browser, but is undefined on mobile browsers.

Parameters

Name Type Description
e Event

The browser's event object.

Details

See
Source
base/element.js, line 2776

down

Whenever the user starts to touch or click the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7604

hit

Whenever an element is highlighted this event is fired.

Example

var c = board.create('circle', [[1, 1], 2]);
board.on('hit', function(evt, el) {
    console.log('JSXGraph example: Hit element', el);
});

Parameters

Name Type Description
e Event

The browser's event object.

el JXG.GeometryElement

The hit element.

target

Details

Source
base/board.js, line 7797

keymove

This event is fired whenever the user is moving an element over the board by pressing arrow keys on a keyboard.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7786

mouseclick

Whenever the user clicks on the board with a mouse device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7699

mouseclick

Whenever the user clicks on an element with a mouse device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2788

mousedblclick

Whenever the user double clicks on the board with a mouse device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

See
Source
base/board.js, line 7707

mousedblclick

Whenever the user double clicks on an element with a mouse device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2796

mousedown

Whenever the user starts to click on the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7612

mousehit

Whenever an element is highlighted this event is fired.

Parameters

Name Type Description
e Event

The browser's event object.

el JXG.GeometryElement

The hit element.

target

Details

See
  • JXG.Board#hit
Source
base/board.js, line 7827

mousemove

This event is fired whenever the user is moving the mouse over the board.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7745

mousemoveselecting

A move event while selecting of a region is active from a device sending mouse events.

Details

Source
base/board.js, line 7925

mousestartselecting

Select a region is started during a down event from a device sending mouse events or by calling JXG.Board.startSelectionMode.

Details

Source
base/board.js, line 7860

mousestopselecting

Selection of a region is stopped during an up event from a device sending mouse events.

Details

Source
base/board.js, line 7894

mouseup

Whenever the user releases the mousebutton over the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7653

move

This event is fired whenever the user is moving the finger or mouse pointer over the board.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7735

moveselecting

A move event while selecting of a region is active.

Details

Source
base/board.js, line 7918

pendown

Whenever the user taps the pen on the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7620

penmove

This event is fired whenever the user is moving the pen over the board.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7755

pointerclick

Whenever the user clicks on the board with a pointer device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7716

pointerclick

Whenever the user clicks on an element with a pointer device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2804

pointerdblclick

Whenever the user double clicks on the board with a pointer device. This event works on desktop browser, but is undefined on mobile browsers.

Parameters

Name Type Description
e Event

The browser's event object.

Details

See
Source
base/board.js, line 7724

pointerdblclick

Whenever the user double clicks on an element with a pointer device. This event works on desktop browser, but is undefined on mobile browsers.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2812

pointerdown

Whenever the user starts to click on the board with a device sending pointer events.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7628

pointermove

This event is fired whenever the user is moving the mouse over the board with a device sending pointer events.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7765

pointermoveselecting

Select a region is started during a down event from a device sending mouse events.

Details

Source
base/board.js, line 7933

pointerstartselecting

Select a region is started during a down event from a device sending pointer events or by calling JXG.Board.startSelectionMode.

Details

Source
base/board.js, line 7869

pointerstopselecting

Selection of a region is stopped during an up event from a device sending pointer events.

Details

Source
base/board.js, line 7902

pointerup

Whenever the user releases the mousebutton over the board with a device sending pointer events.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7661

startselecting

Select a region is started during a down event or by calling JXG.Board.startSelectionMode

Details

Source
base/board.js, line 7852

stopselecting

Selection of a region is stopped during an up event.

Details

Source
base/board.js, line 7887

touchend

Whenever the user stops touching the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7670

touchmove

This event is fired whenever the user is moving the finger over the board.

Parameters

Name Type Description
e Event

The browser's event object.

mode Number

The mode the board currently is in

Details

See
Source
base/board.js, line 7776

touchmoveselecting

Select a region is started during a down event from a device sending touch events.

Details

Source
base/board.js, line 7941

touchstart

Whenever the user starts to touch the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7637

touchstartselecting

Select a region is started during a down event from a device sending touch events or by calling JXG.Board.startSelectionMode.

Details

Source
base/board.js, line 7878

touchstopselecting

Selection of a region is stopped during an up event from a device sending touch events.

Details

Source
base/board.js, line 7910

up

Whenever the user stops to touch or click the board.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/board.js, line 7645

update

This board is updated.

Details

Source
base/board.js, line 7838

Inherited

none

Parameters

Name Type Description
container String | Object

The id of or reference to the HTML DOM element the board is drawn in. This is usually a HTML div. If it is the reference to an HTML element and this element does not have an attribute "id", this attribute "id" is set to a random value.

renderer JXG.AbstractRenderer

The reference of a renderer.

id String

Unique identifier for the board, may be an empty string or null or even undefined.

origin JXG.Coords

The coordinates where the origin is placed, in user coordinates.

zoomX Number

Zoom factor in x-axis direction

zoomY Number

Zoom factor in y-axis direction

unitX Number

Units in x-axis direction

unitY Number

Units in y-axis direction

canvasWidth Number

The width of canvas

canvasHeight Number

The height of canvas

attributes Object

The attributes object given to JXG.JSXGraph.initBoard

Details

Source
base/board.js, line 81

Classes

infobox