JXG.GeometryElement

Class

This is the parent class for all geometry elements like points, circles, lines, curves...

Attributes

Own

aria

Description

ARIA settings for JSXGraph elements. Besides 'label' and 'live', all available properties from https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA may be set. In JSXGraph, the available attributes are used without the leading 'aria-'. For example, the value of the JSXGraph attribute aria.label will be set to the HTML attribute 'aria-label' (ignoring 'aria.enabled').

Type
Object
Default Value
{
  enabled: false,
  label: '',
  live: 'assertive'
 }
Source
options.js, line 1629

clip

Description

If set to false, the JSXGraph element can be dragged out of the JSXGraph board. Used in JXG#appBox.

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

cssClass

Description

Apply CSS classes to an element in non-highlighted view. It is possible to supply one or more CSS classes separated by blanks.

For non-text and non-image elements, this feature is available for the SVG renderer, only.

For text and image elements the specificity (priority) of JSXGraph attributes is higher than the CSS class properties, see Text#cssDefaultStyle For other elements, however, the specificity of a CSS class is higher than the corresponding JSXGraph attribute, see the example below. The fill-properties of a CSS class will be set only if the corresponding JSXGraph attributes are set (to a dummy value).

Type
String
Default Value
''
See
Example
// CSS class
.line {
    stroke: blue;
    stroke-width: 10px;
    fill: yellow;
}

// JavaScript
var line = board.create('line', [[0, 0], [3, 3]], {
  cssClass: 'line',
  strokeColor: 'black',
  strokeWidth: 2,
  fillColor: '' // Necessary to enable the yellow fill color of the CSS class
});

// The line is blue and has stroke-width 10px;
Source
options.js, line 1666

dash

Description

Determines the elements border-style. Possible values are:

  • 0 for a solid line
  • 1 for a dotted line
  • 2 for a line with small dashes
  • 3 for a line with medium dashes
  • 4 for a line with big dashes
  • 5 for a line with alternating medium and big dashes and large gaps
  • 6 for a line with alternating medium and big dashes and small gaps
  • 7 for a dotted line. Needs JXG.GeometryElement#linecap set to "round" for round dots.

The dash patterns are defined in JXG.AbstractRenderer#dashArray.

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

dashScale

Description

If true, the dash pattern is multiplied by strokeWidth / 2.

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

draft

Description

If draft.draft: true the element will be drawn in grey scale colors (as default) to visualize that it's only a draft.

Type
Object
Default Value
{
  draft: false,
  strokeColor: '#565656',
  fillColor: '#565656',
  strokeOpacity: 0.8,
  fillOpacity: 0.8,
  strokeWidth: 1
}
Source
options.js, line 1759

dragToTopOfLayer

Description

If the element is dragged it will be moved on mousedown or touchstart to the top of its layer. Works only for SVG renderer and for simple elements consisting of one SVG node.

Type
Boolean
Default Value
false
Example
var li1 = board.create('line', [1, 1, 1], {strokeWidth: 20, dragToTopOfLayer: true});
var li2 = board.create('line', [1, -1, 1], {strokeWidth: 20, strokeColor: 'red'});

Source
options.js, line 1784

element3D

Description

Links to the defining 3D element of a 2D element. Otherwise it is null.

Default Value
null
Source
options.js, line 1811

fillColor

Description

The fill color of this geometry element.

Type
String
Default Value
JXG.palette.red
See
Source
options.js, line 1821

fillOpacity

Description

Opacity for fill color.

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

fixed

Description

If true the element is fixed and can not be dragged around. The element will be repositioned on zoom and moveOrigin events.

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

frozen

Description

If true the element is fixed and can not be dragged around. The element will even stay at its position on zoom and moveOrigin events. Only free elements like points, texts, images, curves can be frozen.

Type
Boolean
Default Value
false
Example
var txt = board.create('text', [1, 2, 'Hello'], {frozen: true, fontSize: 24});
var sli = board.create('slider', [[-4, 4], [-1.5, 4], [-10, 1, 10]], {
    name:'a',
    frozen: true
});

Source
options.js, line 1855

gradient

Description

Gradient type. Possible values are 'linear'. 'radial' or null.

Type
String
Default Value
null
See
Examples
var a = board.create('slider', [[0, -0.2], [3.5, -0.2], [0, 0, 2 * Math.PI]], {name: 'angle'});
    var b = board.create('slider', [[0, -0.4], [3.5, -0.4], [0, 0, 1]], {name: 'offset1'});
    var c = board.create('slider', [[0, -0.6], [3.5, -0.6], [0, 1, 1]], {name: 'offset2'});

    var pol = board.create('polygon', [[0, 0], [4, 0], [4,4], [0,4]], {
                fillOpacity: 1,
                fillColor: 'yellow',
                gradient: 'linear',
                gradientSecondColor: 'blue',
                gradientAngle: function() { return a.Value(); },
                gradientStartOffset: function() { return b.Value(); },
                gradientEndOffset: function() { return c.Value(); },
                hasInnerPoints: true
        });

var cx = board.create('slider', [[0, -.2], [3.5, -.2], [0, 0.5, 1]], {name: 'cx, cy'});
    var fx = board.create('slider', [[0, -.4], [3.5, -.4], [0, 0.5, 1]], {name: 'fx, fy'});
    var o1 = board.create('slider', [[0, -.6], [3.5, -.6], [0, 0.0, 1]], {name: 'offset1'});
    var o2 = board.create('slider', [[0, -.8], [3.5, -.8], [0, 1, 1]], {name: 'offset2'});
    var r = board.create('slider', [[0, -1], [3.5, -1], [0, 0.5, 1]], {name: 'r'});
    var fr = board.create('slider', [[0, -1.2], [3.5, -1.2], [0, 0, 1]], {name: 'fr'});

    var pol = board.create('polygon', [[0, 0], [4, 0], [4,4], [0,4]], {
                fillOpacity: 1,
                fillColor: 'yellow',
                gradient: 'radial',
                gradientSecondColor: 'blue',
                gradientCX: function() { return cx.Value(); },
                gradientCY: function() { return cx.Value(); },
                gradientR: function() { return r.Value(); },
                gradientFX: function() { return fx.Value(); },
                gradientFY: function() { return fx.Value(); },
                gradientFR: function() { return fr.Value(); },
                gradientStartOffset: function() { return o1.Value(); },
                gradientEndOffset: function() { return o2.Value(); },
                hasInnerPoints: true
    });

