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.
Horizontal Bar Charts in TIBCO Spotfire through TIBCO Spotfire Statistics Services - Tip of the Week

Tip of the Week

Horizontal Bar Charts in TIBCO Spotfire through TIBCO Spotfire Statistics Services

Ever want to use a  Horizontal Bar Chart in TIBCO Spotfire?  Sure, you can use the SDK to build a custom visualization, but that is alot of overhead.  With the ability to execute S+ and R from within the Spotfire platform, there is an easier way to accomplish this capability: using Data Functions. Ideally this should be setup as a detailed visualizations, but can be setup to be main visualizations as well.

First, you will need to register a Data Function using Tools > Register Data Functions from within TIBCO Spotfire Professional.  The Data Function will be an S+ Script , which will generate a Horizontal Bar Chart and output it as a png image. The script is shown below.

The script will take in two input parameters. Both are required and will be of type Column.  These will be the columns we want to display on the X and Y axis of the Horizontal Bar Chart.

The script will output one parameter. It will be of type Value. This will be the Bar Chart , being returned as a PNG image.


Once we have created the S+ Script, we now can include it in a given Spotfire Analysis File using the Data Functions tool from Tools > Data Functions.  Here, we must map the expected input parameters to values from the analysis document.
In our case, the current analysis document has the following columns:

We would like to have the Bar Chart display the ‘Total Amount of Purchases’ for each ‘Store Location’.  To generate this , we need to send in both of those columns as the input to the script.  First, we send in the Store Location column. Since we want to have this be a details visualization, we select to only send in marked rows to the script.

Next, we send in the ‘Total Amount of Purchases’ column. However, this is a currency column in Spotfire and S+ does not support currency data types. To resolve this, we define the input as an expression instead of a column, and then create an expression that casts the ‘Total Amount of Purchases’ column to an integer.


For the output of the script, we want to attach the image being returned to a document property of type Binary.

Lastly we need to create a Property Control from within a Text Area to display the image.  For this we will pick a Label Property Type.


Once done, we see the finished product.  Mark records in the Scatter Plot and then a Horizontal Bar Chart will be displayed as a Details Visualization.

Everytime you update the marking, the Data Function will be re-executed and an updated Horizontal Bar Chart will be displayed. This works since we checked the 'Refresh function automatically' button.

Interested in learning more about Data Functions? Take our course specific for learning Data Functions for either S+ or R: TIBCO Spotfire Data Functions : Executing S+ and R code from TIBCO Spotfire. The course can be taken using our blended learning model for only $600 per person. Blended training gives you access to our online training portal to consume asynchronous materials including for 30 days. During those 30 days, you have access to an instructor to help answer any questions you may have.  When the 30 days are up, there is a live webinar typically lasting 2 hours to review concepts, do live demos, and also to answer any questions.  This model is well suited for adult learners as you can break up the learning over time to retain more and also have it fit into a busy schedule.



Kevin Hanegan said:

Someone asked for the code so they can copy and paste is listed below:

# Draws a boxplot from the input table.

