# Widget Class
Defines widget behavior attributes.
# Properties
| Name | Type | Description |
|---|---|---|
oid | string | The widget's unique ID |
title | string | The widget's title |
Type | string | The widget's type |
manifest | WidgetManifest | The widget's manifest JSON |
datasource | Datasource | The widget's data source |
metadata | WidgetMetadata | The widget's meta-data object |
options | object | The widget's options object |
style | object | The widget style object |
initialized | boolean | Whether the widget was initialized |
refreshing | boolean | Whether the widget is refreshing |
queryResult | queryResult | Contains the last processed query result |
rawQueryResult | rawQueryResult | Contains the last raw query result |
$dashboard | Dashboard | A reference to the dashboard containing the widget |
indicatorInstance | IndicatorInstance | Only for indicator widgets |
$$events | EventsCollection | Contains all available events for the dashboard and their handlers |
# Methods
# refresh
refresh() → Promise
Refreshes the widget.
Arguments
N/A
Returns
A Promise that resolves when the widget has refreshed
Example
widget.refresh().then(function () {
console.log('widget is refreshed');
});
# redraw
redraw()
Requests a widget redraw.
Arguments
N/A
Returns
N/A
Example
widget.redraw();
# destroy
destroy()
Releases the resources of the widget object .
Arguments
N/A
Returns
N/A
Example
widget.destroy();
# on
on(eventName, eventHandler)
Subscribe to a widget event
Arguments
| Name | Type | Description | Example |
|---|---|---|---|
eventName | string | Event to register to | 'beforemenu' |
eventHandler | function | Event handler function |
Returns
N/A
Example
widget.on('initialized', function () {
console.log('widget initialized');
});
# Events
# initialized
Fired when the widget is initialized.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# domready
Fired when the widget is rendered and added to the DOM.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# refreshed
Fired when a widget is refreshed.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# buildquery
Fired when executing the widget's native build query and allows customization of the JAQL query object before execution.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
query | object | JAQL query object |
# beforequery
Fired before the query is executed.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
query | object | JAQL query object |
# querystart
Fired when the widget's query starts.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# queryend
Fired when the widget's query has ended.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
query | object | JAQL query object |
rawResult | object | JAQL query result |
reason | string | Query reason |
# processresult
Fired when executing the widget's native result processing, and allows customization of the query result before being rendered.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
query | object | JAQL query object |
result | object | processed result |
rawResult | object | JAQL query result |
reason | string | Query reason |
# render
Fired when the widget is rendered.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
reason | string | rendering reason |
disableAnimations | boolean | Indicates whether animations should take place |
# ready
Fired when the widget's rendering is over and the widget is ready.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# readjust
Fired when a layout change is applied to the widget.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# beforewidgetindashboardmenu
Fired when clicking the widget's menu while viewing a dashboard.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance. |
items | object[] | Array of items to be displayed. |
element | DOMElement | The source element that triggers the event. |
cancel | boolean | Determines whether the menu is displayed. |
# beforewidgetmenu
Fired when clicking the widget menu while in Edit Widget mode.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance. |
items | object[] | Array of items to be displayed. |
element | DOMElement | The source element that triggers the event. |
cancel | boolean | Determines whether the menu is displayed. |
# beforeviewloaded
/chart - final Highcharts options /scattermap - Object that contains the map instance and the array of markers. Fired before the Highcharts object/map configuration is either updated or created. The event has two parameters, the first one is the widget model and the second is as described in the event arguments column.
Arguments
| Name | Type | Description |
|---|---|---|
widget | widget | Widget instance. |
element | domobject | Element container |
options | object |
# beforedatapointtooltip
Fired for all widgets that render a tooltip. Allows hooking to the tooltip initialization flow, disables the default application tooltip, and creates a new tooltip instead, or overrides the default tooltip template. The event has two parameters; the first one is the widget model, and the second is as described in the event arguments column. The widgets that support the event are: scatter map, area map and all the charts. In maps it is not possible to use the default tooltip and add some more html to it, it is possible only to change it completely.
For writing a property value from context, write in the template model.varPathFromContext Example: For context.pointScope.total, the template is: <div>model.pointScope.total</div>
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
context | object | Default tooltip context. In charts there is context.pointScope for the point context |
template | string | Angular template string of the default tooltip. Change it to replace the template |
cancel | boolean | Determines whether the tooltip should be shown or not |
# destroyed
Fired when the widget is destroyed and it's resources are released.
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
# processcell
Fired when a cell is being processed and enables customization of the cell attributes (text, data, color, size).
Arguments
| Name | Type | Description |
|---|---|---|
widget | Widget | Widget instance |
panel | datapanel | Data panel the cell is related to |
item | item | The item that the cell is related to |
row | object | The entire result set that the row of the cell belongs to |
cell | object | The cell being processed |