# JSXGraph 1.11.1 Reference

## JavaScript must be enabled in order for you to use JSXGraph and JSXGraph reference. However, it seems JavaScript is either disabled or not supported by your browser.

Class Index | File Index

Elements

- Angle
- Arc
- Arrow
- Arrowparallel
- Axes3D
- Axis
- Axis3D
- Bisector
- Bisectorlines
- Boxplot
- Button
- Cardinalspline
- Chart
- Checkbox
- Circle
- Circle3D
- Circumcenter
- Circumcircle
- CircumcircleArc
- CircumcircleSector
- Comb
- Conic
- Curve
- Curve3D
- CurveDifference
- CurveIntersection
- CurveUnion
- Derivative
- Ellipse
- Face3D
- ForeignObject
- Functiongraph
- Functiongraph3D
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- ImplicitCurve
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- IntersectionCircle3D
- IntersectionLine3D
- Label
- Legend
- Line
- Line3D
- MajorArc
- MajorSector
- Measurement
- Mesh3D
- Metapostspline
- Midpoint
- MinorArc
- MinorSector
- MirrorElement
- MirrorPoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelogram
- Parallelpoint
- ParametricSurface3D
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Plane3D
- Point
- Point3D
- PolarLine
- PolePoint
- Polygon
- Polygon3D
- PolygonalChain
- Polyhedron3D
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopefield
- Slopetriangle
- Smartlabel
- Sphere3D
- Spline
- Stepfunction
- Tangent
- TangentTo
- Tapemeasure
- Text
- Text3D
- Ticks
- Ticks3D
- Tracecurve
- Transformation
- Transformation3D
- Turtle
- Vectorfield
- Vectorfield3D
- View3D

Classes

- _global_
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.Board.infobox
- JXG.C
- JXG.CA
- JXG.CanvasRenderer
- JXG.Chart
- JXG.Circle
- JXG.Circle3D
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.CoordsElement
- JXG.Curve
- JXG.Curve3D
- JXG.Dump
- JXG.EventEmitter
- JXG.Expect
- JXG.Face3D
- JXG.ForeignObject
- JXG.GeometryElement
- JXG.GeometryElement3D
- JXG.GeonextParser
- JXG.Group
- JXG.Image
- JXG.JessieCode
- JXG.JSXGraph
- JXG.Legend
- JXG.Line
- JXG.Line3D
- JXG.Math
- JXG.Math.BoxQuadtree
- JXG.Math.Clip
- JXG.Math.Extrapolate
- JXG.Math.Geometry
- JXG.Math.ImplicitPlot
- JXG.Math.IntervalArithmetic
- JXG.Math.Metapost
- JXG.Math.Nlp
- JXG.Math.Numerics
- JXG.Math.Plot
- JXG.Math.Poly
- JXG.Math.Poly.Monomial
- JXG.Math.Poly.Polynomial
- JXG.Math.Poly.Ring
- JXG.Math.ProbFuncs
- JXG.Math.Quadtree
- JXG.Math.Statistics
- JXG.NoRenderer
- JXG.Options
- JXG.Plane3D
- JXG.Point
- JXG.Point3D
- JXG.Polygon
- JXG.Polygon3D
- JXG.PrefixParser
- JXG.Sphere3D
- JXG.Surface3D
- JXG.SVGRenderer
- JXG.Text
- JXG.Text3D
- JXG.Ticks
- JXG.Transformation
- JXG.Turtle
- JXG.Util
- JXG.Util.Base64
- JXG.Util.Unzip
- JXG.Util.UTF8
- JXG.View3D
- JXG.VMLRenderer
- JXG.XML

# Class JXG.JessieCode

↳ JXG.JessieCode

Defined in: jessiecode.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| JXG.JessieCode(code, geonext) A JessieCode object provides an interface to the parser and stores all variables and objects used within a JessieCode script.