Source
options.js, line 1890

gradientAngle

Description

Angle (in radians) of the gradiant in case the gradient is of type 'linear'. If the angle is 0, the first color is on the left and the second color is on the right. If the angle is π/2 the first color is on top and the second color at the bottom.

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

gradientCX

Description

From the SVG specification: ‘cx’, ‘cy’ and ‘r’ define the largest (i.e., outermost) circle for the radial gradient. The gradient will be drawn such that the 100% gradient stop is mapped to the perimeter of this largest (i.e., outermost) circle. For radial gradients in canvas this is the value 'x1'. Takes a value between 0 and 1.

Type
Number
Default Value
0.5
See
Source
options.js, line 2012

gradientCY

Description

From the SVG specification: ‘cx’, ‘cy’ and ‘r’ define the largest (i.e., outermost) circle for the radial gradient. The gradient will be drawn such that the 100% gradient stop is mapped to the perimeter of this largest (i.e., outermost) circle. For radial gradients in canvas this is the value 'y1'. Takes a value between 0 and 1.

Type
Number
Default Value
0.5
See
Source
options.js, line 2027

gradientEndOffset

Description

The gradientEndOffset attribute is a number (ranging from 0 to 1) which indicates where the second gradient stop is placed, see the SVG specification for more information. For linear gradients, this attribute represents a location along the gradient vector. For radial gradients, it represents a percentage distance from (fx,fy) to the edge of the outermost/largest circle.

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

gradientFR

Description

This attribute defines the radius of the start circle of the radial gradient. The gradient will be drawn such that the 0% <stop> is mapped to the perimeter of the start circle. For radial gradients in canvas this is the value 'r0'. Takes a value between 0 and 1.

Type
Number
Default Value
0.0
See
Source
options.js, line 2085

gradientFX

Description

‘fx’ and ‘fy’ define the focal point for the radial gradient. The gradient will be drawn such that the 0% gradient stop is mapped to (fx, fy). For radial gradients in canvas this is the value 'x0'. Takes a value between 0 and 1.

Type
Number
Default Value
0.5
See
Source
options.js, line 2056

gradientFY

Description

y-coordinate of the circle center for the second color in case of gradient 'radial'. (The attribute fy in SVG) For radial gradients in canvas this is the value 'y0'. Takes a value between 0 and 1.

Type
Number
Default Value
0.5
See
Source
options.js, line 2071

gradientR

Description

From the SVG specification: ‘cx’, ‘cy’ and ‘r’ define the largest (i.e., outermost) circle for the radial gradient. The gradient will be drawn such that the 100% gradient stop is mapped to the perimeter of this largest (i.e., outermost) circle. For radial gradients in canvas this is the value 'r1'. Takes a value between 0 and 1.

Type
Number
Default Value
0.5
See
Source
options.js, line 2100

gradientSecondColor

Description

Second color for gradient.

Type
String
Default Value
'#ffffff'
See
Source
options.js, line 2115

gradientSecondOpacity

Description

Opacity of second gradient color. Takes a value between 0 and 1.

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

gradientStartOffset

Description

The gradientStartOffset attribute is a number (ranging from 0 to 1) which indicates where the first gradient stop is placed, see the SVG specification for more information. For linear gradients, this attribute represents a location along the gradient vector. For radial gradients, it represents a percentage distance from (fx,fy) to the edge of the outermost/largest circle.

Type
Number
Default Value
0.0
See
Source
options.js, line 2137

highlight

Type
Boolean
Default Value
true
Source
options.js, line 2151

highlightCssClass

Description

Apply CSS classes to an element in highlighted view. It is possible to supply one or more CSS classes separated by blanks.

For non-text and non-image elements, this feature is available for the SVG renderer, only.

Type
String
Default Value
''
See
Source
options.js, line 1706

highlightFillColor

Description

The fill color of the given geometry element when the mouse is pointed over it.

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

highlightFillOpacity

Description

Opacity for fill color when the object is highlighted.

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

highlightStrokeColor

Description

The stroke color of the given geometry element when the user moves the mouse over it.

Type
String
Default Value
'#c3d9ff'
See
Source
options.js, line 2183

highlightStrokeOpacity

Description

Opacity for stroke color when the object is highlighted.

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

highlightStrokeWidth

Description

Width of the element's stroke when the mouse is pointed over it.

Type
Number
Default Value
2
See
Source
options.js, line 2209

ignoreForLabelAutoposition

Description

Decides if the element should be ignored when using auto positioning for some label.

Type
boolean
Default Value
false
See
Source
options.js, line 2718

isLabel

Default Value
false
Source
options.js, line 2223

layer

Description

Display layer which will contain the element.

Default Value
See JXG.Options#layer
See
Source
options.js, line 2232

lineCap

Description

Line endings (linecap) of a stroke element, i.e. line, circle, curve. Possible values are:

  • 'butt',
  • 'round',
  • 'square'.

Not available for VML renderer.

Type
String
Default Value
'butt'
Source
options.js, line 2241

needsRegularUpdate

Description

