Usage (signatures)
board.create('smartlabel', [element, textopt]);
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
element |
JXG.GeometryElement | GeometryElements: point, line, circle, polygon, angle. |
|
text |
String | function |
<optional> |
Optional text. In case, this content is not the empty string, the measurement is overwritten by this text. |
Examples
var p1 = board.create('point', [3, 4], {showInfobox: false, withLabel: false});
board.create('smartlabel', [p1], {digits: 1, baseUnit: 'm', dir: 'col', useMathJax: false});
var s1 = board.create('line', [[-7, 2], [6, -6]], {point1: {visible:true}, point2: {visible:true}});
board.create('smartlabel', [s1], {baseUnit: 'm', measure: 'length', prefix: 'L = ', useMathJax: false});
board.create('smartlabel', [s1], {baseUnit: 'm', measure: 'slope', prefix: 'Δ = ', useMathJax: false});
var c1 = board.create('circle', [[0, 1], [4, 1]], {point2: {visible: true}});
board.create('smartlabel', [c1], {baseUnit: 'm', measure: 'perimeter', prefix: 'U = ', useMathJax: false});
board.create('smartlabel', [c1], {baseUnit: 'm', measure: 'area', prefix: 'A = ', useMathJax: false});
board.create('smartlabel', [c1], {baseUnit: 'm', measure: 'radius', prefix: 'R = ', useMathJax: false});
var p2 = board.create('polygon', [[-6, -5], [7, -7], [-4, 3]], {});
board.create('smartlabel', [p2], {
baseUnit: 'm',
measure: 'area',
prefix: 'A = ',
cssClass: 'smart-label-pure smart-label-polygon',
highlightCssClass: 'smart-label-pure smart-label-polygon',
useMathJax: false
});
board.create('smartlabel', [p2, () => 'X: ' + p2.vertices[0].X().toFixed(1)], {
measure: 'perimeter',
cssClass: 'smart-label-outline smart-label-polygon',
highlightCssClass: 'smart-label-outline smart-label-polygon',
useMathJax: false
});
var a1 = board.create('angle', [[1, -1], [1, 2], [1, 5]], {name: 'β', withLabel: false});
var sma = board.create('smartlabel', [a1], {digits: 1, prefix: a1.name + '=', baseUnit: '°', useMathJax: false});
Attributes
Own
baseUnit
- Description
This specifies the unit of measurement in dimension 1 (e.g. length). A power is automatically added to the string. If you want to use different units for each dimension, see Smartlabel#units.
- Type
- String
- Default Value
- ''
- See
- Source
- options.js, line 9531
cssClass
- Description
CSS classes for the smart label. Available classes are:
- 'smart-label-solid'
- 'smart-label-outline'
- 'smart-label-pure'
By default, an additional class is given specific for the element type. Available classes are 'smart-label-angle', 'smart-label-circle', 'smart-label-line', 'smart-label-point', 'smart-label-polygon'.
- Type
- String
- Overrides
- JXG.Text#cssClass
- Default Value
- 'smart-label-solid smart-label-circle' for circles - 'smart-label-solid smart-label-point' for points - ...- See
- Example
-
cssClass: 'smart-label-solid smart-label-point' - Source
- options.js, line 9476
dir
- Description
Display of point coordinates either as row vector or column vector. Available values are 'row' or 'column'.
- Type
- String
- Default Value
- 'row'
- Source
- options.js, line 9721
formatValue
- Description
Function to format the value. If set to null, no formatting will happen.
- Type
- function
- Default Value
- null
- Source
- options.js, line 9598
highlightCssClass
- Description
CSS classes for the smart label when highlighted.
- Type
- String
- Overrides
- JXG.Text#highlightCssClass
- Default Value
- 'smart-label-solid smart-label-circle' for circles - 'smart-label-solid smart-label-point' for points - ...- See
- Source
- options.js, line 9502
measure
- Description
Type of measurement. Available values are:
- 'deg', 'rad' for angles
- 'area', 'perimeter', 'radius' for circles
- 'length', 'slope' for lines
- 'area', 'perimeter' for polygons
Dependent on this value, i.e. the type of measurement, the label is positioned differently on the object.
- Type
- String
- Default Value
- 'radius' for circles - 'length' for lines - 'area' for polygons - 'deg' for angles- Source
- options.js, line 9612
orientation
- Description
Orientation of the smartlabel relative to the line. Available values are:
- 'parallel' (default)
- 'parallel-inverted' / 'inverted'
- 'orthogonal'
- 'orthogonal-inverted'
- 'none' (smartlabe is always horizontal)
Dependent on this value the label is positioned differently on the line.
- Type
- String
- Default Value
- 'parallel'
- Source
- options.js, line 9672
prefix
- Description
Prefix text for the smartlabel. Comes before the measurement value.
- Type
- String | function
- Default Value
- ''
- Source
- options.js, line 9578
showPrefix
- Description
Determines whether a prefix is displayed before the measurement value and unit.
- Type
- Boolean
- Default Value
- true
- See
- Source
- options.js, line 9557
showSuffix
- Description
Determines whether a suffix is displayed after the measurement value and unit.
- Type
- Boolean
- Default Value
- true
- See
- Source
- options.js, line 9568
suffix
- Description
Suffix text for the smartlabel. Comes after unit.
- Type
- String | function
- Default Value
- ''
- Source
- options.js, line 9588
unit
- Description
Measurement unit appended to the output text. For areas, the unit is squared automatically. Replaced by the attributes "baseUnit" and "units".
- Type
- String | function
- Deprecated
- Yes
- Default Value
- ''
- See
- Source
- options.js, line 9517
units
- Description
This attribute expects an object that has the dimension numbers as keys (as integer or in the form of 'dimxx') and assigns a string to each dimension. If a dimension has no specification, Smartlabel#baseUnit is used.
- Type
- Object
- Default Value
- {}
- See
- Source
- options.js, line 9544
visibleThreshold
- Description
Smartlabels of circles and lines are hidden automatically, if there is not enough space. This value (between 0 and 1) controls, how much percent of the line length or circle diameter the label is allowed to take place
- Type
- String
- Default Value
- 0.7 for lines - 0.6 for angles- Source
- options.js, line 9691
Inherited
Members
Own
none
Inherited
Events
Own
none
Inherited
Throws
-
If the element cannot be constructed with the given parent objects an exception is thrown.
- Type
- Error
Details
- Type
- JXG.Text
- Source
- element/smartlabel.js, line 40