Element: <oj-rating-gauge>

Oracle® JavaScript Extension Toolkit (JET)
5.0.0

E90577-01

QuickNav

Attributes

JET Custom Elements

JET components are implemented as custom HTML elements. In addition to the component attributes documented in this page, JET components also support standard HTML global attributes like id and aria-label.

The JET data binding syntax can be used to define both component and global attributes through the use of dynamically evaluated expressions. All attributes (component and global) support attribute-level binding by prefixing the attribute name with ":" (e.g. :id="[...]"). When using attribute-level binding, all expression values are treated as strings. Additionally, component attributes support property-level binding by using the attribute name directly with no ":" prefix. When using property-level binding, the expressions should evaluate to the types documented by the corresponding attributes. Property-level binding is strongly recommended over attribute-level binding for component attributes.

A detailed description of working with custom HTML elements can be found in: JET Custom Element Usage.


PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

Version:
  • 5.0.0
Since:
  • 0.7
Module:
  • ojgauge

JET Rating Gauge

Rating gauges are typically used to display or accept user feedback on a product or service.


<oj-rating-gauge
  value='4' >
</oj-rating-gauge>

Accessibility

The application is responsible for populating the shortDesc value in the component properties object with meaningful descriptors when the component does not provide a default descriptor. Since component terminology for keyboard and touch shortcuts can conflict with those of the application, it is the application's responsibility to provide these shortcuts, possibly via a help popup.

Touch End User Information

Gesture Action
Press & Hold Display tooltip.
Drag Value change when readonly is false.

Keyboard End User Information

Key Action
Enter Submit the current value of the gauge.
Tab Move focus to next element and submit the current value of the gauge.
Shift + Tab Move focus to previous element.
UpArrow Increase the gauge's transient value. Value is set after using Enter or Tab to submit.
DownArrow Decrease the gauge's transient value. Value is set after using Enter or Tab to submit.
LeftArrow Decrease the gauge's transient value in left-to-right locales. Increase the gauge's transient value in right-to-left locales. Value is set after using Enter or Tab to submit.
RightArrow Increase the gauge's transient value in left-to-right locales. Decrease the gauge's transient value in right-to-left locales. Value is set after using Enter or Tab to submit.

Performance

Tracking Resize

By default, the element will track resizes and render at the new size. This functionality adds a small overhead to the initial render for simple elements like gauges or spark charts, which become noticable when using large numbers of these simple elements. To disable resize tracking, set trackResize to off. The application can manually request a re-render at any time by calling the refresh function.

Reading direction

As with any JET component, in the unusual case that the directionality (LTR or RTL) changes post-init, the component must be refresh()ed.

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.

Slots

JET elements can have up to two types of child content:

  • Any child element with a slot attribute will be moved into that named slot, e.g. <span slot='startIcon'>...</span>. All supported named slots are documented below. Child elements with unsupported named slots will be removed from the DOM.
  • Any child element lacking a slot attribute will be moved to the default slot, also known as a regular child.

contextMenu

The contextMenu slot is set on the oj-menu within 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 and demos 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.

Example

Initialize the component with a context menu:

<oj-some-element>
    <-- use the contextMenu slot to designate this as the context menu for this component -->
    <oj-menu slot="contextMenu" style="display:none" aria-label="Some element's context menu">
...
    </oj-menu>
</oj-some-element>

Attributes

changed :boolean

Whether there has been a value entered by the user.
Default Value:
  • false
Supports writeback:
  • true
Names
Item Name
Property changed
Property change event changedChanged
Property change listener attribute (must be of type function) on-changed-changed

changed-state :Object

The changed shape for the gauge. Displayed after the user has set a value, or when the changed attribute of the data object is set to true.
Default Value:
  • {"borderColor": "", "color": "#ED2C02", "shape": "star", "source": "", "svgClassName": "", "svgStyle": {}}
Names
Item Name
Property changedState
Property change event changedStateChanged
Property change listener attribute (must be of type function) on-changed-state-changed

changed-state.border-color :string

The border color for changed state. Does not apply if a custom image is specified.
Names
Item Name
Property changedState.borderColor

changed-state.color :string

The color for changed state. Does not apply if a custom image is specified.
Names
Item Name
Property changedState.color

(nullable) changed-state.shape :('circle'|'diamond'|'human'|'square'|'star'|'triangle'|string)

The shape to be used. Can take the name of a built-in shape or the svg path commands for a custom shape. Does not apply if a custom image is specified.
Default Value:
  • "star"
Names
Item Name
Property changedState.shape

changed-state.source :string

The URI of the custom image. If specified, it takes precedence over shape. For SVG images, the width and height must be defined on the SVG element as pixels.
Default Value:
  • ""
Names
Item Name
Property changedState.source

changed-state.svg-class-name :string

The CSS style class to apply to the changed state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • ""
Names
Item Name
Property changedState.svgClassName

changed-state.svg-style :Object

The inline style to apply to the changed state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • {}
Names
Item Name
Property changedState.svgStyle

hover-state :Object

