# JSXGraph 1.10.0 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
- ForeignObject
- Functiongraph
- Functiongraph3D
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- ImplicitCurve
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- IntersectionCircle3D
- IntersectionLine3D
- Label
- Legend
- Line
- Line3D
- Locus
- MajorArc
- MajorSector
- Measurement
- Mesh3D
- Metapostspline
- Midpoint
- MinorArc
- MinorSector
- mirrorelement
- Mirrorpoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelogram
- Parallelpoint
- ParametricSurface3D
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Point
- Point3D
- PolarLine
- PolePoint
- Polygon
- PolygonalChain
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopefield
- Slopetriangle
- Smartlabel
- Sphere3D
- Spline
- Stepfunction
- Tangent
- TangentTo
- Tapemeasure
- Text
- Text3D
- Ticks
- Ticks3D
- Tracecurve
- Transformation
- 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.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.Math.Symbolic
- JXG.NoRenderer
- JXG.Options
- JXG.Plane3D
- JXG.Point
- JXG.Point3D
- JXG.Polygon
- JXG.Polygon3D
- JXG.PrefixParser
- JXG.Server
- JXG.Server.modules
- 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.Ticks

JXG.GeometryElement
↳ JXG.Ticks

Ticks provides methods for creation and management of ticks on an axis.
Defined in: ticks.js.
Extends JXG.GeometryElement.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| JXG.Ticks(line, ticks, attributes) Creates ticks for an axis.

Fields borrowed from class JXG.GeometryElement:
  _org_type, _pos, ancestors, baseElement, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, nonnegativeOnly, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel

Field Summary
Field Attributes | Field Name and Description
--- | ---
<private> | board The board the ticks line is drawn on.
<private> | equidistant Flag if the ticks are equidistant.
<private> | fixedTicks Array of fixed ticks.
<private> | labelCounter Used to ensure the uniqueness of label ids this counter is used.
<private> | labels Array where the labels are saved.
<private> | labelsData A list of labels which have to be displayed in updateRenderer.
<private> | line The line the ticks belong to.
<private> | ticks Stores the ticks coordinates

Fields borrowed from class JXG.GeometryElement:
  _org_type, _pos, ancestors, baseElement, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, nonnegativeOnly, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel

Method Summary
Method Attributes | Method Name and Description
--- | ---
<private> | _isInsideCanvas(x, y, m) Check if (parts of) the tick is inside the canvas.
| beautifyScientificNotationLabel(labelText) Formats label texts to make labels displayed in scientific notation look beautiful.
<private> | calculateTicksCoordinates() (Re-)calculates the ticks coordinates.
<private> | createTickPath(coords, major)
<private> | formatLabelText(value) Format label texts.
<private> | generateEquidistantTicks(coordsZero, bounds) Creates ticks coordinates and labels automatically.
<private> | generateFixedTicks(coordsZero, bounds) Creates ticks coordinates and labels based on JXG.Ticks#fixedTicks and JXG.Ticks#labels.
<private> | generateLabelData(labelText, tick, tickNumber) Create a tick label data, i.e.
<private> | generateLabelText(tick, zero, value) Creates the label text for a given tick.
<private> | getDistanceFromZero(zero, point) Calculates the signed distance in user coordinates from zero to a given point.
<private> | getDistanceMajorTicks() Calculates the distance between two major ticks in user units.
<private> | getLowerAndUpperBounds(coordsZero, type) Calculate the lower and upper bounds for tick rendering.
<private> | getXandYdeltas() Calculates the x and y distances in user coordinates between two units in user space.
<private> | getZeroCoordinates() Returns the coordinates of the point zero of the line.
| hasPoint(x, y) Checks whether (x,y) is near the line.
<private> | processTickPosition(coordsZero, tickPosition, ticksDelta, deltas) Auxiliary method used by JXG.Ticks#generateEquidistantTicks to create a tick in the line at the given tickPosition.
| setPositionDirectly(method, coords, oldcoords) Sets x and y coordinate of the tick.
<private> | setTicksSizeVariables(pos) Sets the variables used to set the height and slope of each tick.
| update() Recalculate the tick positions and the labels.
| updateRenderer() Uses the boards renderer to update the arc.
<private> | updateRendererLabels() Updates the label elements of the major ticks.