Field Summary
Field Attributes | Field Name and Description
--- | ---
| $log Store $log messages in case there's no console.
| board The board which currently is used to create and look up elements.
| builtIn Built-in functions and constants
| creator Returns a element creator function which takes two parameters: the parents array and the attributes object.
<private> | dpstack A stack to store debug information (like line and column where it was defined) of a parameter
| forceValueCall Force slider names to return value instead of node
| isLHS lhs flag, used by JXG.JessieCode#replaceNames
<private> | lhs Store the left hand side of an assignment.
| lineToElement Keep track of which element is created in which line.
| operands List of all possible operands in JessieCode (except of JSXGraph objects).
<private> | propscope The current scope of the object literal stack JXG.JessieCode#propstack.
<private> | propstack Used to store the property-value definition while parsing an object literal.
<private> | pscope Determines the parameter stack scope.
| scope The global scope.
| scopes Keeps track of all possible scopes every required.
| warnLog The id of an HTML node in which innerHTML all warnings are stored (if no `console` object is available).

Method Summary
Method Attributes | Method Name and Description
--- | ---
<private> | _debug(log) Output a debugging message.
<private> | _error(msg) Throws an exception with the given error message.
<private> | _genericParse(code, cmd, geonext, dontstore) Generic method to parse JessieCode.
<private> | _warn(msg) Output a warning message using JXG#debug and precedes the message with "Warning: ".
| add(a, b) + operator implementation
| area(obj) This is used as the global area() function.
| collectDependencies(node, varnames, result) Search the parse tree below `node` for stationary dependencies, i.e.
<private> | compile(node, js) Compiles a parse tree back to JessieCode.
| createNode(type, value, children) Create a new parse tree node.
| createReplacementNode(node, callValue) Replaces node_var nodes with node_op>op_execfun nodes, calling the internal $() function with the id of the element accessed by the node_var node.
| defineBuiltIn() Defines built in methods and constants.
| defineFunction(node) Converts a node type `node_op` and value `op_map` or `op_function` into a executable function.
| del(element) Implementation of the delete() builtin function
| dist(p1, p2) This is used as the global dist() function.
| div(a, b) Implementation of the / operator.
| eval(v) Implementation of the eval() builtin function.
<private> | execute(node) Executes a parse subtree.
| findSymbol(v, scope) Find the first symbol to the given value from the given scope upwards.
| getAST(code, geonext, dontstore) Get abstract syntax tree (AST) from JessieCode code.
| getElementById(id) Looks up an JXG.GeometryElement by its id.
| getLHS(node) Resolves the lefthand side of an assignment operation
| getName(obj, useId) This is used as the global getName() function.
| getPossibleOperands() Returns information about the possible functions and constants.
| getvar(vname, local, isFunctionName) Looks up the value of the given variable.
| getvarJS(vname, local, withProps) TODO this needs to be called from JS and should not generate JS code Looks up a variable identifier in various tables and generates JavaScript code that could be eval'd to get the value.
| ifthen(cond, v1, v2) Implementation of the ?: operator
| importModule(module) Import modules into a JessieCode script.
| isBuiltIn(vname) Returns true if the given identifier is a builtIn variable/function.
| isCreator(vname) Checks if the given variable name is a valid creator method.
| isLocalVariable(vname) Checks if the given variable name can be found in the current scope chain.
| isMathMethod(vname) Checks if the given variable identifier is a valid member of the JavaScript Math Object.
| isParameter(vname) Checks if the given variable name is a parameter in any scope from the current to the global scope.
| L(e) This is used as the global L() function.
| letvar(vname, value) Assigns a value to a variable in the current scope.
| makeMap(f) Adds the property `isMap` to a function and sets it to true.
| manipulate(code, geonext, dontstore) Manipulate JessieCode.
| mergeAttributes(o) Merge all attribute values given with an element creator into one object.
| mod(a, b) Implementation of the % operator.
| mul(a, b) Multiplication of vectors and numbers
| neg(a) unary - operator implementation
| node(type, value, children) Create a new parse tree node.
| parse(code, geonext, dontstore) Parses JessieCode.
| perimeter(obj) This is used as the global perimeter() function.
| popScope() Remove the current scope and reinstate the previous scope
| pow(a, b) Pow function wrapper to allow direct usage of sliders.
| pushScope(args) Create a new scope.
| radius(obj) This is used as the global radius() function.
| replaceIDs(node) Traverses through the given subtree and changes all values of nodes with the replaced flag set by JXG.JessieCode#replaceNames to the name of the element (if not empty).
| replaceNames(node, callValuePar) Traverses through the given subtree and changes all elements referenced by names through referencing them by ID.
| resolve(vname) Look up the value of a local variable.
<private> | resolveType(vname, node) Type inspection: check if the string vname appears as function name in the AST node.
| setProp(o, what, value) Sets the property `what` of `o` to `value`
| slope(obj) This is used as the global slope() function.
| snippet(code, funwrap, varname, geonext, forceValueCall) Parses a JessieCode snippet, e.g.
| sub(a, b) - operator implementation
| use(board) Implementation of the use() builtin function
| V(e) This is used as the global V() function.
| X(e) This is used as the global X() function.
| Y(e) This is used as the global Y() function.

