Developers Corner

Incorporating JavaScript into Spotfire Text Areas

  • Would you like to learn to apply JavaScript in Spotfire?
  • Would you like to understand what you can do with JavaScript in text areas?

A user recently asked for clarification on how to add JavaScript to Spotfire text areas.  You can Google Spotfire and JavaScript to find code examples, but if you don’t know the basics, they can be difficult to implement.  This post will explain those basics.

Overview of JavaScript and Spotfire

Before I dive into details, if you are unfamiliar with how JavaScript, HTML, CSS, and IronPython work together in the text area, I recommend reading this post explaining the context of each programming language.

Now that we know JavaScript is what triggers or controls action and interaction, consider it to perform a wide variety of tasks, such as…

  • Passing a calculated value to a document property
  • Showing and hiding property controls
  • Performing a set task at an interval

Next, let’s look at how to add JavaScripts to the text area.

How to Add JavaScript

  1. Toggle the text area into edit mode by right-clicking on it and selecting Edit HTML.
  2. Click the Add JavaScript button  Add JavaScript button
  3. Click the New button
  4. Name the script
  5. Enter the script
  6. Add any parameters required
  7. Click Ok
  8. After exiting, you will see the JavaScript in the menu to the right (as shown below).

JavaScript in Menu












Not To Be Confused With…

Using JavaScript in text areas should not be confused with jQuery.  jQuery is a JavaScript library written in JavaScript.  jQuery can do everything JavaScript can, but jQuery helps the developer perform tasks with fewer lines of code.  jQuery is used within the HTML <script> tags as shown below.



If you would like to practice JavaScript, follow the instructions in this post to set the title of a visualization to the current date.


Additional Notes

  1. Test all JavaScripts when upgrading versions of Spotfire.  JavaScript will not always work from one version to the next.  Things change.  Test it.
  2. You must have HTML sanitation turned off in order to use JavaScript.
  3. In my opinion, JavaScript in Spotfire is finicky and difficult to troubleshoot.  For some reason, changing ids fixes a lot of problems.  I don’t know why.
  4. JavaScript Best Practices from TIBCO Community

Spotfire Version

Spotfire version 7.9.1 was used to develop this content.


Leave a Reply

Your email address will not be published. Required fields are marked *