The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
Using Script Controls to automate tasks in TIBCO Spotfire and TIBCO Spotfire Web Player - Tip of the Week

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
 

Jessica said:

Hey Kevin is there a way that I can write a Scipt in spotfire that ties to a button and when that button is clicked it will load another .dxp file while closing the current one?

If so what would be example code for this.

July 3, 2012 5:38 AM
 

dnaik said:

Is it possible to enable or disable the action control buttons or links through scripting?

July 12, 2012 11:03 PM
 

sivaspotfire said:

All, Is it possible to add colors to the headers

like for "Table Header" to the table visualizations.

and Trellis Header for HeatMap or any other visualizations.

It s a key requrirement. Please share your ideas

July 13, 2012 8:55 AM
 

Sisco said:

I used to read you blog religiously, I can't believe I ever stopped! Now I remember what got me captivated to begin with.

August 17, 2012 11:08 PM
 

Poonam said:

Hi steve,

Can you help with prinitng my visulization. I have 3 pages in my project and I want to print all the pages visulation in a single page.. How to do that>

September 10, 2012 10:22 PM
 

Keerthi said:

Hi Steve,

Can u Plz tell me how to enable and disable a Action control like button using ironpython script

September 16, 2012 9:34 PM
 

Blevins said:

My coder is trying to persuade me to move to .net from PHP.

I have always disliked the idea because of the costs.

But he's tryiong none the less. I've been using WordPress on a

number of websites for about a year and am concerned about switching to another platform.

I have heard fantastic things about blogengine.

net. Is there a way I can transfer all my wordpress posts into it?

Any kind of help would be greatly appreciated!

September 20, 2012 7:43 PM
 

Han said:

Amazing! I found this place on yahoo looking for something completely different- and now

I'm going to have to go back and read the old posts :) So much for my free time this morning, but this was a really great find.

September 20, 2012 8:34 PM
 

Carlos Crosetti said:

Hi, I would like to run an IronPython at startup, ir in other words when the Spotfire document is opened. Is that posible? The script would ask the user to choose from a list of predefined "environments" that will drive a data load from different tables, is that doable?

September 21, 2012 8:46 AM
 

Yang said:

First of all I would like to say wonderful blog! I

had a quick question which I'd like to ask if you don't mind.

I was interested to know how you center yourself and clear your head

before writing. I've had a difficult time clearing my mind in getting my thoughts out there. I do take pleasure in writing but it just seems like the first 10 to 15 minutes tend to be wasted just trying to figure out how to begin. Any ideas or tips? Many thanks!

September 22, 2012 12:32 AM
 

Sisk said:

I really like what you guys are up too. This kind of clever work and reporting!

Keep up the amazing works guys I've added you guys to blogroll.

September 24, 2012 3:34 PM
 

Willie said:

Howdy! Do you know if they make any plugins to safeguard against hackers?

I'm kinda paranoid about losing everything I've worked

hard on. Any suggestions?

September 24, 2012 8:11 PM
 

Fonseca said:

Gracias for inspiring me to go do my own my own investigation.

Yours was way more thought out than mine.

September 24, 2012 9:34 PM
 

Perea said:

I Love Your Site. Essentially every post makes

me crack up, analyze things, and learn something.

September 25, 2012 3:28 PM
 

Key said:

I find it so inspiring that I'm not the only human out there over the age of 20 who doesn't know this kind of stuff!

Time to learn *about all of it*.

September 26, 2012 9:23 AM
 

Law said:

Glad to see an update of this website, finally.

September 26, 2012 6:09 PM
 

Briseno said:

Hi, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam responses?

If so how do you prevent it, any plugin or

anything you can recommend? I get so much lately it's driving me mad so any support is very much appreciated.

September 30, 2012 4:48 AM
 

Pinson said:

I absolutely am loving this article. absolutely gonna need to add this

to my blogroll.

October 2, 2012 8:35 PM
 

Ashcraft said:

I don't believe I could keep up with running a site like this! Excellent job, I just hope you keep going for a long time.

October 4, 2012 3:30 AM
 

Mclendon said:

First off I would like to say superb blog! I had a quick question

in which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your thoughts prior to writing. I have had a hard time clearing my thoughts in getting my ideas out there. I do take pleasure in writing however it just seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or tips? Cheers!

October 6, 2012 1:05 AM
 

Burbank said:

I never in a million years would have thought to look at things like this.

This should make my day a lot easier.

October 6, 2012 5:18 AM
 

Daniels said:

This is a fantastic site I can't believe that I didn't wander onto it already!

October 17, 2012 8:38 PM
 

Markley said:

Oh joyous day yes. This is the one reason I was born. To find you, my long lost blogger

soul-mate.

October 30, 2012 12:18 AM
 

Aldrich said:

Right now it looks like Drupal is the best blogging platform out there right now.

(from what I've read) Is that what you are using on your blog?

October 31, 2012 3:54 AM
 

poke said:

can anyone please share link to learn Iron Python script from basics

November 21, 2012 9:56 PM
 

Clifton said:

Really instructive and superb structure of articles, now that’s user friendly (:.

December 11, 2012 5:25 AM
 

Meredith said:

Aw, this has been quite a nice post. In idea I would such as to devote writing for example this additionally – spending time and actual

effort to produce a very first-rate article… but so what can I say…

I procrastinate alot and also by no method appear

to search out something accomplished.

December 31, 2012 1:18 PM
 

Tracey said:

Hello! plenty of thanks for that the nice writing vogue.

Keep it up!

January 1, 2013 2:18 PM
 

Jamieson said:

I just like this site so much, bookmarked .

January 1, 2013 6:52 PM
 

Caro said:

I just done mine and that i was seeking for a couple of design suggestions and you afflicted me with a few.

January 3, 2013 3:02 AM
 

Dyer said:

Fine site! I really love how it can be trouble-free on my

eyes and the data have been well written. I am wondering how I might be notified when a new post

has been made. I’ve subscribed to your RSS which must

do that the trick! Have a great day!

January 5, 2013 9:03 AM
 

Geary said:

I have beeing scouring that the google for this info and only needed

to thank you for the post. BTW, merely off topic, how can

I find out a duplicate of this theme? – Thanks

January 5, 2013 3:17 PM
 

Terry said:

GPS is actually a heaven sent gadget, it is easy to always pinpoint your

exact location wherever you are.

January 5, 2013 5:11 PM
 

Maupin said:

I visited a whole lot of website on that the other hand

I conceive this one holds something special in it in

it

January 18, 2013 11:56 AM
 

MailTest said:

Hi,

Using Spotfire how to send an E-Mail Notification automatically when some event happen like if actual value crosses the forecasted value, want to get automatic mail notification. Is there any way to achieve this?

March 19, 2013 5:55 AM
 

Sands said:

Once I originally commented I clicked that the -Notify me when new feedback have been added-

checkbox and now every time a remark is added I

figure out four emails with the same comment. Is there any other tactic

you possibly can remove me from that service? Thanks!

April 28, 2013 8:48 AM
 

Espinosa said:

It's enormous that you are getting ideas from this article as well as from our dialogue made at this place.

May 22, 2013 5:14 PM
 

Salas said:

The reason for the silence on keylogger: it represents one of the files contained" highly personalised" information about

his appearance and" hearsay evidence and police officers' opinions",

he said. How will you solve this problem there's a fast and rather simple answer; upgrade the antenna!

May 27, 2013 8:16 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Syndication

Other Spotfire Blogs

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