Class Detail
JXG.JessieCode(code, geonext)
A JessieCode object provides an interface to the parser and stores all variables and objects used within a JessieCode script. The optional argument `code` is interpreted after initializing. To evaluate more code after initializing a JessieCode instance please use JXG.JessieCode#parse. For code snippets like single expressions use JXG.JessieCode#snippet.

Parameters:
{String} code Optional
  Code to parse.
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.

Field Detail
{Array} $log
Store $log messages in case there's no console.

{JXG.Board} board
The board which currently is used to create and look up elements.

{Object} builtIn
Built-in functions and constants

{function} creator
Returns a element creator function which takes two parameters: the parents array and the attributes object.

<private> {Array} dpstack
A stack to store debug information (like line and column where it was defined) of a parameter

{Boolean} forceValueCall
Force slider names to return value instead of node

{Boolean} isLHS
lhs flag, used by JXG.JessieCode#replaceNames

Default Value:
  false

<private> {Array} lhs
Store the left hand side of an assignment. If an element is constructed and no attributes are given, this is used as the element's name.

{Object} lineToElement
Keep track of which element is created in which line.

{Object} operands
List of all possible operands in JessieCode (except of JSXGraph objects).

<private> {Number} propscope
The current scope of the object literal stack JXG.JessieCode#propstack.

<private> {Array} propstack
Used to store the property-value definition while parsing an object literal.

<private> {Number} pscope
Determines the parameter stack scope.

{Object} scope
The global scope.

{Array} scopes
Keeps track of all possible scopes every required.

{String} warnLog
The id of an HTML node in which innerHTML all warnings are stored (if no `console` object is available).

Default Value:
  'jcwarn'

Method Detail
<private> _debug(log)
Output a debugging message. Uses debug console, if available. Otherwise an HTML element with the id "debug" and an innerHTML property is used.

Parameters:
{String} log

<private> _error(msg)
Throws an exception with the given error message.

Parameters:
{String} msg
  Error message

<private> {Object} _genericParse(code, cmd, geonext, dontstore)
Generic method to parse JessieCode. This consists of generating an AST with parser.parse, apply simplifying rules from CA and manipulate the AST according to the second parameter "cmd".

Parameters:
{String} code
  JessieCode code to be parsed
{String} cmd
  Type of manipulation to be done with AST
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.
{Boolean} dontstore Optional, Default: false
  If false, the code string is stored in this.code, i.e. in the JessieCode object, e.g. in board.jc.

Returns:
  {Object} Returns result of computation as directed in cmd.

<private> _warn(msg)
Output a warning message using JXG#debug and precedes the message with "Warning: ".

Parameters:
{String} msg

{Number|Array} add(a, b)
+ operator implementation

Parameters:
{Number|Array|JXG.Point} a
{Number|Array|JXG.Point} b

Returns:
  {Number|Array}