If this is set to true, the element is updated in every update call of the board. If set to false, the element is updated only after zoom events or more generally, when the bounding box has been changed. Examples for the latter behavior should be axes.

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

nonnegativeOnly

Description

If some size of an element is controlled by a function, like the circle radius or segments of fixed length, this attribute controls what happens if the value is negative. By default, the absolute value is taken. If true, the maximum of 0 and the value is used.

Type
Boolean
Default Value
false
Example
var slider = board.create('slider', [[4, -3], [4, 3], [-4, 1, 4]], { name: 'a'});
var circle = board.create('circle', [[-1, 0], 1], {
    nonnegativeOnly: true
});
circle.setRadius('a');         // Use JessieCode
var seg = board.create('segment', [[-4, 3], [0, 3], () => slider.Value()], {
    point1: {visible: true},
    point2: {visible: true},
    nonnegativeOnly: true
});

Source
options.js, line 2271

precision

Description

Precision options for JSXGraph elements. This attributes takes either the value 'inherit' or an object of the form:

precision: {
     touch: 30,
     mouse: 4,
     pen: 4
}

In the first case, the global, JSXGraph-wide values of JXGraph.Options.precision are taken.

Type
String | Object
Default Value
'inherit'
See
Source
options.js, line 2316

priv

Description

A private element will be inaccessible in certain environments, e.g. a graphical user interface.

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

rotatable

Description

Determines whether two-finger manipulation may rotate this object. If set to false, the object can only be scaled and translated.

In case the element is a polygon or line and it has the attribute "rotatable:false", moving the element with two fingers results in a rotation or translation.

If an element is set to be neither scalable nor rotatable, it can only be translated.

In case of a polygon, scaling is only possible if no vertex has snapToGrid or snapToPoints enabled and no vertex is fixed by some other constraint. Also, the polygon itself has to have snapToGrid disabled.

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

scalable

Description

Determines whether two-finger manipulation of this object may change its size. If set to false, the object is only rotated and translated.

In case the element is a horizontal or vertical line having ticks, scalable:true enables zooming of the board by dragging ticks lines. This feature is enabled, for the ticks element of the line element the attribute fixed has to be false and the line element's scalable attribute has to be true.

In case the element is a polygon or line and it has the attribute scalable:false, moving the element with two fingers results in a rotation or translation.

If an element is set to be neither scalable nor rotatable, it can only be translated.

In case of a polygon, scaling is only possible if no vertex has snapToGrid or snapToPoints enabled and no vertex is fixed by some other constraint. Also, the polygon itself has to have snapToGrid disabled.

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

shadow

Description

If enabled:true the (stroke) element will get a customized shadow.

Customize color and opacity: If the object's RGB stroke color is [r,g,b] and its opacity is op, and the shadow parameters color is given as [r', g', b'] and opacity as op' the shadow will receive the RGB color

[blend*r + r', blend*g + g', blend*b + b']

and its opacity will be equal to op * op'. Further, the parameters blur and offset can be adjusted.

This attribute is only available with SVG, not with canvas.

Type
Object
Default Value
shadow: {
  enabled: false,
  color: [0, 0, 0],
  opacity: 1,
  blur: 3,
  blend: 0.1,
  offset: [5, 5]
}
Example
board.options.line.strokeWidth = 2
// No shadow
var li1 = board.create('line', [[-2, 5], [2, 6]], {strokeColor: 'red', shadow: false});

// Default shadow
var li2 = board.create('line', [[-2, 3], [2, 4]], {strokeColor: 'red', shadow: true});

// No shadow
var li3 = board.create('line', [[-2, 1], [2, 2]], {strokeColor: 'blue', shadow: {enabled: false}});

// Shadow uses same color as line
var li4 = board.create('line', [[-2, -1], [2, 0]], {strokeColor: 'blue',
            shadow: {enabled: true, color: '#000000', blend: 1}
        });

// Shadow color as a mixture between black and the line color, additionally set opacity
var li5 = board.create('line', [[-2, -3], [2, -2]], {strokeColor: 'blue',
            shadow: {enabled: true, color: '#000000', blend: 0.5, opacity: 0.5}
        });

// Use different value for blur and offset [dx, dy]
var li6 = board.create('line', [[-2, -5], [2, -4]], {strokeColor: 'blue',
            shadow: {enabled: true, offset:[0, 25], blur: 6}
        });

Source
options.js, line 2396

snapToGrid

Description

Snaps the element or its parents to the grid. Currently only relevant for points, circles, and lines. Points are snapped to grid directly, on circles and lines it's only the parent points that are snapped

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

strokeColor

Description

The stroke color of the given geometry element.

Type
String
Default Value
JXG.palette.blue
See
Source
options.js, line 2504

strokeOpacity

Description

Opacity for element's stroke color.

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

strokeWidth

Description

Width of the element's stroke.

Type
Number
Default Value
2
See
Source
options.js, line 2530

tabindex

Description

Controls if an element can get the focus with the tab key. tabindex corresponds to the HTML attribute of the same name. See description at MDN. The additional value "null" completely disables focus of an element. The value will be ignored if keyboard control of the board is not enabled or if the element is not visible.

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

trace

Description

If true the element will be traced, i.e. on every movement the element will be copied to the background. Use JXG.GeometryElement#clearTrace to delete the trace elements.

The calling of element.setAttribute({trace:false}) additionally deletes all traces of this element. By calling element.setAttribute({trace:'pause'}) the removal of already existing traces can be prevented.

The visual appearance of the trace can be influenced by JXG.GeometryElement#traceAttributes.

Type
Boolean | String
Default Value
false
See
Source
options.js, line 2561

traceAttributes

Description

Extra visual attributes for traces of an element

Type
Object
Default Value
{}
See
Example
JXG.Options.elements.traceAttributes = {
    size: 2
};

const board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-4, 4, 4, -4],
    keepaspectratio: true
});