The shape that displays on hover.
Default Value:
  • {"borderColor": "", "color": "#007CC8", "shape": "star", "source": "", "svgClassName": "", "svgStyle": {}}
Names
Item Name
Property hoverState
Property change event hoverStateChanged
Property change listener attribute (must be of type function) on-hover-state-changed

hover-state.border-color :string

The border color for hover state. Does not apply if a custom image is specified.
Names
Item Name
Property hoverState.borderColor

hover-state.color :string

The color for hover state. Does not apply if a custom image is specified.
Names
Item Name
Property hoverState.color

(nullable) hover-state.shape :('circle'|'diamond'|'human'|'square'|'star'|'triangle'|string)

The shape to be used. Can take the name of a built-in shape or the svg path commands for a custom shape. Does not apply if a custom image is specified.
Default Value:
  • "star"
Names
Item Name
Property hoverState.shape

hover-state.source :string

The URI of the custom image. If specified, it takes precedence over shape. For SVG images, the width and height must be defined on the SVG element as pixels.
Default Value:
  • ""
Names
Item Name
Property hoverState.source

hover-state.svg-class-name :string

The CSS style class to apply to the hover state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • ""
Names
Item Name
Property hoverState.svgClassName

hover-state.svg-style :Object

The inline style to apply to the hover state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • {}
Names
Item Name
Property hoverState.svgStyle

max :number

Integer value specifying the maximum value of the gauge, which determines the number of shapes or images that are displayed.
Default Value:
  • 5
Names
Item Name
Property max
Property change event maxChanged
Property change listener attribute (must be of type function) on-max-changed

min :number

The minimum value that can be set on the gauge by the end user. Does not affect the value set on the gauge by API.
Default Value:
  • 0
Names
Item Name
Property min
Property change event minChanged
Property change listener attribute (must be of type function) on-min-changed

orientation :string

Defines the type of rating gauge to be rendered.
Supported Values:
Name Type
"horizontal" string
"vertical" string
Default Value:
  • "horizontal"
Names
Item Name
Property orientation
Property change event orientationChanged
Property change listener attribute (must be of type function) on-orientation-changed

preserve-aspect-ratio :string

Specifies whether the images provided should show up at their defined aspect ratio. With 'none', the space is allocated evenly, and shapes could be stretched. With 'meet', The aspect ratio of the shape or image is taken into account when space is allocated. When aspect ratios conflict, the aspect ratio of the selectedState will be used.
Supported Values:
Name Type
"meet" string
"none" string
Default Value:
  • "meet"
Names
Item Name
Property preserveAspectRatio
Property change event preserveAspectRatioChanged
Property change listener attribute (must be of type function) on-preserve-aspect-ratio-changed

readonly :boolean

Defines whether the value of the gauge can be changed by the end user.
Default Value:
  • false
Names
Item Name
Property readonly
Property change event readonlyChanged
Property change listener attribute (must be of type function) on-readonly-changed

selected-state :Object

The selected shape for the gauge.
Default Value:
  • {"borderColor": "", "color": "#F8C15A", "shape": "star", "source": "", "svgClassName": "", "svgStyle": {}}
Names
Item Name
Property selectedState
Property change event selectedStateChanged
Property change listener attribute (must be of type function) on-selected-state-changed

selected-state.border-color :string

The border color for selected state. Does not apply if a custom image is specified.
Names
Item Name
Property selectedState.borderColor

selected-state.color :string

The color for selected state. Does not apply if a custom image is specified.
Names
Item Name
Property selectedState.color

(nullable) selected-state.shape :('circle'|'diamond'|'human'|'square'|'star'|'triangle'|string)

The shape to be used. Can take the name of a built-in shape or the svg path commands for a custom shape. Does not apply if a custom image is specified.
Default Value:
  • "star"
Names
Item Name
Property selectedState.shape

selected-state.source :string

The URI of the custom image. If specified, it takes precedence over shape. For SVG images, the width and height must be defined on the SVG element as pixels.
Default Value:
  • ""
Names
Item Name
Property selectedState.source

selected-state.svg-class-name :string

The CSS style class to apply to the selected state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • ""
Names
Item Name
Property selectedState.svgClassName

selected-state.svg-style :Object

The inline style to apply to the selected state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • {}
Names
Item Name
Property selectedState.svgStyle

step :number

Specifies the increment by which values can be specified by the end user.
Supported Values:
Name Type
0.5 number
1 number
Default Value:
  • 1
Names
Item Name
Property step
Property change event stepChanged
Property change listener attribute (must be of type function) on-step-changed

thresholds :Array.<oj.ojRatingGauge.Threshold>

An array of objects with the following properties defining the thresholds for the gauge.
Default Value:
  • []
Names
Item Name
Property thresholds
Property change event thresholdsChanged
Property change listener attribute (must be of type function) on-thresholds-changed

tooltip :Object

An object containing an optional callback function for tooltip customization.
Default Value:
  • {"renderer": null}
Names
Item Name
Property tooltip
Property change event tooltipChanged
Property change listener attribute (must be of type function) on-tooltip-changed

