Tip of the Week

Using Script Controls to automate tasks in TIBCO Spotfire and TIBCO Spotfire Web Player

The TIBCO Spotfire SDK allows developers to do three things: Automate, Extend, and Integrate. Automations allow us to automate common tasks and idioms inside TIBCO Spotfire Professional.  Extensions allow us to create extensions to the Spotfire platform, like new visualizations, new calculations, new panels, etc…Integrations allow us to integrate Spotfire Professional and/or the Spotfire Web Player into other applications and components.


In TIBCO Spotfire version 3.1, TIBCO introduces the concept of Script Controls. Scripts Controls provide the ability to add IronPython scripts into a Text Area inside a Spotfire Analysis file. The script has access to the full Client API (from the SDK), and its goal is to perform common automation tasks. Its purpose is not to do or replace any extensions or integrations.   So, the next question is for automation, should I use the full SDK or should I use the Script Controls? There is some overlap, but there are a couple of key differences. 

First, using the full SDK is for more powerful algorithms or automations which are meant to be used inside TIBCO Spotfire Professional or Enterprise Player only.  In these situations, you are usually displaying a dialog and adding capabilities to help out a Business Analyst or Author.  Using the Script Controls  is for when you want to do some lightweight automation, where you do not need a dialog, and you wish to have the solution work in all the TIBCO Spotfire Clients, including the Web Player. Therefore, the functionality created using the Script Controls typically will benefit the Business Author.

The second important difference between the full Client APIs from the SDK (using C#) and Script Controls is that full extensions built using our C# API are built in the Spotfire application itself. This means it can work across and be available for any Spotfire document.  Script Controls, on the other hand, are built and stored inside a specific document.  If you wish to use them in multiple documents, you need to copy the script into each one.

Let’s look at a two use cases to highlight the difference between the C# APIs and Script Controls. Assume you want to create a tool that acts as a template selection tool, which will provide the user with two lists: first a list of data tables, and then another list of templates to choose from. The tool will allow the user to select values from each list box and load and configure the appropriate document in Spotfire.  For this, you would use the full C# API to build a custom tool, which includes a dialog. This solution will not work  in the Web Player, as these types of changes should be done in the Professional Client and the tool is targeted at Business Analysts and Authors.

Next , assume you created a document which includes a property control to define where to expose a vertical reference line in a Scatter Plot. You can have the user enter a number and have the reference line move to that location. But what if you wanted to allow the business user to toggle the reference line on or off? For this, properties will not work, but we can leverage Script Controls. 

So how do you build such a Script? First, you need to turn on editing in a Text Area, and then select the Insert Action Control icon.  On the resulting Action Control dialog, choose to create a new script.


 
Then , in the next dialog, give your Script  a name and enter the Script.


 

Once you are done, click OK, and you are ready to use your script.


 
For more information about Script Controls, including details of IronPython, how to use Properties as input and outputs to the Scripts, and best practices, please attend our 3.1 Delta Training or our dedicated course, Using Script Controls inside TIBCO Spotfire.

 


 

Comments

 

Steve Marshall said:

Hey Kevin

Do you have any examples where you can create a new visualization using the scripting API...

I've got this but I'm puzzled as to why chart is a boolean...

import Spotfire.Dxp.Application.Visuals

from Spotfire.Dxp.Application.Visuals import BarChart

chart = Application.Document.ActivePageReference.Visuals.AddNew<BarChart>()

dataManager = Application.Document.Data

print dataManager

print chart

The output is

<Spotfire.Dxp.Data.DataManager object at 0x000000000000002B [Spotfire.Dxp.Data.DataManager]>

True

April 5, 2010 1:59 PM
 

Cortal Consors Turns to TIBCO Spotfire(R) Analytics Platform for Real-Time Decision Support | Comprehensive Software listings, Reviews and Articles said:

Pingback from  Cortal Consors Turns to TIBCO Spotfire(R) Analytics Platform for Real-Time Decision Support | Comprehensive Software listings, Reviews and Articles

April 12, 2010 12:59 PM
 

Kevin Hanegan said:

Hi Steve,

Your close, but the syntax is a bit off. For IronPython you typically have to use square brackets instead of less than and greater than brackets, so the line to create the Bar Chart should be:

chart = Application.Document.ActivePageReference.Visuals.AddNew[BarChart]() and it will work.

However, also note that by default a chart, when created via the API, will be empty and you need to define which data table to use, which filtering to use, which marking, etc... To have Spotfire select the default settings, call the AutoConfigure method off the chart, like the following:

chart.AutoConfigure()

April 17, 2010 7:44 PM
 

kunal prajapati said:

Hi all can any one help me how to link the bookmarks through script.

July 7, 2010 5:52 AM
 

Kwang-Shi Shu said:

Hi Kevin,

   I created a spotfire document for a clinical trial that contains many data tables. I reused it for another study. However, I need to replace every data table that takes time.

 I would like to write a Python Script to automate the work, i.e.

1) find all data tables in the document.

2) for each table, replace it with new study data, i.e. replace the path

   I just wonder whether you have example for this task?

  Regards,

Kwang-Shi

July 27, 2010 3:19 PM
 

Ambuj said:

Hi Kevin,

I am trying to open a text and csv file in spotfire application using 3.2.1 version in .Net,

But when assign the filePath and try to open the document, I gives me "Exception has been thrown by the target of an invocation" Exception.

If you have any solution of the above problem, please help me, I am blocked from several days, and also it is taking so much time to getting the help from TIBCO Dev support.

I you have any solution, please mail me @ ambuj.saxena@accelrys.com

Thanks !

Ambuj

February 21, 2011 1:23 PM
 

MP said:

Kevin,Do you know if there is a good resource with examples for this scripting?

Also, how do you debug these scripts?

thanks

March 28, 2011 9:19 AM
 

Bhushan said:

Hi,

Can I change the column names dynamically in cross table? If yes, then how can I achieve that?

Thanks,

Bhushan

September 13, 2011 2:22 AM
 

uggkensington said:

http://www.uggkensingtons.org/

http://www.uggkensingtons.org/ugg-fox-fur-short-boots-5531-c-54.html | UGG Fox Fur Short Boots 5531

http://www.uggkensingtons.org/ugg-kensington-boots-5678-c-2.html | UGG Kensington Boots 5678

http://www.uggkensingtons.org/ugg-rainier-eskimo-boots-5189-c-85.html | UGG Rainier Eskimo Boots 5189

http://www.uggkensingtons.org/ugg-retro-cargo-boots-1895-c-3.html | UGG Retro Cargo Boots 1895

December 27, 2011 8:17 PM
 

uggskensingtonsale said:

www.uggskensingtonsale.org

www.uggskensingtonsale.orgugg-adirondack-boots-ii-c-6.html | UGG Adirondack Boots II

www.uggskensingtonsale.orgugg-adirondack-tall-boots-c-11.html | UGG Adirondack Tall Boots

www.uggskensingtonsale.orgugg-amberlee-boots-c-34.html | UGG Amberlee Boots

www.uggskensingtonsale.orgugg-annabelle-boots-c-35.html |

December 28, 2011 4:22 AM
 

uggretrocargosale said:

January 4, 2012 8:50 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Syndication

Tags

Other Spotfire Blogs

Spotfire's interactive information visualization and analytic solutions give users a remarkable experience for quickly and easily querying data and reporting results for superior business intelligence. From portfolio management and customer retention programs to key processes such as CRM, marketing, research, bioinformatics, yield and asset management and design for manufacturing, enterprises around the world rely on Spotfire's business analytics software to improve operational performance.

©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center