Methods borrowed from class JXG.GeometryElement:
  _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, addTransform, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setProperty, show, showElement, snapToPoints, updateVisibility, useLocale

Events borrowed from class JXG.GeometryElement:
  attribute, attribute:key, down, drag, keydrag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, pendown, pendrag, penup, touchdown, touchdrag, touchup, up

Class Detail
JXG.Ticks(line, ticks, attributes)
Creates ticks for an axis.

Parameters:
{JXG.Line} line
  Reference to the axis the ticks are drawn on.
{Number|Array} ticks
  Number defining the distance between two major ticks or an array defining static ticks.
{Object} attributes
  Properties

See:
  JXG.Line#addTicks

Field Detail
<private> {JXG.Board} board
The board the ticks line is drawn on.

<private> {Boolean} equidistant
Flag if the ticks are equidistant. If true, their distance is defined by ticksFunction.

<private> {Array} fixedTicks
Array of fixed ticks.

<private> {number} labelCounter
Used to ensure the uniqueness of label ids this counter is used.

<private> {Array} labels
Array where the labels are saved. There is an array element for every tick, even for minor ticks which don't have labels. In this case the array element contains just `null`.

<private> {Array} labelsData
A list of labels which have to be displayed in updateRenderer.

<private> {JXG.Line} line
The line the ticks belong to.

<private> {Array} ticks
Stores the ticks coordinates
Method Detail
<private> {Boolean} _isInsideCanvas(x, y, m)
Check if (parts of) the tick is inside the canvas. The tick intersects the boundary at two positions: [x[0], y[0]] and [x[1], y[1]] in screen coordinates.

Parameters:
{Array} x
  Array of length two
{Array} y
  Array of length two
m

Returns:
  {Boolean} true if parts of the tick are inside of the canvas or on the boundary.

{String} beautifyScientificNotationLabel(labelText)
Formats label texts to make labels displayed in scientific notation look beautiful. For example, label 5.00e+6 will become 5•10⁶, label -1.00e-7 will become into -1•10⁻⁷

Parameters:
{String} labelText
  - The label that we want to convert

Returns:
  {String} If labelText was not in scientific notation, return labelText without modifications. Otherwise returns beautified labelText with proper superscript notation.

<private> calculateTicksCoordinates()
(Re-)calculates the ticks coordinates.

<private> {Array} createTickPath(coords, major)

Parameters:
{JXG.Coords} coords
  Coordinates of the tick on the line.
{Boolean} major
  True if tick is major tick.

Returns:
  {Array} Array of length 3 containing path coordinates in screen coordinates of the tick (arrays of length 2). 3rd entry is true if major tick otherwise false. If the tick is outside of the canvas, the return array is empty.

<private> {String} formatLabelText(value)
Format label texts. Show the desired number of digits and use utf-8 minus sign.

Parameters:
{Number} value
  Number to be displayed

Returns:
  {String} The value converted into a string.

<private> generateEquidistantTicks(coordsZero, bounds)
Creates ticks coordinates and labels automatically. The frequency of ticks is affected by the values of JXG.Ticks#insertTicks, JXG.Ticks#minTicksDistance, and JXG.Ticks#ticksDistance

Parameters:
{JXG.Coords} coordsZero
  coordinates of the point considered zero
{Object} bounds
  contains the lower and upper bounds for ticks placement

<private> generateFixedTicks(coordsZero, bounds)
Creates ticks coordinates and labels based on JXG.Ticks#fixedTicks and JXG.Ticks#labels.

Parameters:
{JXG.Coords} coordsZero
  Coordinates of the point considered zero
{Object} bounds
  contains the lower and upper bounds for ticks placement

<private> {Object} generateLabelData(labelText, tick, tickNumber)
Create a tick label data, i.e. text and coordinates

Parameters:
{String} labelText
{JXG.Coords} tick
{Number} tickNumber

Returns:
  {Object} with properties 'x', 'y', 't' (text), 'i' (tick number) or null in case of o label

<private> {String} generateLabelText(tick, zero, value)
Creates the label text for a given tick. A value for the text can be provided as a number or string

