Write Scripts in Script Editor
Script editor lets you, as an application designer, write scripts for each widget and thus create interactive and highly custom-defined
analytic applications.
Context
To enable interactivity, you configure the behavior of widgets and write scripts that are executed when the application user performs
an action in the analytic application. For example, you can add a button widget and assign scripts to the its onClick
event. You can also write scripts based on other system events like the onInitialization event of the application or
scripts that are executed whenever data is changed.
Scripts consist of one or more statements written in a JavaScript-based language, which follow a specific syntax. You write scripts in the
script editor. You can find all objects, fields and functions available for scripting in Analytics Designer API Reference.
Procedure
-
Add a widget to the canvas, for example, a dropdown.
The widget icon and name are displayed in the Outline panel.
-
Hover over the widget name.
An button is displayed
right next to the widget name.
-
Select . If the widget supports multiple events, select and then one of the events that triggers the execution
of scripts.
You can also select in the widget's (More Actions) menu.
The script editor opens in a new tab, which displays the name of the event and the widget or application to which the script will be assigned,
for example, Table_1 - onSelect.
You can change the order of the multiple tabs by dragging and dropping them horizontally.
-
Type in one or more statements with this syntax:
<ComponentVariable>.<function>(<arguments>);.
Tip
You can call the value help at any place in the script by pressing
CTRL
+ Space
.
Sample Code
//Gets the selected text of a dropdown.
var selectedText = Dropdown_1.getSelectedText();
-
When you've finished your script, close the tab by selecting at
its right side.