Usage
Signature:
interface LedGaugeElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { LedGaugeElement } from "ojs/ojgauge";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojgauge";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Styling
-
CSS Variables
-
metricLabel
-
markerSize
| Name | Type | Description |
|---|---|---|
----oj-gauge-metric-label-font-weight |
<font_weight> | Font weight for metric label. |
| Name | Type | Description |
|---|---|---|
--oj-led-gauge-sm-size |
<length> | Led gauge small size |
--oj-led-gauge-md-size |
<length> | Led gauge medium size |
--oj-led-gauge-lg-size |
<length> | Led gauge large size |
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
contextMenu
-
The contextMenu slot is set on the
oj-menuwithin this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.
To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc of the individual components for details.
Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.
-
tooltipTemplate
-
The
tooltipTemplateslot is used to specify custom tooltip content. The slot content must be a single <template> element. This slot takes precedence over the tooltip.renderer property if specified.When the template is executed, the component's binding context is extended with the following properties:
- $current - an object that contains information for the gauge. (See oj.ojLedGauge.TooltipContext or the table below for a list of properties available on $current)
Attributes
-
border-color :string
-
The border color of the gauge. Only applies when thresholds are not defined. The default value varies based on theme.
Names
Item Name Property borderColorProperty change event borderColorChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-border-color-changed -
color :string
-
The color of the gauge. Only applies when thresholds are not defined. The default value varies based on theme.
Names
Item Name Property colorProperty change event colorChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-color-changed -
label :Object
-
An object defining the label.
Names
Item Name Property labelProperty change event labelChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-changed -
label.style :Partial<CSSStyleDeclaration>
-
The CSS style object defining the style of the label. The following style properties are supported: color, cursor, fontFamily, fontSize, fontStyle, fontWeight, textDecoration.
- Default Value:
{}
Names
Item Name Property label.style -
(nullable) label.text :string
-
The text for the label.
- Default Value:
""
Names
Item Name Property label.text -
marker-size :"sm"|"md"|"lg"|"fit"
-
Specifies the size of the led gauge.
- Default Value:
"fit"
Supported Values:
Value Description fitThe size of the led will be determined based on application styling. If no explicit component size is specified, a default size will be used. lgLarge size, as determined by the theme, will be used for the gauge. mdMedium size, as determined by the theme, will be used for the gauge. smSmall size, as determined by the theme, will be used for the gauge. Names
Item Name Property markerSizeProperty change event markerSizeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-marker-size-changed -
max :number
-
The maximum value of the gauge.
- Default Value:
100
Names
Item Name Property maxProperty change event maxChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-max-changed -
metric-label :Object
-
An object defining the value label.
Names
Item Name Property metricLabelProperty change event metricLabelChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-metric-label-changed -
(nullable) metric-label.converter :oj.Converter.<string>
-
The converter used to format the labels. When using a converter, scaling should be set to none, as the formatted result may not be compatible with the scaling suffixes.
- Default Value:
null
Names
Item Name Property metricLabel.converter -
(nullable) metric-label.rendered :string
-
Defines if the label is rendered.
- Default Value:
"off"
Supported Values:
Value offonNames
Item Name Property metricLabel.rendered -
(nullable) metric-label.scaling :string
-
The scaling behavior of the labels. When using a converter, scaling should be set to none, as the formatted result may not be compatible with the scaling suffixes.
- Default Value:
"auto"
Supported Values:
Value autobillionmillionnonequadrillionthousandtrillionNames
Item Name Property metricLabel.scaling -
metric-label.style :Partial<CSSStyleDeclaration>
-
The CSS style object defining the style of the label. The following style properties are supported: color, cursor, fontFamily, fontSize, fontStyle, fontWeight, textDecoration.
- Default Value:
{}
Names
Item Name Property metricLabel.style -
(nullable) metric-label.text :string
-
The text for the label. If specified, text will overwrite the numeric value that is displayed by default. The converter, scaling, and textType attributes are ignored when text is specified.
- Default Value:
""
Names
Item Name Property metricLabel.text -
(nullable) metric-label.text-type :string
-
Defines whether the label is a number or a percentage of the total value.
- Default Value:
"number"
Supported Values:
Value numberpercentNames
Item Name Property metricLabel.textType -
min :number
-
The minimum value of the gauge.
- Default Value:
0
Names
Item Name Property minProperty change event minChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-min-changed -
rotation :90|180|270|0
-
The rotation angle for the gauge. Useful for changing the direction of triangle or arrow gauges.
- Default Value:
0
Supported Values:
Value 018027090Names
Item Name Property rotationProperty change event rotationChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-rotation-changed -
size :number
-
Fraction of area to use. Values range from 0 to 1.
- Default Value:
1
Names
Item Name Property sizeProperty change event sizeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-size-changed -
svg-class-name :string
-
The CSS style class to apply to the gauge. The style class and inline style will override any other styling specified through the properties. For tooltip interactivity, it's recommended to also pass a representative color to the color attribute.
- Default Value:
""
Names
Item Name Property svgClassNameProperty change event svgClassNameChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-svg-class-name-changed -
svg-style :Partial<CSSStyleDeclaration>
-
The inline style to apply to the gauge. The style class and inline style will override any other styling specified through the properties. For tooltip interactivity, it's recommended to also pass a representative color to the color attribute. Only SVG CSS style properties are supported.
- Default Value:
{}
Names
Item Name Property svgStyleProperty change event svgStyleChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-svg-style-changed -
thresholds :Array.<oj.ojLedGauge.Threshold>
-
An array of objects with the following properties defining the thresholds for the gauge.
- Default Value:
[]
Names
Item Name Property thresholdsProperty change event thresholdsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-thresholds-changed -
tooltip :Object
-
An object containing an optional callback function for tooltip customization.
Names
Item Name Property tooltipProperty change event tooltipChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-tooltip-changed -
tooltip.renderer :((context: ojLedGauge.TooltipContext) => ({insert: Element|string}|{preventDefault: boolean}))
-
A function that returns a custom tooltip. The function takes a tooltip context argument, provided by the gauge, and should return an object that contains only one of the two properties:
- insert: HTMLElement | string - An HTML element, which will be appended to the tooltip, or a tooltip string.
- preventDefault:
true- Indicates that the tooltip should not be displayed. It is not necessary to return {preventDefault:false} to display tooltip, since this is a default behavior.
- Default Value:
null
Names
Item Name Property tooltip.renderer -
track-resize :"on"|"off"
-
Defines whether the element will automatically render in response to changes in size. If set to
off, then the application is responsible for callingrefreshto render the element at the new size.- Default Value:
"on"
Supported Values:
Value offonNames
Item Name Property trackResizeProperty change event trackResizeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-track-resize-changed -
translations :object|null
-
A collection of translated resources from the translation bundle, or
nullif this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.If the component does not contain any translatable resource, the default value of this attribute will be
null. If not, an object containing all resources relevant to the component.If this component has translations, their documentation immediately follows this doc entry.
Names
Item Name Property translationsProperty change event translationsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-translations-changed -
(nullable) translations.accessible-contains-controls :string
-
Used to describe a container that contains controls.
See the translations attribute for usage examples.
- Since:
- 13.0.0
Names
Item Name Property translations.accessibleContainsControls -
(nullable) translations.component-name :string
-
Used to describe the data visualization type for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Gauge"
Names
Item Name Property translations.componentName -
(nullable) translations.label-and-value :string
-
Used to display a label and its value.
See the translations attribute for usage examples.
- Default Value:
"{0}: {1}"
Names
Item Name Property translations.labelAndValue -
(nullable) translations.label-clear-selection :string
-
Text shown for clearing multiple selection on touch devices.
See the translations attribute for usage examples.
- Default Value:
"Clear Selection"
Names
Item Name Property translations.labelClearSelection -
(nullable) translations.label-count-with-total :string
-
Used to display a count out of a total.
See the translations attribute for usage examples.
- Default Value:
"{0} of {1}"
Names
Item Name Property translations.labelCountWithTotal -
(nullable) translations.label-data-visualization :string
-
Label for data visualizations used for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Data Visualization"
Names
Item Name Property translations.labelDataVisualization -
(nullable) translations.label-invalid-data :string
-
Text shown when the component receives invalid data.
See the translations attribute for usage examples.
- Default Value:
"Invalid data"
Names
Item Name Property translations.labelInvalidData -
(nullable) translations.label-no-data :string
-
Text shown when the component receives no data.
See the translations attribute for usage examples.
- Default Value:
"No data to display"
Names
Item Name Property translations.labelNoData -
(nullable) translations.state-collapsed :string
-
Used to describe the collapsed state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Collapsed"
Names
Item Name Property translations.stateCollapsed -
(nullable) translations.state-drillable :string
-
Used to describe a drillable object for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Drillable"
Names
Item Name Property translations.stateDrillable -
(nullable) translations.state-expanded :string
-
Used to describe the expanded state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Expanded"
Names
Item Name Property translations.stateExpanded -
(nullable) translations.state-hidden :string
-
Used to describe the hidden state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Hidden"
Names
Item Name Property translations.stateHidden -
(nullable) translations.state-isolated :string
-
Used to describe the isolated state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Isolated"
Names
Item Name Property translations.stateIsolated -
(nullable) translations.state-maximized :string
-
Used to describe the maximized state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Maximized"
Names
Item Name Property translations.stateMaximized -
(nullable) translations.state-minimized :string
-
Used to describe the minimized state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Minimized"
Names
Item Name Property translations.stateMinimized -
(nullable) translations.state-selected :string
-
Used to describe the selected state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Selected"
Names
Item Name Property translations.stateSelected -
(nullable) translations.state-unselected :string
-
Used to describe the unselected state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Unselected"
Names
Item Name Property translations.stateUnselected -
(nullable) translations.state-visible :string
-
Used to describe the visible state for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Visible"
Names
Item Name Property translations.stateVisible -
type :"arrow"|"diamond"|"square"|"rectangle"|"triangle"|"star"|"human"|"circle"|string
-
The shape of the LED gauge. Can take the name of a built-in shape or the SVG path commands for a custom shape.
- Default Value:
"circle"
Supported Values:
Value Argument arrow<optional>
circle<optional>
diamond<optional>
human<optional>
rectangle<optional>
square<optional>
star<optional>
triangle<optional>
Names
Item Name Property typeProperty change event typeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-type-changed -
value :number|null
-
The metric value.
- Supports writeback:
true
Names
Item Name Property valueProperty change event valueChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-value-changed -
visual-effects :"none"|"auto"
-
Defines whether the theme specific visual effects such as overlays and gradients are applied to the gauge.
- Default Value:
"auto"
Supported Values:
Value autononeNames
Item Name Property visualEffectsProperty change event visualEffectsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-visual-effects-changed
Methods
-
getMetricLabel : {string}
-
Returns the gauge's formatted metric label.
Returns:
The formatted metric label.
- Type
- string
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty. The return type will be the same as the type of the property as specified in this API document. If the method is invoked with an incorrect property/subproperty name, it returns undefined.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. - Since:
- 4.0.0
Returns:
- Type
- any
Example
Get a single subproperty of a complex property:
let subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2'); -
refresh : {void}
-
Refreshes the component.
Returns:
- Type
- void
-
setProperties(properties) : {void}
-
Performs a batch set of properties. The type of value for each property being set must match the type of the property as specified in this API document.
Parameters:
Name Type Description propertiesObject An object containing the property and value pairs to set. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a batch of properties:
myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"}); -
setProperty(property, value) : {void}
-
Sets a property or a subproperty (of a complex property) and notifies the component of the change, triggering a [property]Changed event. The value should be of the same type as the type of the attribute mentioned in this API document.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a single subproperty of a complex property:
myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");
Type Definitions
-
Threshold
-
Properties:
Name Type Argument Description borderColorstring <optional>
The border color of the threshold. colorstring <optional>
The color of the threshold. maxnumber <optional>
The upper bound of the threshold. This value is ignored for the final threshold, which uses the maximum value of the gauge. shortDescstring <optional>
Specific description for the threshold and overwrites the shortDesc specified on gauge. This is used for accessibility and also for customizing the tooltip text. -
TooltipContext