Parameters:
{JXG.Coords} tick
  The Coords-object of the tick to create a label for
{JXG.Coords} zero
  The Coords-object of line's zero
{Number|String} value
  A predefined value for this tick

Returns:
  {String}

<private> {Number} getDistanceFromZero(zero, point)
Calculates the signed distance in user coordinates from zero to a given point. Sign is positive, if the direction from zero to point is the same as the direction zero to point2 of the line.

Parameters:
{JXG.Coords} zero
  coordinates of the point considered zero
{JXG.Coords} point
  coordinates of the point to find out the distance

Returns:
  {Number} distance between zero and point, including its sign

<private> getDistanceMajorTicks()
Calculates the distance between two major ticks in user units.

- If the attribute "insertTicks" is false, the value of the attribute "ticksDistance" is returned. The attribute "minTicksDistance" is ignored in this case.
- If the attribute "insertTicks" is true, the attribute "ticksDistance" is ignored. The distance between two major ticks is computed as a 10i, where a is one of {1, 2, 5} and the number a 10i is maximized such that there are approximately 6 major ticks and there are at least "minTicksDistance" pixel between minor ticks. The latter restriction has priority over the number of major ticks.

Returns:
  Number

<private> {String, Object} getLowerAndUpperBounds(coordsZero, type)
Calculate the lower and upper bounds for tick rendering. If JXG.Ticks#includeBoundaries is false, the boundaries will exclude point1 and point2.

Parameters:
{JXG.Coords} coordsZero
type

Returns:
  {String} [type] If type=='ticksdistance', the bounds are the intersection of the line with the bounding box of the board, respecting the value of the line attribute 'margin' and the width of arrow heads. Otherwise, it is the projection of the corners of the bounding box to the line - without the attribute 'margin' and width of arrow heads.
  The first case is needed to determine which ticks are displayed, i.e. where to stop. The second case is to determine the distance between ticks in case of 'insertTicks:true'.
  {Object} {lower: Number, upper: Number } containing the lower and upper bounds in user units.

<private> {Object} getXandYdeltas()
Calculates the x and y distances in user coordinates between two units in user space. In essence, these are cosine and sine. The only work to be done is to determine the direction of the line.

Returns:
  {Object}

<private> {JXG.Coords} getZeroCoordinates()
Returns the coordinates of the point zero of the line. If the line is an Axis, the coordinates of the projection of the board's zero point is returned Otherwise, the coordinates of the point that acts as zero are established depending on the value of JXG.Ticks#anchor

Returns:
  {JXG.Coords} Coords object for the zero point on the line

{Boolean} hasPoint(x, y)
Checks whether (x,y) is near the line. Only available for line elements, not for ticks on curves.

Parameters:
{Number} x
  Coordinate in x direction, screen coordinates.
{Number} y
  Coordinate in y direction, screen coordinates.

Returns:
  {Boolean} True if (x,y) is near the line, False otherwise.

<private> processTickPosition(coordsZero, tickPosition, ticksDelta, deltas)
Auxiliary method used by JXG.Ticks#generateEquidistantTicks to create a tick in the line at the given tickPosition.

Parameters:
{JXG.Coords} coordsZero
  coordinates of the point considered zero
{Number} tickPosition
  current tick position relative to zero
{Number} ticksDelta
  distance between two major ticks in user coordinates
{Object} deltas
  x and y distance between two major ticks

{JXG.Ticks} setPositionDirectly(method, coords, oldcoords)
Sets x and y coordinate of the tick.

Parameters:
{number} method
  The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
{Array} coords
  coordinates in screen/user units
{Array} oldcoords
  previous coordinates in screen/user units

Returns:
  {JXG.Ticks} this element

<private> setTicksSizeVariables(pos)
Sets the variables used to set the height and slope of each tick.

Parameters:
pos

{JXG.Ticks} update()
Recalculate the tick positions and the labels.

Returns:
  {JXG.Ticks}

{JXG.Ticks} updateRenderer()
Uses the boards renderer to update the arc.

Returns:
  {JXG.Ticks} Reference to the object.

<private> {JXG.Ticks} updateRendererLabels()
Updates the label elements of the major ticks.

Returns:
  {JXG.Ticks} Reference to the object.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Oct 02 2024 09:14:36 GMT+0200 (Mitteleuropäische Sommerzeit)