Class Index | File Index

Elements

Classes


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.
Attributes Summary
Field Attributes Field Name and Description
 
Determine the position of the tick with value 0.
 
Draw labels yes/no
 
Draw the zero tick, that lies at line.point1?
 
A function that expects two JXG.Coords, the first one representing the coordinates of the tick that is to be labeled, the second one the coordinates of the center (the tick with position 0).
 
If the distance between two ticks is too big we could insert new ticks.
 
User defined labels for special ticks.
 
Total height of a major tick.
 
The maximum number of characters a tick label can use.
 
Total height of a minor tick.
 
The number of minor ticks between two major ticks.
 
If a label exceeds JXG.Ticks#maxLabelLength this determines the precision used to shorten the tick label.
 
Scale the ticks but not the tick labels.
 
A string that is appended to every tick, used to represent the scale factor given in JXG.Ticks#scaleSymbol.
 
Decides in which direction finite ticks are visible.
 
The default distance between two ticks.
Fields borrowed from class JXG.GeometryElement:
_pos, addEvent, ancestors, baseElement, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getProperty, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, lastDragTime, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, rendNode, scalable, setProperty, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Field Summary
Field Attributes Field Name and Description
 
The board the ticks line is drawn on.
 
Equidistant ticks.
 
Array of fixed ticks.
 
To ensure the uniqueness of label ids this counter is used.
 
A list of labels that are currently unused and ready for reassignment.
 
The line the ticks belong to.
<deprecated>  
Maximum distance between two ticks, measured in pixels.
 
Least distance between two ticks, measured in pixels.
 
A function calculating ticks delta depending on the ticks number.
Fields borrowed from class JXG.GeometryElement:
_pos, addEvent, ancestors, baseElement, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getProperty, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, lastDragTime, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, rendNode, scalable, setProperty, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Method Summary
Method Attributes Method Name and Description
<private>  
_adjustTickDistance(ticksDelta, distScr, factor, p1c, deltaX, deltaY)
<private>  
_makeLabel(pos, newTick, board, drawLabels, id, i, center)
Create a tick label
<private>  
_tickEndings(coords, dx, dy, dxMaj, dyMaj, dxMin, dyMin, major)
 
(Re-)calculates the ticks coordinates.
 
hasPoint(x, y)
Checks whether (x,y) is near the line.
<private>  
Removes the HTML divs of the tick labels before repositioning
 
setPositionDirectly(method, coords, oldcoords)
Sets x and y coordinate of the tick.
 
Recalculate the tick positions and the labels.
 
Uses the boards renderer to update the arc.
Methods borrowed from class JXG.GeometryElement:
_set, addChild, addDescendants, addRotation, addTransform, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getTextAnchor, getType, hideElement, labelColor, noHighlight, normalize, off, on, prepareUpdate, remove, removeChild, removeDescendants, resolveShortcuts, setArrow, setAttribute, setDash, setLabelText, showElement, triggerEventHandlers
Events borrowed from class JXG.GeometryElement:
attribute, attribute:<attribute><attribute>, down, drag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, 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
Attribute Detail
{String} anchor
Determine the position of the tick with value 0. 'left' means point1 of the line, 'right' means point2, and 'middle' is equivalent to the midpoint of the defining points.
Defined in: options.js.
Default Value:
'left'

{Boolean} drawLabels
Draw labels yes/no
Defined in: options.js.
Default Value:
false

{Boolean} drawZero
Draw the zero tick, that lies at line.point1?
Defined in: options.js.
Default Value:
false

{function} generateLabelValue
A function that expects two JXG.Coords, the first one representing the coordinates of the tick that is to be labeled, the second one the coordinates of the center (the tick with position 0).
Defined in: options.js.

{Boolean} insertTicks
If the distance between two ticks is too big we could insert new ticks. If insertTicks is true, we'll do so, otherwise we leave the distance as is. This option is ignored if equidistant is false.
Defined in: options.js.
See:
JXG.Ticks#equidistant
JXG.Ticks#maxTicksDistance
Default Value:
false

