new ScaleBar(pixelSize, viewer [, options])
Creates a new ScaleBar instance.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pixelSize |
number | Size of a pixel in real-world units (in mm) |
|||||||||||||||||||||
viewer |
Viewer | The OpenLIME viewer instance |
|||||||||||||||||||||
options |
Object |
<optional> |
Configuration options Properties
|
- Source:
Properties:
Name | Type | Description |
---|---|---|
svg |
SVGElement | Main SVG container element |
line |
SVGElement | Scale bar line element |
text |
SVGElement | Scale text element |
lastScaleZoom |
number | Last zoom level where scale was updated |
Extends
Methods
-
format(d [, unit])
-
Formats a measurement value with appropriate units. Automatically selects the best unit if none specified.
Parameters:
Name Type Argument Description d
number Value to format (in millimeters)
unit
string <optional>
Specific unit to use for formatting
- Inherited From:
- Overrides:
- Source:
Returns:
Formatted measurement with units (e.g., "5.00 mm" or "1.00 m")
- Type
- string
Example
const units = new Units(); units.format(1500); // Returns "1.50 m" units.format(1500, 'mm'); // Returns "1500.00 mm"