Adding a script action to a text area or visualization item
As a Spotfire Analyst user (and a script author), you can define your own scripts and add them to action controls in a text area, or as an on-click action for certain visualization items, using the installed client. By using scripts included in an action mod, analysts who do not create scripts themselves can add shared scripts developed by trusted signers. The scripts allow you to incorporate simple actions or tools into your analysis without having to deploy complete AddIns to the server. The scripts have full access to the Spotfire API.
About this task
For security reasons, there are some restrictions for using scripts. For more information, see Usage of scripts and data functions. Script authors should also make sure to save trusted scripts to the library, so that other users can benefit from their work. For even better shareability, scripts can be included in a signed action mod. See Manage trust for more information.
See also IronPython Scripting in Spotfire on the Community for more examples on using scripts in Spotfire.
In HTML mode it is also possible to add some functionality using JavaScript by editing the HTML of the text area. See JavaScript example scripts for more information.
Before you begin
Follow the steps in Adding actions to a text area or Adding actions performed when clicking on visualization items and make sure you select Script in step 3.
Procedure
Example script workflows
Below are more details about how to create and use a few example scripts in Spotfire. These steps can also serve as instructions for how you should work when creating your own scripts. See also IronPython example scripts.
- IronPython example scripts
This topic lists a number of example scripts that can be executed by clicking on action links or buttons in the text area. - JavaScript example scripts
This topic shows some examples of scripts based on JavaScript that can be used in the text area to provide some simple interactivity.
Creating the "Change visualization title" script
This example shows how you can add a script that changes the title of a visualization.
About this task
See Adding actions to a text area for information about how to reach the Action Control dialog.
Procedure
Results
Document.ActiveVisualReference.Title = title
Using the "Change visualization title" script in a text area
When you use a script in an action control you can define how to provide the necessary input for all parameters of the script. This example shows how you can use the script from the previous example on a button in a text area.
Procedure
Creating the "Change filtering scheme" script
This example shows how you can add a script that changes the filtering scheme.
About this task
Procedure
Using the "Change filtering scheme" script in a text area
This example shows how you can use the script created in the previous example on a button in a text area.