{Array} labels
User defined labels for special ticks. Instead of the i-th tick's position, the i-th string stored in this array is shown. If the number of strings in this array is less than the number of special ticks, the tick's position is shown as a fallback.
Defined in: options.js.
Default Value:
[]

{Number} majorHeight
Total height of a major tick. If negative the full height of the board is taken.
Defined in: options.js.

{Number} maxLabelLength
The maximum number of characters a tick label can use.
Defined in: options.js.
See:
JXG.Ticks#precision
Default Value:
3

{Number} minorHeight
Total height of a minor tick. If negative the full height of the board is taken.
Defined in: options.js.

{Number} minorTicks
The number of minor ticks between two major ticks.
Defined in: options.js.

{Number} precision
If a label exceeds JXG.Ticks#maxLabelLength this determines the precision used to shorten the tick label.
Defined in: options.js.
See:
JXG.Ticks#maxLabelLength
Default Value:
3

{Number} scale
Scale the ticks but not the tick labels.
Defined in: options.js.
See:
JXG.Ticks#scaleSymbol
Default Value:
1

{String} scaleSymbol
A string that is appended to every tick, used to represent the scale factor given in JXG.Ticks#scaleSymbol.
Defined in: options.js.
See:
JXG.Ticks#scale
Default Value:
''

{Array} tickEndings
Decides in which direction finite ticks are visible. Possible values are 0=false or 1=true. In case of [0,1] the tick is only visible to the right of the line. In case of [1,0] the tick is only visible to the left of the line.
Defined in: options.js.

{Boolean} ticksDistance
The default distance between two ticks. Please be aware that this value does not have to be used if JXG.Ticks#insertTicks is set to true.
Defined in: options.js.
See:
JXG.Ticks#equidistant
JXG.Ticks#insertTicks
Default Value:
1
Field Detail
{JXG.Board} board
The board the ticks line is drawn on.

{Boolean} equidistant
Equidistant ticks. Distance is defined by ticksFunction

{Array} fixedTicks
Array of fixed ticks.

labelCounter
To ensure the uniqueness of label ids this counter is used.

labelsRepo
A list of labels that are currently unused and ready for reassignment.

{JXG.Line} line
The line the ticks belong to.

{int} maxTicksDistance
Maximum distance between two ticks, measured in pixels. Is used only when insertTicks is set to true.
Deprecated:
This value will be ignored.
See:
#insertTicks

{int} minTicksDistance
Least distance between two ticks, measured in pixels.

{Function} ticksFunction
A function calculating ticks delta depending on the ticks number.
Method Detail
<private> _adjustTickDistance(ticksDelta, distScr, factor, p1c, deltaX, deltaY)
Parameters:
ticksDelta
distScr
factor
p1c
deltaX
deltaY

<private> {JXG.Text} _makeLabel(pos, newTick, board, drawLabels, id, i, center)
Create a tick label
Parameters:
{Number} pos
{JXG.Coords} newTick
{JXG.Board} board
{Boolean} drawLabels
{String} id
Id of the ticks object
{Number} i
{JXG.Coords} center
Returns:
{JXG.Text}

<private> {Array} _tickEndings(coords, dx, dy, dxMaj, dyMaj, dxMin, dyMin, major)
Parameters:
{JXG.Coords} coords
Coordinates of the tick on the line.
{Number} dx
horizontal tick extension in user coordinates.
{Number} dy
vertical tick extension in user coordinates.
{Number} dxMaj
horizontal tick direction in screen coordinates.
{Number} dyMaj
vertical tick direction in screen coordinates.
{Number} dxMin
horizontal tick direction in screen coordinates.
{Number} dyMin
vertical tick direction in screen coordinates.
{Boolean} major
True if tick is major tick.
Returns:
{Array} Array of length 3 containing start and end 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.

calculateTicksCoordinates()
(Re-)calculates the ticks coordinates.

{Boolean} hasPoint(x, y)
Checks whether (x,y) is near the line.
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> removeTickLabels()
Removes the HTML divs of the tick labels before repositioning

{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

{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}

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 27 2013 11:32:44 GMT+0200 (CEST)