var p = board.create('point', [0.0, 2.0], {
    trace: true,
    size: 10,
    traceAttributes: {
        color: 'black',
        face: 'x'
    }
});

Source
options.js, line 2583

transitionDuration

Description

Transition duration (in milliseconds) for certain changes of properties like color and opacity. The properties can be set in the attribute transitionProperties Works in SVG renderer, only.

Type
Number
Default Value
100 JXG.Options.elements#transitionDuration
See
Source
options.js, line 2635

transitionProperties

Description

Attributes which change smoothly in the time set in transitionDuration. Possible values are ['fill', 'fill-opacity', 'stroke', 'stroke-opacity', 'stroke-width', 'width', 'height', 'rx', 'ry'] (and maybe more) for geometry elements and ['color', 'opacity', 'all'] for HTML texts.

Type
Array
See
Example
var p1 = board.create("point", [0, 2], {
    name: "A",
    highlightStrokeWidth: 10,
    transitionDuration: 1000,
    transitionProperties: ['width', 'height', 'stroke-width',
        'fill', 'fill-opacity', 'rx', 'ry', 'stroke', 'stroke-opacity'] });

Source
options.js, line 2655

visible

Description

If false the element won't be visible on the board, otherwise it is shown.

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

withLabel

Description

If true a label will display the element's name. Using this to suppress labels is more efficient than visible:false.

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

Inherited

none

Members

Own

(constant) _org_type : Number

Description

Original type of the element at construction time. Used for removing glider property.

Type
Number
Source
base/element.js, line 326

(private) _pos : Number

Description

The position of this element inside the JXG.Board#objectsList.

Type
Number
Default Value
-1
Source
base/element.js, line 228

ancestors : Object

Description

Elements on which this element depends on are stored here.

Type
Object
Source
base/element.js, line 150

(private) baseElement : JXG.GeometryElement

Type
JXG.GeometryElement
Default Value
null
Source
base/element.js, line 138

board : JXG.Board

Description

Reference to the board associated with the element.

Type
JXG.Board
Source
base/element.js, line 312

childElements : Object

Description

Stores all dependent objects to be updated when this point is moved.

Type
Object
Source
base/element.js, line 87

descendants : Object

Description

Elements depending on this element are stored here.

Type
Object
Source
base/element.js, line 144

dump : Boolean

Description

The element is saved with an explicit entry in the file (true) or implicitly via a composition.

Type
Boolean
Default Value
true
Source
base/element.js, line 207

elType : String

Description

The string used with JXG.Board#create

Type
String
Source
base/element.js, line 199

(constant) elementClass : Number

Description

The element's class.

Type
Number
Source
base/element.js, line 333

hasLabel : Boolean

Description

If element has a label subelement then this property will be set to true.

Type
Boolean
Default Value
false
Source
base/element.js, line 94

highlighted : Boolean

Description

True, if the element is currently highlighted.

Type
Boolean
Default Value
false
Source
base/element.js, line 101

id : String

Description

Unique identifier for the element. Equivalent to id-attribute of renderer element.

Type
String
Source
base/element.js, line 339

inherits : Object

Description

Inherits contains the subelements, which may have an attribute (in particular the attribute 'visible') having value 'inherit'.

Type
Object
Source
base/element.js, line 220

isDraggable : Boolean

Description

Controls if this element can be dragged. In GEONExT only free points and gliders can be dragged.

Type
Boolean
Default Value
false
Source
base/element.js, line 74

isReal : Boolean

Description

If element is in two dimensional real space this is true, else false.

Type
Boolean
Default Value
true
Source
base/element.js, line 81

lastDragTime : Date

Description

Time stamp containing the last time this element has been dragged.

Type
Date
Default Value
creation time
Source
base/element.js, line 303

methodMap : Object

Description

The methodMap determines which methods can be called from within JessieCode and under which name it can be used. The map is saved in an object, the name of a property is the name of the method used in JessieCode, the value of a property is the name of the method in JavaScript.

Type
Object
Source
base/element.js, line 2639

mouseover : Boolean

Description

Is the mouse over this element?

Type
Boolean
Default Value
false
Source
base/element.js, line 296

name : String

Description

Not necessarily unique name for the element.

Type
String
Default Value
Name generated by JXG.Board#generateName.
See
Source
base/element.js, line 357

needsUpdate : Boolean

Description

Controls if updates are necessary

Type
Boolean
Default Value
true
Source
base/element.js, line 66

notExistingParents : Object

Description

Stores all Intersection Objects which in this moment are not real and so hide this element.

Type
Object
Source
base/element.js, line 108

numTraces : Number

Description

Counts the number of objects drawn as part of the trace of the element.

Type
Number
See
Source
base/element.js, line 124

parents : Object

Description

Ids of elements on which this element depends directly are stored here.

Type
Object
Source
base/element.js, line 156

quadraticform : Array

Description

Quadratic form representation of circles (and conics)

Type
Array
Default Value
[[1,0,0],[0,1,0],[0,0,1]]
Source
base/element.js, line 261

rendNode : Object

Description

Stores the SVG (or VML) rendering node for the element. This enables low-level access to SVG nodes. The properties of such an SVG node can then be changed by calling setAttribute(). Note that there are a few elements which consist of more than one SVG nodes:

  • Elements with arrow tail or head: rendNodeTriangleStart, rendNodeTriangleEnd
  • SVG (or VML) texts: rendNodeText
  • Button: rendNodeForm, rendNodeButton, rendNodeTag
  • Checkbox: rendNodeForm, rendNodeCheckbox, rendNodeLabel, rendNodeTag
  • Input: rendNodeForm, rendNodeInput, rendNodeLabel, rendNodeTag

