Making your Data Dance in TIBCO Spotfire Web Player


In last week’s post, we learned how to animate visualizations by looping through filters automatically. This week we will learn how to get this solution to work in the Web Player.  This is a three part process. The first part is to deploy the tool to the Web Player server. The second part is to execute the tool as a button from within a text area. The third and final part is to provide a method for consumer to update parameters for the tool (the refresh rate, and which column to use). We will discuss the first two in this post, and the third section in next week’s post.


Deploy the Tool to the Web Player
For our tool to be available to use from within the Spotfire Web Player, we first need to make sure the tool’s dll is deployed to the Web Player server. This is documented in detail in Section 4.2 of the Spotfire Web Player Installation Manual

This requires running an ‘Web Update Tool’ which will search the Spotfire server to find new deployed extensions, and deploy them to the Web Player.

Execute the Tool from within a Script Control
Next, we need to be able to call the tool from within the Web Player. By default, tools (with the exception of custom export tools) does not show up in the Web Player UI. However, using the APIs, there is a collection off the Application object called Toolbox, which allows developers to execute Custom Tools.   We can execute this code from within a script and attach it to a button from within a Text Area.


In order for the script to see the Custom Tool dll, we first need to add a reference to it. Assume the DLL for our Custom Tool is called SpotfireTraining.Animate filters, we would add the following lines of code to reference it.

import clr
clr.AddReference("SpotfireTraining.AnimateFilters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=481d6bdd0b956834")

You can get the exact values to put in for the AddReference method from the tool’s module.xml file.

After you do this, you will need to import the custom tool class from your DLL. Assuming our custom tool class is called AnimateFiltersTool, you would need to add the following:

import Spotfire.Dxp.Application
from SpotfireTraining.AnimateFilters import AnimateFiltersTool

Next, we need to call the TryGetTool method off the Toolbox collection and pass in the  custom tool class name:

found, tool = Application.Toolbox.TryGetTool[AnimateFiltersTool]()

Finally we check to see if the tool was found, and if it is we call the Execute method , this will execute the tool. Depending on which type of tool it is , you will need to also pass in the context for the tool. In our example, we did a Page tool (which means the tool shows up in Spotfire Professional when you right click on a page tab). In this case, we are creating a Script parameter which passes in the specific page as an argument with the variable called ‘page’.

if found:

  tool.Execute(page)

NOTE: The Toolbox collection only works on custom tools built using the SDK, it will not work on built-in tools.

The complete script is shown below:

import clr
clr.AddReference("SpotfireTraining.AnimateFilters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=481d6bdd0b956834")
import Spotfire.Dxp.Application
from SpotfireTraining.AnimateFilters import AnimateFiltersTool

found, tool = Application.Toolbox.TryGetTool[AnimateFiltersTool]()
if found:
  tool.Execute(page)

Want to see the file in action in the Spotfire Web Player?  Click here.

 


 
Since our tool does not display a dialog, this will work fine in the Web Player.  Next week, in the third and final tip on this topic, we will learn how we can add parameters into the tool (which column to select and what the refresh rate should be) and allow the consumer to configure them in the Web Player.

If you are interested in learning how to complete a tool like this yourself, consider taking our Developer Bootcamp. If you would like to have Spotfire build this tool or a similar tool for you, please contact Professional Services.