Usage
Signature:
interface CLegendElement<K extends string | number,D extends oj-c.Legend.Item<K> | oj-c.Legend.Section<K> | any>
Typescript Import Format
//To typecheck the element APIs, import as below.
import { CLegendElement } from "oj-c/legend";
//For the transpiled javascript to load the element's module, import as below
import "oj-c/legend";
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.
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.
-
itemTemplate
-
The
itemTemplateslot is used to specify the template for creating items of the legend. The slot content must be wrapped in a <template> element. The content of the template should be a single <oj-c-legend-item> element. See the oj-c-legend-item doc for more details.When the template is executed for each area, it will have access to the components's binding context containing the following properties:
- $current - an object that contains information for the current node. (See the table below for a list of properties available on $current)
- alias - if data-oj-as attribute was specified, the value will be used to provide an application-named alias for $current.
Properties of $current:
Name Type Argument Description dataD The data object of the current item. indexnumber The zero-based index of the current item relative to the parent. keyK The key of the current item. parentDataArray<D> <optional>
An array of data objects of the outermost to innermost parents of the node parentKeyK <optional>
The key of the parent node -
sectionTemplate
-
The
sectionTemplateslot is used to specify the template for creating sections of the legend. The slot content must be wrapped in a <template> element. The content of the template should be a single <oj-c-legend-section> element. See the oj-c-legend-section doc for more details.When the template is executed for each area, it will have access to the components's binding context containing the following properties:
- $current - an object that contains information for the current node. (See the table below for a list of properties available on $current)
- alias - if data-oj-as attribute was specified, the value will be used to provide an application-named alias for $current.
Properties of $current:
Name Type Description dataD The data object of the current section. indexnumber The zero-based index of the current section. keyK The key of the current section.
Attributes
-
context-menu-config :oj-c.Legend.LegendContextMenuConfig.<K, D>
-
Specifies a context menu configuration. It takes the keys `accessibleLabel` and `items`, where `accessibleLabel` is optional and items required .`items` function returns an array of menu item object representations that indicates what menu items are going to be part of menu based on some specific context menu context.
Context Menu Item Type Def ContextMenuSeparator { type: 'separator'} MenuItem { type?: 'item'; label: string; key: string; disabled?: boolean; onAction?: () => void; startIcon?: MenuIcon; endIcon?: MenuIcon; variant?: 'standard' | 'destructive'; }; ContextMenuSubMenu { type: 'submenu'; label?: string; disabled?: boolean; startIcon?: string; items?: Array<ContextMenuItems>; }; ContextMenuSelectSingle { type: 'selectsingle'; key?: string; items?: Array<MenuSelectItem>; selection?: string; onSelection?: (detail: { value: string }) => void; }; ContextMenuSelectMultiple { type: 'selectmultiple'; key?: string; items?: Array<MenuSelectItem>; selection?: Array<string>; onSelection?: (detail: { value: Array<string> }) => void; }; MenuIcon { type?: 'class'; class: string; } | { type: 'img'; src: string; }; MenuSelectItem { label: string; disabled?: boolean; endIcon?: MenuIcon; value: string; } Names
Item Name Property contextMenuConfigProperty change event contextMenuConfigChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-context-menu-config-changed -
data :(DataProvider.<K, D>|null)
-
The DataProvider for the sections and items of the legend. It should provide a data tree where each node in the data tree corresponds to a section or item in the legend. Nodes that are leaves will be treated as items. The row key will be used as the id for legend sections and items. The DataProvider can either have data shape specified by oj-c-legend-item (or oj-c-legend-section) as its data shape, in which case no template is required or it can have an arbitrary data shape, in which case an oj-c-legend-item element (and oj-c-legend-section element for hierarchical data) must be specified in the itemTemplate (and sectionTemplate) slot
- Default Value:
null
Names
Item Name Property dataProperty change event dataChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-data-changed -
drilling :"on"|"off"
-
Whether drilling is enabled on all legend items. Drillable objects will show a background opacity, a pointer cursor on hover, and fire ojDrill event on click.
- Default Value:
"off"
Supported Values:
Value Description offLegend items will not be drillable onLegend items will be drillable Names
Item Name Property drillingProperty change event drillingChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-drilling-changed -
halign :"center"|"end"|"start"
-
Defines the horizontal alignment of the legend contents.
- Default Value:
"start"
Supported Values:
Value Description centerLegend contents will be center aligned endLegend contents will be end aligned startLegend contents will be start aligned Names
Item Name Property halignProperty change event halignChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-halign-changed -
hidden-categories :Array<string>
-
An array of categories that will be hidden.
- Default Value:
[]
- Supports writeback:
true
Names
Item Name Property hiddenCategoriesProperty change event hiddenCategoriesChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-hidden-categories-changed -
hide-and-show-behavior :"on"|"off"
-
Defines whether the legend can be used to initiate hide and show behavior on referenced data items.
- Default Value:
"off"
Supported Values:
Value Description offlegend cannot be used to initiate hide and show behavior on referenced data items. onLegend can be used to initiate hide and show behavior on referenced data items. Names
Item Name Property hideAndShowBehaviorProperty change event hideAndShowBehaviorChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-hide-and-show-behavior-changed -
highlighted-categories :Array<string>
-
An array of categories that will be highlighted.
- Default Value:
[]
- Supports writeback:
true
Names
Item Name Property highlightedCategoriesProperty change event highlightedCategoriesChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-highlighted-categories-changed -
hover-behavior :"dim"|"none"
-
Defines the behavior applied when hovering over a legend item.
- Default Value:
"none"
Supported Values:
Value Description dimDimming hover behavior is applied. noneNo hover behavior will be applied. Names
Item Name Property hoverBehaviorProperty change event hoverBehaviorChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-hover-behavior-changed -
orientation :"horizontal"|"vertical"
-
Defines the orientation of the legend, which determines the direction in which the legend items are laid out.
- Default Value:
"vertical"
Supported Values:
Value Description horizontalLegend items will be horizontally placed in available space. verticalLegend items will be vertically stacked. Names
Item Name Property orientationProperty change event orientationChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-orientation-changed -
section-title-halign :"center"|"end"|"start"
-
The horizontal alignment of the section titles.
- Default Value:
"start"
Supported Values:
Value Description centerThe section title will be center aligned. endThe section title will be end aligned. startThe section title will be start aligned. Names
Item Name Property sectionTitleHalignProperty change event sectionTitleHalignChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-section-title-halign-changed -
section-title-style :Partial<Pick<CSSStyleDeclaration, "color" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "textDecoration">>
-
The CSS style object defining the style of the section titles' text. The following style properties are supported: color, fontFamily, fontSize, fontStyle, fontWeight, textDecoration
Names
Item Name Property sectionTitleStyleProperty change event sectionTitleStyleChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-section-title-style-changed -
section-title-style.color :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/color)
Names
Item Name Property sectionTitleStyle.color -
section-title-style.font-family :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-family)
Names
Item Name Property sectionTitleStyle.fontFamily -
section-title-style.font-size :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-size)
Names
Item Name Property sectionTitleStyle.fontSize -
section-title-style.font-style :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-style)
Names
Item Name Property sectionTitleStyle.fontStyle -
section-title-style.font-weight :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-weight)
Names
Item Name Property sectionTitleStyle.fontWeight -
section-title-style.text-decoration :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration)
Names
Item Name Property sectionTitleStyle.textDecoration -
symbol-height :number
-
The height of the legend symbol in pixels. If the value is 0, it will take the same value as symbolWidth. If both symbolWidth and symbolHeight are 0, then it will use a default value that may vary based on theme.
- Default Value:
0
Names
Item Name Property symbolHeightProperty change event symbolHeightChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-symbol-height-changed -
symbol-width :number
-
The width of the legend symbol in pixels. If the value is 0, it will take the same value as symbolHeight. If both symbolWidth and symbolHeight are 0, then it will use a default value that may vary based on theme
- Default Value:
0
Names
Item Name Property symbolWidthProperty change event symbolWidthChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-symbol-width-changed -
text-style :Partial<Pick<CSSStyleDeclaration, "color" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "textDecoration">>
-
The CSS style object defining the style of the legend item text.
Names
Item Name Property textStyleProperty change event textStyleChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-text-style-changed -
text-style.color :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/color)
Names
Item Name Property textStyle.color -
text-style.font-family :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-family)
Names
Item Name Property textStyle.fontFamily -
text-style.font-size :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-size)
Names
Item Name Property textStyle.fontSize -
text-style.font-style :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-style)
Names
Item Name Property textStyle.fontStyle -
text-style.font-weight :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-weight)
Names
Item Name Property textStyle.fontWeight -
text-style.text-decoration :string
-
[MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration)
Names
Item Name Property textStyle.textDecoration -
valign :"middle"|"bottom"|"top"
-
Defines the vertical alignment of the legend contents.
- Default Value:
"top"
Supported Values:
Value Description bottomThe legend items will be bottom aligned. middleThe legend items will be middle aligned. topThe legend items will be top aligned. Names
Item Name Property valignProperty change event valignChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-valign-changed
Events
-
ojContextMenuAction
-
Triggered when a menu item is clicked, whether by keyboard, mouse, or touch events.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type contextMenuContext{ type: 'background'; } | { data?: oj-c.Legend.Item<K>; itemData?: D; itemIndexPath: Array<number>; type: 'item'; } menuItemKeystring -
ojContextMenuSelection
-
Triggered when a select menu item is clicked, whether by keyboard, mouse, or touch events.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type contextMenuContext{ type: 'background'; } | { data?: oj-c.Legend.Item<K>; itemData?: D; itemIndexPath: Array<number>; type: 'item'; } menuSelectionGroupKeystring valuestring|Array<string> -
ojDrill
-
Triggered during a drill gesture (single click on the legend item).
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description idK The id of the drilled item
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesobject An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
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. Returns:
- Type
- void
Type Definitions
Documentation-only Types
Note: Type definitions in this section have been provided for documentation purposes and cannot be imported into application code.
-
ContextMenuItems :(oj-c.Legend.MenuItem|oj-c.Legend.ContextMenuSeparator|oj-c.Legend.ContextMenuSubMenu|oj-c.Legend.ContextMenuSelectSingle|oj-c.Legend.ContextMenuSelectMultiple)
-
-
ContextMenuSelectMultiple
-
Properties:
Name Type Argument Description itemsArray.<oj-c.Legend.MenuSelectItem> <optional>
Specifies the array of select items that make up the select multiple. keystring A unique key associated with the select multiple. onSelection(detail: oj-c.Legend.SelectMenuItemDetail<string[]>) => void <optional>
selectionArray<string> <optional>
type"selectmultiple" Specifies a select multiple menu item. -
ContextMenuSelectSingle
-
Properties:
Name Type Argument Description itemsArray.<oj-c.Legend.MenuSelectItem> <optional>
Specifies the array of select items that make up the select single. keystring A unique key associated with the select single. onSelection(detail: oj-c.Legend.SelectMenuItemDetail<string>) => void <optional>
selectionstring <optional>
type"selectsingle" Specifies a select single menu item. -
ContextMenuSeparator
-
Properties:
Name Type type"separator" -
ContextMenuSubMenu
-
Properties:
Name Type Argument Description disabledboolean <optional>
Specifies if the submenu is disabled (enabled by default). itemsArray<string | oj-c.Legend.MenuItem | oj-c.Legend.ContextMenuSeparator | oj-c.Legend.ContextMenuSubMenu | oj-c.Legend.ContextMenuSelectSingle | oj-c.Legend.ContextMenuSelectMultiple> <optional>
keystring <optional>
A unique key associated with the submenu menu item. labelstring <optional>
The submenu label. startIconstring <optional>
Optional icon to render at the start of the submenu. type"submenu" Specifies a submenu menu item. -
Item<K>
-
Object type that defines a legend data item.
Properties:
Name Type Argument Description borderColorstring <optional>
The border color of the marker. Only applies if symbolType is "marker" or "lineWithMarker categoriesArray<string> <optional>
An array of categories for the legend item. Legend items currently only support a single category. colorstring <optional>
The color of the legend symbol (line or marker). When symbolType is "lineWithMarker", this attribute defines the line color and the markerColor attribute defines the marker color. drilling"inherit" | "off" | "on" <optional>
Whether drilling is enabled on the legend item. Drillable objects will show a pointer cursor on hover and fire ojDrill event on click. To enable drilling for all legend items at once, use the drilling attribute in the top level. idK The id of the legend item. lineStyle"dashed" | "solid" | "dotted" <optional>
The line style. Only applies when the symbolType is "line" or "lineWithMarker". lineWidthnumber <optional>
The line width in pixels. Only applies when the symbolType is "line" or "lineWithMarker. markerColorstring <optional>
The color of the marker, if different than the line color. Only applies if the symbolType is "lineWithMarker". markerShape"square" | "circle" | "ellipse" | "diamond" | "human" | "plus" | "star" | "triangleDown" | "triangleUp" | "rectangle" <optional>
The shape of the marker. Only applies if symbolType is "marker" or "lineWithMarker". Does not apply if a custom image is specified. shortDescstring <optional>
The description of this legend item. This is used for accessibility and for customizing the tooltip text. sourcestring <optional>
The URI of the image of the legend symbol. symbolType"marker" | "image" | "line" | "lineWithMarker" <optional>
The type of legend symbol to display. textstring The legend item text. Also used as item aria label if short-desc is not provided. -
LegendContextMenuConfig<K,D>
-
Properties:
Name Type Argument accessibleLabelstring <optional>
items(context: LegendContextMenuContext<K, D>) => Array<oj-c.Legend.ContextMenuItems> -
MenuItem
-
Specifies a standard menu item.
Properties:
Name Type Argument Description disabledboolean <optional>
Specifies if the menu item is disabled (enabled by default). endIcon{ type?: 'class'; class: string; } | { type: 'img'; src: string; } <optional>
Optional icon to render at the end of the menu item. keystring A unique key associated with the menu item. labelstring The menu item label. onActionfunction <optional>
Optional callback function associated with the menu item. startIcon{ type?: 'class'; class: string; } | { type: 'img'; src: string; } <optional>
Optional icon to render at the start of the menu item. type"item" <optional>
Specifies a standard menu item. variant"standard" | "destructive" <optional>
Specifies the menu item behavior. -
MenuSelection
-
Properties:
Name Type Description at(index: number) => string | undefined Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array. -
MenuSelectItem
-
Specifies a selectable item in a menu item.
Properties:
Name Type Argument Description disabledboolean <optional>
Specifies if the selectable item is disabled (enabled by default). endIcon{ type?: 'class'; class: string; } | { type: 'img'; src: string; } <optional>
Optional icon to render at the end of the selectable item. labelstring The selectable item label. valuestring The value associated with the selectable item. -
Section<K>
-
Object type that defines a section data item.
Properties:
Name Type Description idK The id of the legend section. For the DataProvider case, the key for the node will be used as the id. itemsArray.<oj-c.Legend.Item.<K>> The id of the legend section. For the DataProvider case, the key for the node will be used as the id. titlestring The title of the legend section. -
SelectMenuItemDetail<T extends oj-c.Legend.MenuSelection>
-
Properties:
Name Type menuSelectionGroupKeystring valueT