Here is are two examples: The first example shows how to access the SVG node, the second example demonstrates how to change SVG attributes.

Type
Object
Examples
var p1 = board.create('point', [0, 0]);
    console.log(p1.rendNode);
    // returns the full SVG node details of the point p1, something like:
    // <ellipse id='box_jxgBoard1P6' stroke='#ff0000' stroke-opacity='1' stroke-width='2px'
    //   fill='#ff0000' fill-opacity='1' cx='250' cy='250' rx='4' ry='4'
    //   style='position: absolute;'>
    // </ellipse>
var s = board.create('segment', [p1, p2], {strokeWidth: 60});
    s.rendNode.setAttribute('stroke-linecap', 'round');
Source
base/element.js, line 193

stdform : Array

Description

[c, b0, b1, a, k, r, q0, q1]

See A.E. Middleditch, T.W. Stacey, and S.B. Tor: "Intersection Algorithms for Lines and Circles", ACM Transactions on Graphics, Vol. 8, 1, 1989, pp 25-40.

The meaning of the parameters is: Circle: points p=[p0, p1] on the circle fulfill a<p, p> + <b, p> + c = 0 For convenience we also store r: radius k: discriminant = sqrt(<b,b>-4ac) q=[q0, q1] center

Points have radius = 0. Lines have radius = infinity. b: normalized vector, representing the direction of the line.

Should be put into Coords, when all elements possess Coords.

Type
Array
Default Value
[1, 0, 0, 0, 1, 1, 0, 0]
Source
base/element.js, line 254

subs : Object

Description

Subs contains the subelements, created during the create method.

Type
Object
Source
base/element.js, line 213

symbolic : Object

Description

Stores variables for symbolic computations

Type
Object
Source
base/element.js, line 162

traces : Object

Description

Keeps track of all objects drawn as part of the trace of the element.

Type
Object
See
Source
base/element.js, line 116

transformations : Array

Description

Stores the transformations which are applied during update in an array

Type
Array
See
Source
base/element.js, line 131

(constant) type : Number

Description

Type of the element.

Type
Number
Source
base/element.js, line 319

visProp : Object

Description

An associative array containing all attributes.

Type
Object
Default Value
empty object
Source
base/element.js, line 272

visPropCalc : Object

Description

An associative array containing attributes which are calculated from the attribute values (i.e. visProp) and from other constraints. An example: if an intersection point does not have real coordinates, visPropCalc.visible is set to false. Additionally, the user can control visibility with the attribute "visible", even by supplying a functions as value.

Type
Object
Default Value
empty object
Source
base/element.js, line 285

Inherited

none

Methods

Own

(private) _set(key, value)

Sets the value of attribute key to value. Here, mainly hex strings for rga(a) colors are parsed and values of type object get a special treatment. Other values are just set to the key.

Parameters

Name Type Description
key String

The attribute's name.

value

The new value

Details

Source
base/element.js, line 1143

addChild(obj)

Add an element as a child to the current element. Can be used to model dependencies between geometry elements.

Parameters

Name Type Description
obj JXG.GeometryElement

The dependent object.

Details

Source
base/element.js, line 386

(private) addDescendants(obj)

Parameters

Name Type Description
obj JXG.GeometryElement

The element that is to be added to the descendants list.

Returns

this

Details

Source
base/element.js, line 425

addParents(parents) → {JXG.Object}

Adds ids of elements to the array this.parents. This method needs to be called if some dependencies can not be detected automatically by JSXGraph. For example if a function graph is given by a function which refers to coordinates of a point, calling addParents() is necessary.

Example

// Movable function graph
var A = board.create('point', [1, 0], {name:'A'}),
    B = board.create('point', [3, 1], {name:'B'}),
    f = board.create('functiongraph', function(x) {
         var ax = A.X(),
             ay = A.Y(),
             bx = B.X(),
             by = B.Y(),
             a = (by - ay) / ( (bx - ax) * (bx - ax) );
          return a * (x - ax) * (x - ax) + ay;
     }, {fixed: false});
f.addParents([A, B]);

Parameters

Name Type Description
parents Array

Array of elements or ids of elements. Alternatively, one can give a list of objects as parameters.

Returns

reference to the object itself.

Type
JXG.Object

Details

Source
base/element.js, line 478

(private) addParentsFromJCFunctions(function_array) → {JXG.Object}

Add dependence on elements in JessieCode functions.

Parameters

Name Type Description
function_array Array

Array of functions containing potential properties "deps" with elements the function depends on.

Returns

reference to the object itself

Type
JXG.Object

Details

Source
base/element.js, line 521

addRotation(angle)

Rotate texts or images by a given degree.

Parameters

Name Type Description
angle number

The degree of the rotation (90 means vertical text).

Details

See
  • JXG.GeometryElement#rotate
Source
base/element.js, line 2001

addTicks(ticks) → {String}

Adds ticks to this line or curve. Ticks can be added to a curve or any kind of line: line, arrow, and axis.

Parameters

Name Type Description
ticks JXG.Ticks

Reference to a ticks object which is describing the ticks (color, distance, how many, etc.).

Returns

Id of the ticks object.

Type
String

Details

Source
base/element.js, line 2291

addTransform(transform) → {JXG.GeometryElement}

Add transformations to this element.

Parameters

Name Type Description
transform Transformation | Array

Either one Transformation or an array of JXG.Transformations.

Returns

Reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 629

animate(hash, time, optionsopt) → {JXG.GeometryElement}

Animates attributes for that object like stroke or fill color, opacity and maybe even more later.

Parameters

Name Type Attributes Description
hash Object

Object containing attributes with target values for the animation.

time number

Number of milliseconds to complete the animation.

options Object <optional>

Optional settings for the animation:

  • callback: A function that is called as soon as the animation is finished