{Number} area(obj)
This is used as the global area() function.

Parameters:
{JXG.Circle|JXG.Polygon} obj

Returns:
  {Number}

collectDependencies(node, varnames, result)
Search the parse tree below `node` for stationary dependencies, i.e. dependencies hard coded into the function.

Parameters:
{Object} node
{Array} varnames
  List of variable names of the function
{Object} result
  An object where the referenced elements will be stored. Access key is their id.

<private> compile(node, js)
Compiles a parse tree back to JessieCode.

Parameters:
{Object} node
{Boolean} js Optional, Default: false
  Compile either to JavaScript or back to JessieCode (required for the UI).

Returns:
  Something

createNode(type, value, children)
Create a new parse tree node. Basically the same as node(), but this builds the children part out of an arbitrary number of parameters, instead of one array parameter.

Parameters:
{String} type
  Type of node, e.g. node_op, node_var, or node_const
value
  The nodes value, e.g. a variables value or a functions body.
children
  Arbitrary number of parameters; define the child nodes.

{Object} createReplacementNode(node, callValue)
Replaces node_var nodes with node_op>op_execfun nodes, calling the internal $() function with the id of the element accessed by the node_var node.

Parameters:
{Object} node
{Boolean} callValue Optional, Default: undefined
  if true, uses $value() instead of $()

Returns:
  {Object} op_execfun node

{Object} defineBuiltIn()
Defines built in methods and constants.

Returns:
  {Object} BuiltIn control object

{function} defineFunction(node)
Converts a node type `node_op` and value `op_map` or `op_function` into a executable function. Does a simple type inspection.

Parameters:
{Object} node

Returns:
  {function}

See:
  JXG.JessieCode#resolveType

del(element)
Implementation of the delete() builtin function

Parameters:
{JXG.GeometryElement} element

{Number} dist(p1, p2)
This is used as the global dist() function.

Parameters:
{JXG.Point} p1
{JXG.Point} p2

Returns:
  {Number}

{Number|Array} div(a, b)
Implementation of the / operator.

Parameters:
{Number|Array} a
{Number} b

Returns:
  {Number|Array}

eval(v)
Implementation of the eval() builtin function. Calls JXG.evaluate().

Parameters:
{String|Number|Function} v

<private> {Number|String|Object|Boolean} execute(node)
Executes a parse subtree.

Parameters:
{Object} node

Returns:
  {Number|String|Object|Boolean} Something

{Array} findSymbol(v, scope)
Find the first symbol to the given value from the given scope upwards.

Parameters:
v
  Value
{Number} scope Optional, Default: -1
  The scope, default is to start with current scope (-1).

Returns:
  {Array} An array containing the symbol and the scope if a symbol could be found, an empty array otherwise;

{Node} getAST(code, geonext, dontstore)
Get abstract syntax tree (AST) from JessieCode code. This consists of generating an AST with parser.parse.

Parameters:
{String} code
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.
{Boolean} dontstore Optional, Default: false
  If false, the code string is stored in this.code.

Returns:
  {Node} AST

{JXG.GeometryElement} getElementById(id)
Looks up an JXG.GeometryElement by its id.

Parameters:
{String} id

Returns:
  {JXG.GeometryElement}

{Object} getLHS(node)
Resolves the lefthand side of an assignment operation

Parameters:
node

Returns:
  {Object} An object with two properties. o which contains the object, and a string what which contains the property name.

{String} getName(obj, useId)
This is used as the global getName() function.

Parameters:
{JXG.GeometryElement} obj
{Boolean} useId

Returns:
  {String}

{Object} getPossibleOperands()
Returns information about the possible functions and constants.

Returns:
  {Object}

getvar(vname, local, isFunctionName)
Looks up the value of the given variable. We use a simple type inspection.

Parameters:
{String} vname
  Name of the variable
{Boolean} local Optional, Default: false
  Only look up the internal symbol table and don't look for the `vname` in Math or the element list.
{Boolean} isFunctionName Optional, Default: false
  Lookup function of type builtIn, Math.*, creator.

