Business Intelligence Tools / Developers Corner

Spotfire & JavaScript — Setting the Visualization Title to Current Date

  • Do you want to know how to add a dynamic date to the title of your visualization?
  • Do you want to learn more about using JavaScripts in Spotfire?

I was recently asked how you could add the current date to the title of a visualization.  This is a tricky thing to do with out of the box functionality.  As you can see in the screenshot below, you can configure a dynamic title using property controls or other “default properties”, but you aren’t allowed to use custom expressions in the title, so the DateTimeNow function is not an option.


Instead, this can be done with JavaScript following the steps shown below.

  1. Name the visualization that will have the dynamic date, and give it a simple name like MyVis or MyMap
  2. Add a text area to the page
  3. Right click on the text area and select Edit HTML
  4. Add a JavaScript to the HTML by clicking the insert JavaScript button


5. Click the New button and name the script

6. Paste the following script:

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {

if(mm<10) {

today = mm+'/'+dd+'/'+yyyy;


7. In the last line of code, swap out ‘MyViz’ with the name of your visualization.  Make sure to leave in the single quotes.

If you would like add additional text to the title, change the second to last line of text to something like this…

today = mm+’/’+dd+’/’+yyyy + ‘ Description of Vis Purpose’;


Now you have a visualization title inclusive of a dynamic date.

1 thought on “Spotfire & JavaScript — Setting the Visualization Title to Current Date

  1. Pingback: Incorporating JavaScript into Spotfire Text Areas - Data Shop Talk

Leave a Reply

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