Returns

A reference to the object

Type
JXG.GeometryElement

Details

Source
base/element.js, line 836

bounds() → {Array|Array}

Dimensions of the smallest rectangle enclosing the element.

Returns

Details

Source
base/element.js, line 1954

clearTrace()

Removes all objects generated by the trace function.

Details

Source
base/element.js, line 1926

clearTransforms() → {JXG.GeometryElement}

Remove all JXG.Transformations of this element.

Returns

Reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 647

cloneToBackground() → {JXG.GeometryElement}

Copy the element to background. This is used for tracing elements.

Returns

A reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1943

(private) countChildren() → {number}

Counts the direct children of an object without counting labels.

Returns

Number of children

Type
number

Details

Source
base/element.js, line 601

(private) createGradient()

Creates a gradient nodes in the renderer.

Details

See
Source
base/element.js, line 1822

createLabel()

Creates a label element for this geometry element.

Details

See
  • JXG.GeometryElement#addLabelToElement
Source
base/element.js, line 1833

(private) draggable() → {boolean}

Decides whether an element can be dragged. This is used in JXG.GeometryElement#setPositionDirectly methods where all parent elements are checked if they may be dragged, too.

Returns

Type
boolean

Details

Source
base/element.js, line 658

eval(val) → {String|Number|Object}

Get value of a parameter. If the parameter is a function, call the function and return its value. In that case, the function is called with the GeometryElement as (only) parameter. For label elements (i.e. if the attribute "islabel" is true), the anchor element is supplied. The label of an element can be accessed as sub-object "label" then.

Parameters

Name Type Description
val String | Number | function | Object

If not a function, it will be returned as is. If function it will be evaluated, where the GeometryElement is supplied as the (only) parameter of that function.

Returns

Type
String | Number | Object

Details

See
  • GeometryElement#evalVisProp
  • JXG#evaluate
Source
base/element.js, line 1720

evalVisProp(key) → {String|Number|Boolean}

Get value of an attribute. If the value that attribute is a function, call the function and return its value. In that case, the function is called with the GeometryElement as (only) parameter. For label elements (i.e. if the attribute "islabel" is true), the anchor element is supplied. The label element can be accessed as sub-object "label". If the attribute does not exist, undefined will be returned.

Parameters

Name Type Description
key String

Attribute key

Returns

value of attribute "key" (evaluated in case of a function) or undefined

Type
String | Number | Boolean

Details

See
  • GeometryElement#eval
  • JXG#evaluate
Source
base/element.js, line 1631

formatNumberLocale(value, digitsopt) → {String|Number}

Format a number according to the locale set in the attribute "intl". If in the options of the intl-attribute "maximumFractionDigits" is not set, the optional parameter digits is used instead. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat for more information about internationalization.

Parameters

Name Type Attributes Description
value Number

Number to be formatted

digits Number <optional>

Optional number of digits

Returns

string containing the formatted number according to the locale or the number itself of the formatting is not possible.

Type
String | Number

Details

Source
base/element.js, line 2539

(private) fullUpdate(visible) → {JXG.GeometryElement}

Run through the full update chain of an element.

Parameters

Name Type Description
visible Boolean

Set visibility in case the elements attribute value is 'inherit'. null is allowed.

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 944

generatePolynomial() → {Array}

Array of strings containing the polynomials defining the element. Used for determining geometric loci the groebner way.

Returns

An array containing polynomials describing the locus of the current object.

Type
Array

Details

Source
base/element.js, line 823

getAttribute(key)

Get the value of the property key.

Parameters

Name Type Description
key String

The name of the property you are looking for

Returns

The value of the property

Details

Source
base/element.js, line 1593

getAttributes() → {Object}

Retrieve a copy of the current visProp.

Returns

Type
Object

Details

Source
base/element.js, line 2255

getLabelAnchor() → {JXG.Coords}

Returns the coords object where the label of the element shall be drawn. Differs in some cases from the values that getTextAnchor returns.

Returns

JXG.Coords Place where the text shall be drawn.

Type
JXG.Coords

Details

See
Source
base/element.js, line 1794

getName() → {String}

Returns the elements name. Used in JessieCode.

Returns

Type
String

Details

Source
base/element.js, line 619

getParents() → {Array}

List of the element ids resp. values used as parents in JXG.Board#create.

Returns

Type
Array

Details

Source
base/element.js, line 2223

getProperty()

Deprecated alias for JXG.GeometryElement#getAttribute.

Details

Deprecated
Use JXG.GeometryElement#getAttribute.
Source
base/element.js, line 1583

(private) getSnapSizes() → {Array}

Determine values of snapSizeX and snapSizeY. If the attributes snapSizex and snapSizeY are greater than zero, these values are taken. Otherwise, determine the distance between major ticks of the default axes.

Returns

containing the snap sizes for x and y direction.

Type
Array

Details

Source
base/element.js, line 2355

getTextAnchor() → {JXG.Coords}

Returns the coords object where a text that is bound to the element shall be drawn. Differs in some cases from the values that getLabelAnchor returns.

Returns

JXG.Coords Place where the text shall be drawn.

Type
JXG.Coords

Details

See
Source
base/element.js, line 1784

getType() → {String}

The type of the element as used in JXG.Board#create.

Returns

Type
String

Details

Source
base/element.js, line 2215

handleSnapToGrid(force, fromParent) → {JXG.GeometryElement}

Move an element to its nearest grid point. The function uses the coords object of the element as its actual position. If there is no coords object or if the object is fixed, nothing is done.

Parameters

Name Type Description
force Boolean

force snapping independent from what the snaptogrid attribute says

fromParent Boolean

True if the drag comes from a child element. This is the case if a line through two points is dragged. In this case we do not try to force the points to stay inside of the visible board, but the distance between the two points stays constant.

