Usage (signatures)
board.create('measurement', [x, y, expression]);
Here, expression is a prefix expression, see JXG.PrefixParser.
Parameters
| Name | Type | Description |
|---|---|---|
x |
PointLike | |
y |
PointLike | |
expression |
Array |
Examples
var p1 = board.create('point', [1, 1]);
var p2 = board.create('point', [1, 3]);
var ci1 = board.create('circle', [p1, p2]);
var m1 = board.create('measurement', [1, -2, ['Area', ci1]], {
visible: true,
prefix: 'area: ',
baseUnit: 'cm'
});
var m2 = board.create('measurement', [1, -4, ['Radius', ci1]], {
prefix: 'radius: ',
baseUnit: 'cm'
});
var p1 = board.create('point', [1, 1]);
var p2 = board.create('point', [1, 3]);
var ci1 = board.create('circle', [p1, p2]);
var seg = board.create('segment', [[-2,-3], [-2, 3]], { firstArrow: true, lastArrow: true});
var sli = board.create('slider', [[-4, 4], [-1.5, 4], [-10, 1, 10]], {name:'a'});
var m1 = board.create('measurement', [-6, -2, ['Radius', ci1]], {
prefix: 'm1: ',
baseUnit: 'cm'
});
var m2 = board.create('measurement', [-6, -4, ['L', seg]], {
prefix: 'm2: ',
baseUnit: 'cm'
});
var m3 = board.create('measurement', [-6, -6, ['V', sli]], {
prefix: 'm3: ',
baseUnit: 'cm',
dim: 1
});
var m4 = board.create('measurement', [2, -6,
['+', ['V', m1], ['V', m2], ['V', m3]]
], {
prefix: 'm4: ',
baseUnit: 'cm'
});
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 Measurement#units.
- Type
- String
- Default Value
- ''
- See
- Example
-
var p1 = board.create("point", [0,1]), p2 = board.create("point", [3,1]), c = board.create("circle", [p1, p2]); board.create("measurement", [-2, -3, ["Perimeter", c]], { baseUnit: " m" }); board.create("measurement", [1, -3, ["Area", c]], { baseUnit: " m" }); - Source
- options.js, line 7476
dim
- Description
Dimension of the measured data. This measurement can only be combined with a measurement of a suitable dimension. Overwrites the dimension returned by the Dimension() method. Normally, the default value null is used here to automatically determine the dimension.
However, if the coordinates or a direction vector are measured, the value is usually returned as an array. To tell the measurement that the function Measurement#formatCoords or Measurement#formatDirection should be used to display the array properly, 'coords' or 'direction' must be specified here.
- Type
- Number | 'coords' | 'direction'
- Default Value
- null
- See
- Source
- options.js, line 7625
formatCoords
- Description
Function to format coordinates. Does only have an effect, if Measurement#dim is set to 'coords'.
- Type
- function
- See
- Example
-
var p = board.create("point", [-2, 0]); board.create("measurement", [0, -3, ["Coords", p]], { dim: 'coords', formatCoords: function (_,x,y,z) { if (parseFloat(z) !== 1) return 'Infinit coords'; else return '(' + x + ' | ' + y + ')'; } }); - Source
- options.js, line 7643
formatDirection
- Description
Function to format direction vector. Does only have an effect, if Measurement#dim is set to 'direction'.
- Type
- function
- Example
-
var p1 = board.create("point", [0,1]), p2 = board.create("point", [3,1]), s = board.create("segment", [p1, p2]); board.create("measurement", [0, -2, ["Direction", s]], { dim: 'direction', formatDirection: function (self,x,y) { return '\\[\\frac{' + y + '}{' + x + '} = ' + (!isFinite(y/x) ? '\\infty' : JXG.toFixed(y/x, self.visProp.digits)) + '\\]'; }, useMathJax: true }); - Source
- options.js, line 7695
prefix
- Description
String that is displayed before the measurement and its unit.
- Type
- String
- Default Value
- ''
- See
- Source
- options.js, line 7603
showPrefix
- Description
Determines whether a prefix is displayed before the measurement value and unit.
- Type
- Boolean
- Default Value
- true
- See
- Source
- options.js, line 7581
showSuffix
- Description
Determines whether a suffix is displayed after the measurement value and unit.
- Type
- Boolean
- Default Value
- true
- See
- Source
- options.js, line 7592
suffix
- Description
String that is displayed after the measurement and its unit.
- Type
- String
- Default Value
- ''
- See
- Source
- options.js, line 7614
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, Measurement#baseUnit is used.
- Type
- Object
- Default Value
- {}
- See
- Example
-
var p1 = board.create("point", [0,1]), p2 = board.create("point", [3,1]), c = board.create("circle", [p1, p2]); board.create("measurement", [-3, -3, ["Perimeter", c]], { baseUnit: " m", units: { 1: " length unit", 2: " area unit" }, }); board.create("measurement", [1, -3, ["Area", c]], { baseUnit: " m", units: { dim1: " length unit", dim2: " area unit" }, }); - Source
- options.js, line 7521
Inherited
none
Throws
-
If the element cannot be constructed with the given parent objects an exception is thrown.
- Type
- Exception
Details
- Type
- JXG.Text
- Source
- element/measure.js, line 201