tooltip.renderer :((context: oj.ojRatingGauge.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 :string

Defines whether the element will automatically render in response to changes in size. If set to off, then the application is responsible for calling refresh to render the element at the new size.
Supported Values:
Name Type
"off" string
"on" string
Default Value:
  • "on"
Names
Item Name
Property trackResize
Property change event trackResizeChanged
Property change listener attribute (must be of type function) on-track-resize-changed
Examples

Initialize the data visualization element with the track-resize attribute specified:

<oj-some-dvt track-resize='off'></oj-some-dvt>

Get or set the trackResize property after initialization:

// getter
var value = myComponent.trackResize;

// setter
myComponent.trackResize="off";

(readonly) transient-value :number|null

PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

The transientValue is the read-only property for retrieving the transient value from the rating gauge. It is triggered when hovering over the rating gauge.

This is a read-only property so page authors cannot set or change it directly.

Supports writeback:
  • true
Since:
  • 4.2.0
Names
Item Name
Property transientValue
Property change event transientValueChanged
Property change listener attribute (must be of type function) on-transient-value-changed

translations :Object|null

A collection of translated resources from the translation bundle, or null if 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 translations
Property change event translationsChanged
Property change listener attribute (must be of type function) on-translations-changed
Examples

Initialize the component, overriding some translated resources and leaving the others intact:

<!-- Using dot notation -->
<oj-some-element translations.some-key='some value' translations.some-other-key='some other value'></oj-some-element>

<!-- Using JSON notation -->
<oj-some-element translations='{"someKey":"some value", "someOtherKey":"some other value"}'></oj-some-element>

Get or set the translations property after initialization:

// Get one
var value = myComponent.translations.someKey;

// Set one, leaving the others intact. Always use the setProperty API for 
// subproperties rather than setting a subproperty directly.
myComponent.setProperty('translations.someKey', 'some value');

// Get all
var values = myComponent.translations;

// Set all.  Must list every resource key, as those not listed are lost.
myComponent.translations = {
    someKey: 'some value',
    someOtherKey: 'some other value'
};

(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

unselected-state :Object

The unselected shape for the gauge.
Default Value:
  • {"borderColor": "", "color": "#C4CED7", "shape": "star", "source": "", "svgClassName": "", "svgStyle": {}}
Names
Item Name
Property unselectedState
Property change event unselectedStateChanged
Property change listener attribute (must be of type function) on-unselected-state-changed

unselected-state.border-color :string

The border color for unselected state. Does not apply if a custom image is specified.
Names
Item Name
Property unselectedState.borderColor

unselected-state.color :string

The color for unselected state. Does not apply if a custom image is specified.
Names
Item Name
Property unselectedState.color

(nullable) unselected-state.shape :('circle'|'diamond'|'human'|'square'|'star'|'triangle'|string)

The shape to be used. Can take the name of a built-in shape or the svg path commands for a custom shape. Does not apply if a custom image is specified.
Default Value:
  • "star"
Names
Item Name
Property unselectedState.shape

unselected-state.source :string

The URI of the custom image. If specified, it takes precedence over shape. For SVG images, the width and height must be defined on the SVG element as pixels.
Default Value:
  • ""
Names
Item Name
Property unselectedState.source

unselected-state.svg-class-name :string

The CSS style class to apply to the unselected state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • ""
Names
Item Name
Property unselectedState.svgClassName

unselected-state.svg-style :Object

The inline style to apply to the unselected state. The style class and inline style will override any other styling specified through the properties. Does not apply if custom image is specified.
Default Value:
  • {}
Names
Item Name
Property unselectedState.svgStyle

value :number|null

The value set on the gauge.
Supports writeback:
  • true
Names
Item Name
Property value
Property change event valueChanged
Property change listener attribute (must be of type function) on-value-changed

visual-effects :string

Defines whether visual effects such as overlays are applied to the gauge.
Supported Values:
Name Type
"auto" string
"none" string
Default Value:
  • "auto"
Names
Item Name
Property visualEffects
Property change event visualEffectsChanged
Property change listener attribute (must be of type function) on-visual-effects-changed

Methods

getProperty(property) → {*}

Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description
property string The property name to get. Supports dot notation for subproperty access.
Since:
  • 4.0.0
Returns:
Type
*
Example

Get a single subproperty of a complex property:

var subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2');

refresh() → {void}

Refreshes the component.
Returns:
Type
void

setProperties(properties) → {void}

Performs a batch set of properties.
Parameters:
Name Type Description
properties Object 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 single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description
property string The property name to set. Supports dot notation for subproperty access.
value * 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
borderColor string <optional>
The border color of the threshold.
color string <optional>
The color of the threshold.
max number <optional>
The upper bound of the threshold. This value is ignored for the final threshold, which uses the maximum value of the gauge.
shortDesc string <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

Properties:
Name Type Description
color string The indicator color of the gauge.
componentElement Element The rating gauge HTML element.
label string The computed metric label.
parentElement Element The tooltip element. The function can directly modify or append content to this element.