Returns

Reference to this element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 2384

hasPoint(x, y) → {Boolean}

Checks whether (x,y) is near the element.

Parameters

Name Type Description
x Number

Coordinate in x direction, screen coordinates.

y Number

Coordinate in y direction, screen coordinates.

Returns

True if (x,y) is near the element, False otherwise.

Type
Boolean

Details

Source
base/element.js, line 2282

hide() → {JXG.GeometryElement}

Hide the element. It will still exist but not be visible on the board. Alias for "element.setAttribute({visible: false});"

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1015

hideElement() → {JXG.GeometryElement}

Hide the element. It will still exist but not be visible on the board. Alias for JXG.GeometryElement#hide

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1025

(private) highlight(forceopt) → {JXG.Board}

Highlights the element.

Parameters

Name Type Attributes Default Description
force Boolean <optional>
false

Force the highlighting

Returns

Type
JXG.Board

Details

Source
base/element.js, line 1884

noHighlight() → {JXG.Board}

Uses the "normal" attributes of the element.

Returns

Type
JXG.Board

Details

Source
base/element.js, line 1911

(private) normalize()

Normalize the element's standard form.

Details

Source
base/element.js, line 1962

(private) prepareUpdate()

Notify all child elements for updates.

Details

Source
base/element.js, line 1759

remove()

Removes the element from the construction. This only removes the SVG or VML node of the element and its label (if available) from the renderer, to remove the element completely you should use JXG.Board#removeObject.

Details

Source
base/element.js, line 1768

removeAllTicks()

Removes all ticks from a line or curve.

Details

Source
base/element.js, line 2305

removeChild(obj) → {JXG.Object}

Remove an element as a child from the current element.

Parameters

Name Type Description
obj JXG.GeometryElement

The dependent object.

Returns

reference to the object itself

Type
JXG.Object

Details

Source
base/element.js, line 544

(private) removeDescendants(obj) → {JXG.Object}

Removes the given object from the descendants list of this object and all its child objects.

Parameters

Name Type Description
obj JXG.GeometryElement

The element that is to be removed from the descendants list.

Returns

reference to the object itself

Type
JXG.Object

Details

Source
base/element.js, line 584

removeTicks(tick)

Removes ticks identified by parameter named tick from this line or curve.

Parameters

Name Type Description
tick JXG.Ticks

Reference to tick object to remove.

Details

Source
base/element.js, line 2320

removeTransform(transform) → {JXG.GeometryElement}

Remove transformations of this element.

Parameters

Name Type Description
transform Transformation | Array

Either one Transformation or an array of JXG.Transformations.

Returns

Reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 639

(private) resolveShortcuts(attributes) → {Object}

Resolves attribute shortcuts like color and expands them, e.g. strokeColor and fillColor. Writes the expanded attributes back to the given attributes.

Parameters

Name Type Description
attributes Object

object

Returns

The given attributes object with shortcuts expanded.

Type
Object

Details

Source
base/element.js, line 1189

setArrow(firstArrow, lastArrow)

Determines whether the element has arrows at start or end of the arc. If it is set to be a "typical" vector, ie lastArrow == true, then the element.type is set to VECTOR.

Parameters

Name Type Description
firstArrow Boolean

True if there is an arrow at the start of the arc, false otherwise.

lastArrow Boolean

True if there is an arrow at the end of the arc, false otherwise.

Details

Source
base/element.js, line 1805

setAttribute(attributes) → {JXG.GeometryElement}

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]

Example

// Set attribute directly on creation of an element using the attributes object parameter
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 5, 5, 1]};
var p = board.create('point', [2, 2], {visible: false});

// Now make this point visible and fixed:
p.setAttribute({
    fixed: true,
    visible: true
});

Parameters

Name Type Description
attributes Object

An object with attributes.

Returns

A reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1281

(private) setDash(dash)

Set the dash style of an object. See JXG.GeometryElement#dash for a list of available dash styles. You should use JXG.GeometryElement#setAttribute instead of this method.

Parameters

Name Type Description
dash number

Indicates the new dash style

Details

Source
base/element.js, line 1750

(private) setDisplayRendNode(val) → {JXG.GeometryElement}

Show the element or hide it. If hidden, it will still exist but not be visible on the board.

Sets also the display of the inherits elements. These can be JSXGraph elements or arrays of JSXGraph elements. However, deeper nesting than this is not supported.

Parameters

Name Type Description
val Boolean

true: show the element, false: hide the element

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 960

setLabel(str)

Sets a label and its text If label doesn't exist, it creates one

Parameters

Name Type Description
str String

Details

Source
base/element.js, line 1217

setLabelText(str)

Updates the element's label text, strips all html.

Parameters

Name Type Description
str String

Details

Source
base/element.js, line 1228

setName(str)

Updates the element's label text and the element's attribute "name", strips all html.

Parameters

Name Type Description
str String

Details

Source
base/element.js, line 1241

setParents(parents) → {JXG.Object}

Sets ids of elements to the array this.parents. First, this.parents is cleared. See JXG.GeometryElement#addParents.

Parameters

Name Type Description
parents Array

Array of elements or ids of elements. Alternatively, one can give a list of objects as parameters.

Returns

reference to the object itself.

Type
JXG.Object

Details

Source
base/element.js, line 508

setPosition(method, coords) → {JXG.GeometryElement}

Translates the object by (x, y). In case the element is defined by points, the defining points are translated, e.g. a circle constructed by a center point and a point on the circle line.

Parameters

Name Type Description
method Number

The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.

coords Array

array of translation vector.

Returns

Reference to the element object.

Type
JXG.GeometryElement

Details

See
  • JXG.GeometryElement3D#setPosition2D
Source
base/element.js, line 677