See:
  JXG.JessieCode#resolveType

getvarJS(vname, local, withProps)
TODO this needs to be called from JS and should not generate JS code Looks up a variable identifier in various tables and generates JavaScript code that could be eval'd to get the value.

Parameters:
{String} vname
  Identifier
{Boolean} local Optional, Default: false
  Don't resolve ids and names of elements
{Boolean} withProps Optional, Default: false

{*} ifthen(cond, v1, v2)
Implementation of the ?: operator

Parameters:
{Boolean} cond
  Condition
{*} v1
{*} v2

Returns:
  {*} Either v1 or v2.

importModule(module)
Import modules into a JessieCode script.

Parameters:
{String} module

{Boolean} isBuiltIn(vname)
Returns true if the given identifier is a builtIn variable/function.

Parameters:
{String} vname

Returns:
  {Boolean}

{Boolean} isCreator(vname)
Checks if the given variable name is a valid creator method.

Parameters:
{String} vname

Returns:
  {Boolean}

{Object} isLocalVariable(vname)
Checks if the given variable name can be found in the current scope chain.

Parameters:
{String} vname

Returns:
  {Object} A reference to the scope object the variable can be found in or null if it can't be found.

{Boolean} isMathMethod(vname)
Checks if the given variable identifier is a valid member of the JavaScript Math Object.

Parameters:
{String} vname

Returns:
  {Boolean}

{Object} isParameter(vname)
Checks if the given variable name is a parameter in any scope from the current to the global scope.

Parameters:
{String} vname

Returns:
  {Object} A reference to the scope object that contains the variable in its arg list.

{Number} L(e)
This is used as the global L() function.

Parameters:
{JXG.Line} e

Returns:
  {Number}

letvar(vname, value)
Assigns a value to a variable in the current scope.

Parameters:
{String} vname
  Variable name
value
  Anything

See:
  JXG.JessieCode#sstack
  JXG.JessieCode#scope

{function} makeMap(f)
Adds the property `isMap` to a function and sets it to true.

Parameters:
{function} f

Returns:
  {function}

{String} manipulate(code, geonext, dontstore)
Manipulate JessieCode. This consists of generating an AST with parser.parse, apply simplifying rules from CA and compile the AST back to JessieCode.

Parameters:
{String} code
  JessieCode code to be parsed
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.
{Boolean} dontstore Optional, Default: false
  If false, the code string is stored in this.code.

Returns:
  {String} Simplified JessieCode code

{Object} mergeAttributes(o)
Merge all attribute values given with an element creator into one object.

Parameters:
{Object} o
  An arbitrary number of objects

Returns:
  {Object} All given objects merged into one. If properties appear in more (case sensitive) than one object the last value is taken.

{Number|Array} mod(a, b)
Implementation of the % operator.

Parameters:
{Number|Array} a
{Number} b

Returns:
  {Number|Array}

{Number|Array} mul(a, b)
Multiplication of vectors and numbers

Parameters:
{Number|Array} a
{Number|Array} b

Returns:
  {Number|Array} (Inner) product of the given input values.

{Number|Array} neg(a)
unary - operator implementation

Parameters:
{Number|Array|JXG.Point} a

Returns:
  {Number|Array}

node(type, value, children)
Create a new parse tree node.

Parameters:
{String} type
  Type of node, e.g. node_op, node_var, or node_const
value
  The nodes value, e.g. a variables value or a functions body.
{Array} children
  Arbitrary number of child nodes.

{Object} parse(code, geonext, dontstore)
Parses JessieCode. This consists of generating an AST with parser.parse, apply simplifying rules from CA and executing the ast by calling this.execute(ast).

Parameters:
{String} code
  JessieCode code to be parsed
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.
{Boolean} dontstore Optional, Default: false
  If false, the code string is stored in this.code.

Returns:
  {Object} Parse JessieCode code and execute it.

{Number} perimeter(obj)
This is used as the global perimeter() function.