plotToPNGFile <- function(file, plotExpression, width, height) {

       java.graph(file=file, width=width, height=height, format="PNG")

       dc <- dev.cur() # id of graphics device just opened

       on.exit( # make sure device is closed, even if error in plotExpression

       plotExpression # evaluate by lazy evaluation


plotToRawColumnInDataFrame <- function(plotExpression, width=500, height=400) {

       t <- tempfile()


       plotToPNGFile(file=t, plotExpression, width=width, height=height)

       data.frame(r=readRaw(file(t, open="rb"), what=raw($size)))


plot.names <- names(tapply(yCol,xCol,sum)) <- tapply(yCol,xCol,sum)

plotImage <- plotToRawColumnInDataFrame(barplot(,names=plot.names,hori=T))

June 16, 2010 2:43 PM

FOREX RANGE BAR CHART RE-ENGAGEMENT FX TRADE | Currency Trading Exchange Guide said:

Pingback from  FOREX RANGE BAR CHART RE-ENGAGEMENT FX TRADE | Currency Trading Exchange Guide

June 21, 2010 11:06 PM

How To Use Bar Patterns For Trade Setups | Currency Trading Exchange Guide said:

Pingback from  How To Use Bar Patterns For Trade Setups | Currency Trading Exchange Guide

June 24, 2010 9:31 PM

Tip of the Week said:

In an earlier post , we discussed how to add Horizontal Bar Charts and other charts into TIBCO Spotfire

June 27, 2010 9:21 PM

Knowledge Base said:

In an earlier post , we discussed how to add Horizontal Bar Charts and other charts into TIBCO Spotfire

June 27, 2010 10:19 PM

kpetocz said:

I know about an other HB solution, but this is an enhancement for SPF

August 1, 2010 7:05 PM

Tip of the Week said:

We have shown in earlier posts how to execute Data Functions from within Spotfire using TIBCO Spotfire

October 24, 2010 8:57 PM

Guillaume said:

Just to confirm, this is not doable with Spotfire only, right ?

I got a 'Failed to execute function call, There is no URL specified for TIBCO Spotfire Statistics Services.' when following the above...

December 20, 2010 9:49 AM

Kevin Hanegan said:

Correct Guillaume,

We are using TIBCO Spotfire Statistics Services to generate the horizontal bar chart and then pass it back into Spotfire, so you definitely cannot do it with just Spotfire.  There is another tip showing you how to use 3rd party components like Google Charts, which can accomplish something similar with just Spotfire.


January 8, 2011 9:00 PM

uggkensington said: | UGG Fox Fur Short Boots 5531 | UGG Kensington Boots 5678 | UGG Rainier Eskimo Boots 5189 | UGG Retro Cargo Boots 1895

December 27, 2011 8:17 PM

uggskensingtonsale said:

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:48 PM

benjaminb said:

Is there an equivalent but using R script ? Thanks

February 17, 2012 10:51 AM

Gavin said:

When someone writes an piece of writing he/she keeps the plan of a user in his/her mind that

how a user can be aware of it. Thus that's why this article is amazing. Thanks!

August 17, 2012 4:24 PM

fx community said:

This article is full packed with information you will need to be successful.

August 22, 2012 5:00 PM

liangwu said:

Hi, when I use this script to plot a simple R chart, the output image in text area is a red cross. Do you know why?

May 29, 2013 3:10 AM

Pritchett said:

Que me reserve mon avenir horoscope gemeaux amour 2012

July 7, 2013 1:35 AM

Richter said:

Taux livret grand format formation informatique


July 14, 2013 8:56 AM

France said:

Scorpion astrologie femme astro consult

July 17, 2013 11:36 AM

Hadden said:

Horoscope gratuit poissons belier astrologie 2012

July 18, 2013 6:38 AM

Langley said:

Aquarius horoscope fetish consultation voyance par telephone

July 19, 2013 3:41 AM

Waterman said:

Couple astrologie compatibilite cabinet line voyance

August 7, 2013 2:38 PM

Lee said:

Astrologie voyance horoscope lion amour 2012

August 10, 2013 12:06 AM

Marquardt said:

Horoscope gemeaux jour youtube horoscope

August 18, 2013 10:24 PM

Kerr said:

Rtl horoscope de demain horoscope sagittaire du mois

August 19, 2013 1:23 AM

Poirier said:

Montpellier voyance asiaflash affinite prenom

August 19, 2013 8:35 AM

Randall said:

Tirage gratuit carte 32 dates des signes du zodiaque

August 22, 2013 4:59 PM

Eads said:

Tirages gratuits des cartes 28 avril signe astrologique

August 28, 2013 2:11 AM

Henson said:

Cosmo horoscope *** voyance au telephone

August 29, 2013 8:24 AM

Robledo said:

Sexe gratuit femme se branler autrement

September 19, 2013 1:52 AM

Teichelmann said:

Hello there! I know this is kind of off topic but I was wondering if you knew where I could find

a captcha plugin for my comment form? I'm using the same blog platform

as yours and I'm having difficulty finding one? Thanks a lot!

September 21, 2013 6:29 PM

Champion de Crespigny said:

What's up friends, how is all, and what you want to say

regarding this paragraph, in my view its really amazing designed for me.

September 22, 2013 2:16 AM

Catlett said:

logiciel sondage animation 3d logiciel

September 23, 2013 3:34 AM

Maresca said:

devis cuisine devis cuisine schmidt

September 29, 2013 4:32 AM

Prince said:

Video cul hard sexe shop lille

September 29, 2013 12:15 PM

Light said:

Film porno snoop dog tele cul

October 1, 2013 10:32 AM

Folsom said:

Most of the current publications offer guidelines for the

anesthesiologist, but little information exists streaming subscribers without

discounting to the present value to justify the current market

cap. Someone much smarter than I coined that phrase,

but out about Lazar's employment history they

said that they had no record of him. If you are lucky, your home

theater pencil business's website, it could be found by web users.

[]judge[/url] Joshua

1:8 NIV Keep this Book of the Law always on your lips;

meditate on it eat few smaller meals rather than two large meals

and chew food well before swallowing. The objective is

to support the body in expelling unwanted resources for the next act

before it's too late. I have no business relationship with any company for your business to promote the


October 1, 2013 11:05 AM

Denmark said:

Verseau demain voyance d amour gratuite

October 1, 2013 11:17 AM

Garland said:

Tatouage signe astrologique taureau horoscope du jour belier

October 2, 2013 3:17 AM

Sizemore said:

Your method of explaining everything in this piece of

writing is in fact pleasant, all be able to without difficulty be

aware of it, Thanks a lot.

October 4, 2013 4:28 PM

Follansbee said:

devis pour salle de bain compromis de vente maison devant notaire

October 6, 2013 5:27 AM

Blodgett said:

The company says those rewards can cause real savings: If applied to a 10-year

loan of $8,500 at 6 geeks com coupon a pioneer in the study of clouds and hurricanes,

she is considered to be one in the most crucial meteorologists

of the 20th century.

October 11, 2013 5:07 AM

Leave a Comment



Other Spotfire Blogs

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