setPositionDirectly(method, coords, oldcoords) → {JXG.GeometryElement}

Moves an element by the difference of two coordinates.

Parameters

Name Type Description
method Number

The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.

coords Array

coordinates in screen/user units

oldcoords Array

previous coordinates in screen/user units

Returns

{JXG.GeometryElement} A reference to the object

Type
JXG.GeometryElement

Details

Source
base/element.js, line 757

setProperty()

Deprecated alias for JXG.GeometryElement#setAttribute.

Details

Deprecated
Use JXG.GeometryElement#setAttribute.
Source
base/element.js, line 1253

show() → {JXG.GeometryElement}

Make the element visible. Alias for "element.setAttribute({visible: true});"

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1035

showElement() → {JXG.GeometryElement}

Make the element visible. Alias for JXG.GeometryElement#show

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1045

(private) snapToPoints() → {JXG.GeometryElement}

Snaps the element to points. Only works for points. Points will snap to the next point as defined in their attributes Point#attractorDistance and Point#attractorUnit. Lines and circles will snap their parent points to points.

Returns

Reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 2247

toTopOfLayer() → {JXG.GeometryElement}

Moves the element to the top of its layer. Works only for SVG renderer and for simple elements consisting of one SVG node.

Example

// Move one of the points 'A' or ''B' to make
  // their midpoint visible.
  const point1 = board.create("point", [-3, 1]);
  const point2 = board.create("point", [2,  1]);
  var mid = board.create("midpoint", [point1, point2]);
  const point3 = board.create("point", [-0.5, 1], {size: 10, color: 'blue'});

  mid.coords.on('update', function() {
      mid.toTopOfLayer();
  });
  point3.coords.on('update', function() {
      point3.toTopOfLayer();
  });

Returns

{JXG.GeometryElement} A reference to the object

Type
JXG.GeometryElement

Details

Source
base/element.js, line 809

update() → {JXG.GeometryElement}

General update method. Should be overwritten by the element itself. Can be used sometimes to commit changes to the object.

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 922

(private) updateRenderer() → {JXG.GeometryElement}

Provide updateRenderer method.

Returns

Reference to the element

Type
JXG.GeometryElement

Details

Source
base/element.js, line 934

(private) updateVisibility(parent_val) → {JXG.GeometryElement}

Set the visibility of an element. The visibility is influenced by (listed in ascending priority):

  1. The value of the element's attribute 'visible'
  2. The visibility of a parent element. (Example: label) This overrules the value of the element's attribute value only if this attribute value of the element is 'inherit'.
  3. being inside of the canvas

This method is called three times for most elements:

  1. between JXG.GeometryElement#update and JXG.GeometryElement#updateRenderer. In case the value is 'inherit', nothing is done.
  2. Recursively, called by itself for child elements. Here, 'inherit' is overruled by the parent's value.
  3. In JXG.GeometryElement#updateRenderer, if the element is outside of the canvas.

Parameters

Name Type Description
parent_val Boolean

Visibility of the parent element.

Returns

Reference to the element.

Type
JXG.GeometryElement

Details

Source
base/element.js, line 1071

useLocale() → {Boolean}

Checks if locale is enabled in the attribute. This may be in the attributes of the board, or in the attributes of the text. The latter has higher priority. The board attribute is taken if attribute "intl.enabled" of the text element is set to 'inherit'.

Returns

if locale can be used for number formatting.

Type
Boolean

Details

Source
base/element.js, line 2606

(static) addEvent()

Alias of JXG.EventEmitter.on.

Details

Source
base/element.js, line 2509

(static) removeEvent()

Alias of JXG.EventEmitter.off.

Details

Source
base/element.js, line 2518

Inherited

none

Events

Own

attribute:key

This is a generic event handler. It exists for every possible attribute that can be set for any element, e.g. if you want to be notified everytime an element's strokecolor is changed, is the event attribute:strokecolor.

Parameters

Name Type Description
val

The old value.

nval

The new value

el Object

Reference to the element

Details

Source
base/element.js, line 2863

attribute

Notify every time an attribute is changed.

Parameters

Name Type Description
o Object

A list of changed attributes and their new value.

el Object

Reference to the element

Details

Source
base/element.js, line 2854

down

Whenever the user starts to touch or click an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2736

drag

This event is fired whenever the user drags an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2695

keydrag

This event is fired whenever the user drags the element by pressing arrow keys on the keyboard.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2727

mousedown

Whenever the user starts to click an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2744

mousedrag

This event is fired whenever the user drags the element with a mouse.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2703

mousemove

This event is fired whenever the user is moving the mouse over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2687

mouseout

This event is fired whenever the user puts the mouse away from an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2671

mouseover

This event is fired whenever the user puts the mouse over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2655

mouseup

Whenever the user releases the mousebutton over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2830

move

This event is fired whenever the user is moving over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2679

out

This event is fired whenever the user is leaving an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2663

over

This event is fired whenever the user is hovering over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2647

pendown

Whenever the user taps an element with the pen.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2752

pendrag

This event is fired whenever the user drags the element with a pen.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2711

penup

Whenever the user lifts the pen over an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2838

touchdown

Whenever the user starts to touch an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2760

touchdrag

This event is fired whenever the user drags the element on a touch device.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2719

touchup

Whenever the user stops touching an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2846

up

Whenever the user stops to touch or click an element.

Parameters

Name Type Description
e Event

The browser's event object.

Details

Source
base/element.js, line 2822

Inherited

none

Parameters

Name Type Description
board JXG.Board

Reference to the board the element is constructed on.

attributes Object

Hash of attributes and their values.

type Number

Element type (a JXG.OBJECT_TYPE_... value).

oclass Number

The element's class (a JXG.OBJECT_CLASS_ value).

Details

Source
base/element.js, line 58