Parameters:
{JXG.Circle|JXG.Polygon} obj

Returns:
  {Number}

{Object} popScope()
Remove the current scope and reinstate the previous scope

Returns:
  {Object}

{Number} pow(a, b)
Pow function wrapper to allow direct usage of sliders.

Parameters:
{Number|Slider} a
{Number|Slider} b

Returns:
  {Number}

{Object} pushScope(args)
Create a new scope.

Parameters:
{Array} args

Returns:
  {Object}

{Number} radius(obj)
This is used as the global radius() function.

Parameters:
{JXG.Circle|Sector} obj

Returns:
  {Number}

replaceIDs(node)
Traverses through the given subtree and changes all values of nodes with the replaced flag set by JXG.JessieCode#replaceNames to the name of the element (if not empty).

Parameters:
{Object} node

replaceNames(node, callValuePar)
Traverses through the given subtree and changes all elements referenced by names through referencing them by ID. An identifier is only replaced if it is not found in all scopes above the current scope and if it has not been blacklisted within the codeblock determined by the given subtree.

Parameters:
{Object} node
{Boolean} callValuePar Optional, Default: false
  if true, uses $value() instead of $() in createReplacementNode

{*} resolve(vname)
Look up the value of a local variable.

Parameters:
{string} vname

Returns:
  {*}

<private> resolveType(vname, node)
Type inspection: check if the string vname appears as function name in the AST node. Used in "op_execfun". This allows the JessieCode examples below.

Parameters:
{String} vname
{Object} node

Returns:
  'any' or 'function'

See:
  JXG.JessieCode#execute
  JXG.JessieCode#getvar

Examples:

     var p = board.create('point', [2, 0], {name: 'X'});
     var txt = 'X(X)';
     console.log(board.jc.parse(txt));

     var p = board.create('point', [2, 0], {name: 'X'});
     var txt = 'f = function(el, X) { return X(el); }; f(X, X);';
     console.log(board.jc.parse(txt));

     var p = board.create('point', [2, 0], {name: 'point'});
     var txt = 'B = point(1,3); X(point);';
     console.log(board.jc.parse(txt));

     var p = board.create('point', [2, 0], {name: 'A'});
     var q = board.create('point', [-2, 0], {name: 'X'});
     var txt = 'getCoord=function(p, f){ return f(p); }; getCoord(A, X);';
     console.log(board.jc.parse(txt));

setProp(o, what, value)
Sets the property `what` of `o` to `value`

Parameters:
{JXG.Point|JXG.Text} o
{String} what
value

{Number} slope(obj)
This is used as the global slope() function.

Parameters:
{JXG.Line} obj

Returns:
  {Number}

snippet(code, funwrap, varname, geonext, forceValueCall)
Parses a JessieCode snippet, e.g. "3+4", and wraps it into a function, if desired.

Parameters:
{String} code
  A small snippet of JessieCode. Must not be an assignment.
{Boolean} funwrap Optional, Default: true
  If true, the code is wrapped in a function.
{String} varname Optional, Default: ''
  Name of the parameter(s)
{Boolean} geonext Optional, Default: false
  Geonext compatibility mode.
{Boolean} forceValueCall Optional, Default: true
  Force evaluation of value method of sliders.

{Number|Array} sub(a, b)
- operator implementation

Parameters:
{Number|Array|JXG.Point} a
{Number|Array|JXG.Point} b

Returns:
  {Number|Array}

use(board)
Implementation of the use() builtin function

Parameters:
{String} board

{Number} V(e)
This is used as the global V() function.

Parameters:
{Glider|Slider} e

Returns:
  {Number}

{Number} X(e)
This is used as the global X() function.

Parameters:
{JXG.Point|JXG.Text} e

Returns:
  {Number}

{Number} Y(e)
This is used as the global Y() function.

Parameters:
{JXG.Point|JXG.Text} e

Returns:
  {Number}

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Apr 04 2025 09:22:41 GMT+0200 (Mitteleuropäische Sommerzeit)